Generated from the shipped type definitions.
fn delay(ms: number): Promise<void>
Await a delay of ms milliseconds before continuing. Tick-integrated (resumes on a game frame).
import { delay } from "@s2script/sdk/timers";
// plugins/funcommands/src/plugin.ts:77 — sm_freeze auto-unfreeze after `secs`
delay(secs * 1000).then(() => { const q = Player.fromSlot(slot); if (q && q.pawn) q.pawn.moveType = WALK; });
fn nextTick(): Promise<void>
Yield to the next microtick.
fn nextFrame(): Promise<void>
Yield until the next game frame.
fn threadSleep(ms: number): void
Block the current thread (fiber) for ms milliseconds.
Only valid inside a threadSleep-capable fiber context.
A live callback timer, returned by after and every. Ledgered against the creating
plugin: unload kills it whether or not kill() was called, so a repeating timer can never outlive
its plugin and fire into a dead context.
fn after(ms: number, fn: () => void): Timer
Run fn once after ms milliseconds (SourceMod CreateTimer without TIMER_REPEAT).
Prefer delay when you can await; use this when you need something cancellable.
A throwing callback is reported and contained — it never kills the frame or the timer system.
import { after } from "@s2script/sdk/timers";
const t = after(5000, () => console.log("5s later"));
t.kill(); // ...unless cancelled first
fn every(ms: number, fn: () => void): Timer
Run fn every ms milliseconds until killed (SourceMod CreateTimer with TIMER_REPEAT).
The next firing is scheduled *after* the callback returns, so a slow callback cannot pile up.
ms must be greater than 0 — a zero-interval repeat would re-arm every drain and starve the
frame, so it throws rather than degrading.
import { every } from "@s2script/sdk/timers";
const tick = every(1000, () => console.log("tick"));
// later: tick.kill();