Modules

Docs / API / Modules / timers

Timers

Platform

@s2script/sdk/timers

Tick-integrated async timing: delay, nextTick, nextFrame, threadSleep.

Import

import { delay } from "@s2script/sdk/timers";

Author-time types ship in the npm package; the engine injects the runtime at plugin load. Add @s2script/sdk to your plugin's dependencies.

API reference

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.

Back to modules All packages

s2script — Source 2 plugin framework

GitHub