Search docs
Search modules and symbols
API overview

API overview

Author-time types ship in two npm packages; the engine injects the runtime at load:

  • @s2script/sdk — every engine-generic capability, one per subpath (@s2script/sdk/entity, /events, /chat, …). Also carries the s2s build CLI.
  • @s2script/cs2 — CS2 game types (Player, Pawn, schema accessors, the typed event overlay, ChatColors).

How imports work

import { plugin } from '@s2script/sdk/plugin';
import { HookResult } from '@s2script/sdk/events';
import { Player } from '@s2script/cs2';

Add @s2script/sdk (and @s2script/cs2) to your package’s dependencies. The CLI externalizes both by wildcard; the host maps @s2script/sdk/<name> → the injected runtime module.

Two flavors of API

  • Load-scoped subscriptions go through the ctx your factory receives — ctx.commands, ctx.events, ctx.clients, ctx.entities, ctx.server, ctx.config, plus ctx.use / ctx.publish. These are ledgered and torn down on unload.
  • Stateless helpers are plain named imports — Chat, Player, Admin, config, Events.fire, delay, fetch.
export default plugin((ctx) => {
  ctx.events.on('round_start', () => Chat.toAll('go!'));   // subscription → ctx
  ctx.server.onGameFrame(() => { /* per-frame */ });        // subscription → ctx
});

Engine-generic highlights

SubpathRole
@s2script/sdk/pluginplugin(), PluginContext, Scope
@s2script/sdk/entityEntityRef, create/spawn, I/O
@s2script/sdk/eventsFire events + HookResult
@s2script/sdk/timersdelay / nextTick / nextFrame
@s2script/sdk/clientsClient handle
@s2script/sdk/commandsCommand dispatch types
@s2script/sdk/chatChat send
@s2script/sdk/adminAdmin flags + cache
@s2script/sdk/serverServer.command, cvars
@s2script/sdk/dbSQLite / SQL database
@s2script/sdk/http · /ws · /netAsync network
@s2script/sdk/menu · /votesMenus + votes

CS2

@s2script/cs2Player, Pawn, schema accessors, the typed event overlay, ChatColors, pickPlayer, Fade/Shake/HintText.

Next

s2script — Source 2 plugin framework

GitHub