Function: AddTimer(spawn, time, function, max_count, player)
Description:
Schedules a named spawn script callback after an initial delay. The timer remembers
the original spawn and optional actor allocation without keeping either alive for
the delay. A retired spawn or a different allocation using its runtime ID cannot
receive the callback. If the optional actor is no longer available in the timer's
zone, the callback receives nil for that argument.
Parameters:
spawn(Spawn) - The original spawn that owns the timer.time(uint32) - Initial delay in milliseconds. Zero is rejected; values below 10 are raised to 10.function(string) - Nonempty callback name.max_count(uint32, optional) - Number of callback attempts; omission or zero means one. Repeated callbacks run on subsequent timer checks after the initial delay; the delay is not restarted between attempts.player(Spawn, optional) - Original optional actor. NPC spawn scripts receive(spawn, player); Player scripts receive(zone, spawn, player). Omission suppliesnilfor the optional actor.
Returns: None.
Dispatch and cancellation:
Callbacks run outside the timer registry lock with owned actor loans. A callback
can add or stop timers. New timers wait for the next traversal. StopTimer also
cancels queued callbacks that have not entered, including ones captured by the
current traversal; it cannot interrupt a callback already entered. Native argument
preparation failure before admission leaves the timer available for a later check.
An entered callback attempt is not automatically replayed after a partial error.
For Player timers, the global and zone Player scripts use the same admitted actors.
See Lua actor lifetime.