[HELP] Server side threads?

Is it possible to make server side threads so that I can have the server poll users for a information every x seconds?

As it stands I know its possible to have the data come in from the client side every x seconds, but I’d rather have a more synchronised time this is done, so I know the data is as ‘fresh’ as possible without being a resource drain.

Thanks,

You could use something like
SetTimeout([time], function() end)
to run some code every ‘x’ seconds

That should actually do the trick nicely. This wouldn’t interrupt the ability to accept a callback from a client side method, right?

Or would it be best to call a function with a built in delay to account for data coming back?

If you are triggering the client side method in the timeout function it should be fine.
I haven’t made code that does this myself but here’s an example from EssentialMode that is used to update the player money.

-- Function to update player money every 60 seconds.
local function savePlayerMoney()
	SetTimeout(60000, function()
		TriggerEvent("es:getPlayers", function(users)
			for k,v in pairs(users)do
				MySQL:executeQuery("UPDATE users SET `money`='@value' WHERE identifier = '@identifier'",
			    {['@value'] = v.money, ['@identifier'] = v.identifier})
			end
		end)

		savePlayerMoney()
	end)
end

savePlayerMoney()