Skip to content

OnTick

Every simulation tick, with the time since the last one.

Thirty times a second ([rates] tick_hz), after the tick’s network events were applied. Whatever runs here runs for every tick of every player’s game, so keep it to a few lines; do the heavy things on a timer every second instead. The server log reports the slowest tick while the budget is missed.

function OnTick(dt)
-- ...
end
Parameter Type
dt number seconds since the previous tick (0.033 at 30 Hz)

nothing

local elapsed = 0
function OnTick(dt)
elapsed = elapsed + dt
if elapsed >= 1 then -- once a second is enough for most bookkeeping
elapsed = 0
checkRound()
end
end

SetTimer · GetServerTick · the Server and timers group of the index