Hookpoints: UpdateServer - SignatureBeef/Terraria-s-Dedicated-Server-Mod GitHub Wiki

Summary

This event is fired on every server update. This is about every 16ms. Use care when using this one since it could really make a large performance hit on the server if you have it doing a lot.

Object Returned

There is no object returned.

Example

Lua
This demonstrates how you can find out the actions the player is performing in real time. Printing it to the console is not the best use though.

function YourPlugin:Initialized()
	export.Hooks = {}
	export.Hooks.UpdateServer=
	{
		Call = export.OnUpdateServer,
	}
end

function YourPlugin:Enabled()
	test.plyr = Tools.GetPlayerByName("PlayerName") -- This simply gets the player object for "PlayerName". I put it in Enabled() for the example, but you probably would want it elsewhere.
end

function YourPlugin:OnUpdateServer()
	if test.plyr ~= nil then
		if test.plyr.controlRight then
			Tools.WriteLine("RIGHT")
		elseif test.plyr.controlLeft then
			Tools.WriteLine("LEFT")
		elseif test.plyr.controlUp then
			Tools.WriteLine("UP")
		elseif test.plyr.controlDown then
			Tools.WriteLine("DOWN")
		end
	end
end