Skip to content

Timers

Function Description
swizzin.timer.after(ms, fn) Runs fn once after ms milliseconds (0 to 86,400,000). Returns an id
swizzin.timer.every(ms, fn) Runs fn repeatedly every ms milliseconds (at least 100). Returns an id
swizzin.timer.cancel(id) Cancels a timer
--! name: Reminder
--! api: 1
--! permissions: send
swizzin.command("remind", function(ctx, args)
local target = ctx.target
swizzin.timer.after(60000, function()
if target ~= nil then
swizzin.send(target, "One minute is up")
end
end)
end)
  • A timer keeps the network context it was created in.
  • Each script may have at most 32 live timers.
  • All timers are cancelled when the script stops or reloads.
  • A timer callback is a callback like any other: it must finish within 250 ms.