Modules
Generated API reference for @s2script/sdk subpaths and @s2script/cs2. See also the package reference.
- Config @s2script/sdk/config Platform
typed access to the plugin's materialized config.
- Console @s2script/sdk/console Platform
Injected console logging for plugins.
- Engine calls (unsafe) @s2script/sdk/unsafe Platform
Call or detour an engine function the framework does not wrap. Declare it in `gamedata/functions.jsonc` and bind with `Engine.function` — `s2s build` derives `engine:calls` / `engine:hooks`. Validated at load; optional bindings degrade with structured `status`. Operator allow-list still default-deny.
- Entity @s2script/sdk/entity Platform
Liveness-gated EntityRef handles, typed reads/writes, create/spawn/teleport/remove, and entity I/O.
- Interfaces @s2script/sdk/interfaces Platform
Protocol 2 contract types: Notification, Hook, Transform, Subscription, AttachmentScope. Name-inferred publish / use, bindForwards, and watchOptional. Protocol 2 `on` returns an idempotent Subscription (not a numeric id).
- Math @s2script/sdk/math Platform
Vector and QAngle value types plus helpers like forwardVector.
- Plugin @s2script/sdk/plugin Platform
Load-window authoring: `hook` (game-event catalog: hook.on / hook.onPre), previous(), pluginId(), publish / use / tryUse / watchOptional / bindForwards, onOutput, createScope, Scope. The artifact is export function OnPluginStart (plus optional named publics). CJS evaluation is before the load window.
- Plugins @s2script/sdk/plugins Platform
runtime plugin management (the SM `sm plugins` backend).
- Timers @s2script/sdk/timers Platform
Tick-integrated async timing: delay, nextTick, nextFrame, threadSleep (Promise). Overload rejects or throws AsyncQueueFull.
- Clients @s2script/sdk/clients Players & world
A Client is a handle to one connection lifetime. Reusing a slot never revives a saved handle. Disconnect callbacks expose a synchronous identity snapshot; stale getters and actions return safe defaults.
- Damage @s2script/sdk/damage Players & world
Borrowed DamageInfo view of a live damage event (throws "expired borrowed view" after the synchronous callback). Subscribe with SDKHook (OnTakeDamage / OnTakeDamagePost), provided by the selected game package. Post assignment of damage is ignored.
- Events @s2script/sdk/events Players & world
Typed game-event bus: fire / fireToClient, HookResult, and the block-scoped GameEvent accessor.
- SDKHooks @s2script/sdk/sdkhooks Players & world
Per-entity SDKHook / SDKUnhook (SourceMod-shaped). OnTakeDamage / OnTakeDamagePost; SetTransmit AND-merges with Transmit.setVisibleTo; lifecycle virtuals (Spawn, Think, Use, …); Weapon* / Reload.
- Sound @s2script/sdk/sound Players & world
engine-generic sound: emit a named SoundEvent + register custom precache paths.
- Trace @s2script/sdk/trace Players & world
Ray / line / hull traces returning a liveness-gated hit entity.
- Transmit @s2script/sdk/transmit Players & world
Declarative per-client visibility masks. AND-merges with SDKHookType.SetTransmit — either API can hide; SetTransmit cannot un-hide a native mask clear.
- User Commands @s2script/sdk/usercmd Players & world
a SourceMod `OnPlayerRunCmd`-equivalent: intercept, read, modify, and block a player's per-tick input (buttons, view angles, movement, impulse) before the game processes it.
- User Messages @s2script/sdk/usermessages Players & world
A general protobuf user-message builder.
- Voice @s2script/sdk/voice Players & world
Who can hear whom: per-sender audibility rules (`Voice.setAudibleTo`) that AND-merge across plugins, plus hot-path counters (`Voice.stats`).
- Admin @s2script/sdk/admin Admin & chat
engine-generic admin flag model + cache API. Resolved at runtime via `globalThis.__s2pkg_admin`; no game-specific symbols. Import: `import { ADMFLAG, Admin } from "./admin";`
- Bans @s2script/sdk/bans Admin & chat
Host-global SteamID64 ban cache. `Bans.add` updates the cache then attempts persistence (void; no rollback). `Bans.remove` returns whether a cache key existed, not disk ACK.
- Chat @s2script/sdk/chat Admin & chat
print messages to player chat.
- Commands @s2script/sdk/commands Admin & chat
Load-window `command()` / `command.admin` / `command.server`. `Command` is an alias for `CommandInvocation`. Owned handlers return `HookResult.Handled`.
- Menu @s2script/sdk/menu Admin & chat
Slot-based menus. On CS2, Center and Chat paint a hudkit center sheet from the six-sheet pool (claim on first open, release when idle; Chat fallback per session if the pool is busy or the HUD open fails). activation is immediate or tab.
- Server @s2script/sdk/server Admin & chat
Server.command, cvars, and map validity. Map start is the named public `OnMapStart`.
- TopMenu @s2script/sdk/topmenu Admin & chat
Shared admin/top-menu registry. Plugins declare a tab with `addTab({ id, title })` then `addItem(tabId, item)`. Items default to the admin sheet (`sm_admin`); opt into the player hub (`sm_menu`) with `sheets: ["menu"]`. Snapshot `tabs` is `{ id, title }[]`; `categories` stays tab ids.
- Translations @s2script/sdk/translations Admin & chat
SourceMod-style i18n (per-client language, phrase files, {1} formatting).
- Votes @s2script/sdk/votes Admin & chat
Chat-ballot votes. On CS2, a right-side rail on s2script_lib (hudkit.layout — not a Menu, not a hudkit modal, not a second CustomHudLayout). VoteTally.choice is the per-slot 0-based cast. showLiveTally is ignored when a tally renderer is registered.
- Cookies @s2script/sdk/cookies Persistence
SM-parity client preference cookies. Cookies.set / setAuthId return boolean admission — false leaves the cache unchanged; true is host-owned until DB ACK, not a durability guarantee.
- Database @s2script/sdk/db Persistence
Async SQLite / SQL. query / execute reject with AsyncQueueFull or AsyncPayloadTooLarge before acceptance; oversized results reject with DatabaseResultTooLarge.
- HTTP @s2script/sdk/http Network
Off-thread fetch. Admission rejects with AsyncQueueFull / AsyncPayloadTooLarge; oversized responses reject with HttpResponseTooLarge.
- Sockets @s2script/sdk/net Network
Raw TCP / UDP sockets. TcpSocket.send and UdpSocket.sendTo return boolean admission — false means closed, oversized, or full; true is queued, not delivered.
- WebSocket @s2script/sdk/ws Network
Client WebSocket. send returns boolean admission — false means closed, oversized, or full; true is queued, not delivered.
- CS2 @s2script/cs2 Game CS2
CS2 player/pawn model, schema accessors, typed events overlay, menus, CustomHudLayout / hudkit, CustomPlayerCamera, Fade/Shake/HintText, and pickup gates (`items` / ItemsApi).
- HUD @s2script/cs2 Game CS2
Custom Panorama HUD: CustomHudLayout.create(spec) plus hudkit (modals, badges, toasts, callouts, banners, MOTD, dashboard). `CustomHudSpec.observable` (default false) is spectator rendering policy, not confidentiality. Use from OnPluginStart or later; pre-ctx methods throw. Modal/badge null is pool exhaustion (`tryModal` / `tryBadge` report PoolExhausted). spec/descriptor stay readable at module top-level. Retained views expose isValid(); modal/dashboard clicks dispatch from the last complete paint. `invalidate()` coalesces next-frame repaints; `refresh()` stays synchronous. tryOwn* / tryOwnDashboard claim shared surfaces (`Busy` instead of overwrite); hideAll preserves explicit claims. Unload/reload clears surfaces; `badge.release()` hides for every remaining viewer. HudLayout.subscribeClick is a disposable sibling of onClick. ui / hud() / components() are deprecated aliases.
- Workshop contract @s2script/sdk/contracts/workshop Interfaces
Type-only contract for a workshop / UGC service. The framework ships no implementation: a community plugin publishes one and consumers depend on this shape.