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 thes2sbuild 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
ctxyour factory receives —ctx.commands,ctx.events,ctx.clients,ctx.entities,ctx.server,ctx.config, plusctx.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
| Subpath | Role |
|---|---|
@s2script/sdk/plugin | plugin(), PluginContext, Scope |
@s2script/sdk/entity | EntityRef, create/spawn, I/O |
@s2script/sdk/events | Fire events + HookResult |
@s2script/sdk/timers | delay / nextTick / nextFrame |
@s2script/sdk/clients | Client handle |
@s2script/sdk/commands | Command dispatch types |
@s2script/sdk/chat | Chat send |
@s2script/sdk/admin | Admin flags + cache |
@s2script/sdk/server | Server.command, cvars |
@s2script/sdk/db | SQLite / SQL database |
@s2script/sdk/http · /ws · /net | Async network |
@s2script/sdk/menu · /votes | Menus + votes |
CS2
@s2script/cs2 — Player, Pawn, schema accessors, the typed event overlay, ChatColors, pickPlayer, Fade/Shake/HintText.
Next
- Full package reference
- Modules catalog — generated from the shipped type definitions
- Concepts: entities, events, commands, async