Generated from the shipped type definitions.
A CS2 player pawn (the in-world body): the generated CCSPlayerPawn schema fields + the liveness-gated ref.
controller is the typed reverse hop (shadows the raw generated m_hController handle).
Nav props (sceneNode, weaponServices, movementServices, aimPunchServices) are generated from nav-targets.json.
Entry point for the Pawn body object — resolve the in-world pawn for a player slot.
import { Pawn } from "@s2script/cs2";
const pawn = Pawn.forSlot(0);
if (pawn) console.log(pawn.activeWeapon?.clip1);
A CS2 player (the persistent controller entity): the generated CCSPlayerController schema fields
(team/score/ping/…) + the liveness-gated controller ref. pawn is the typed body (shadows the raw
generated m_hPawn handle). Referenced by slot (0-based); a stored Player degrades to null on reuse.
Entry point for the Player controller object — resolve players by slot or user-id, enumerate
connected players, or resolve a SourceMod target string.
import { Player } from "@s2script/cs2";
for (const p of Player.all()) p.pawn?.slay();
Game-event subscription (typed overlay). Importing from @s2script/cs2 gives the typed overloads:
Events.on("player_death", ev => ev.getPlayerSlot("attacker")) typechecks via the GameEvents map.
Events.onPre runs before broadcast and may return a HookResult to block.
Events.fire fires an event with typed field constraints.
The off signature matches @s2script/events semantics: removes ALL of this plugin's handlers for name.
Show-activity helper: SourceMod's FormatActivitySource per-recipient decision.
For each connected recipient, call formatSource(actorSlot, recipientSlot) to get
{ show, name } — whether to display the action to that recipient, and under what name
(real name for admins / self, generic label for non-admins, per the SHOW_ACTIVITY flags).
actorSlot < 0 = server console (always real "Console" label).
CS2 chat color control bytes (values from CounterStrikeSharp's ChatColors enum). Prepend one to a chat
message to color it — CS2 requires a leading control byte for the message to render at all. The plugin
owns color (SourceMod-parity): e.g. Chat.toAll(ChatColors.Green + "[SM] hello").
fn pickPlayer(adminSlot: number, onPicked: (target: Player) => void): void
Show a target-picker Center menu of connected players to adminSlot (the adminmenu framework's shared
player picker; freezePlayer is on). The picked player is re-resolved via Player.fromUserId at select
time, so onPicked only ever receives a live target — a player who left in the meantime is skipped with
a chat notice to adminSlot, and onPicked is not called.
A live CEnvBeam handle. update() moves both endpoints; remove() destroys it.
Draw a point-to-point beam (a CEnvBeam) from start to end. Returns a handle, or null if the entity
couldn't be created. The beam is game-world-owned — call handle.remove() to clean up.
A live read view over CCSGameRules (via the cs_gamerules proxy). Every field is liveness-gated at the
proxy root and reads null if the proxy is gone (e.g. between maps).
readonly timeRemaining: number | null
— roundTime - timeElapsed — real seconds until the engine ends the round (matches the HUD clock).setTimeRemaining(seconds: number): boolean
— Set the REMAINING round time (writes roundTime = timeElapsed + seconds).addTimeRemaining(seconds: number): boolean
— Extend/shrink the round clock by delta seconds (writes roundTime += seconds). Read + drive CCSGameRules state. get() re-finds the cs_gamerules proxy each call (liveness-gated
cache); returns null when no proxy exists (e.g. pre-map-load).
Team scoreboard scores (cs_team_manager entities, CTeam.m_iScore + notifyStateChanged). team is
0..3 (Unassigned/Spectator/T/CT), matched by m_iTeamNum; entities are re-found per call.
CS2 round-end reasons (CCSGameRules::TerminateRound / round_end.reason). Binary-validated against
our build (reason bound = 22; #SFUI_Notice_* switch). Gaps 2/3/15 are removed legacy VIP reasons.
cs_win_panel_round final_event values (validated at the live gate against a natural round end).
Screen-fade user message (CUserMessageFade). duration/holdTime are engine fade units; color is a
packed RGBA fixed32. Returns false if the message/fields don't resolve.
Screen-shake user message (CUserMessageShake). command 0 = start. Returns false if unresolved.
Best-effort hint text (TextMsg-family). Returns false if the message/fields don't resolve.
to(slot: number, text: string): boolean
— Show text as hint text to slot. false if the message/fields don't resolve. A world-space coordinate triple (a corner or center of a TriggerZoneHandle box).
A live runtime trigger_multiple zone (from TriggerZone.create).
Create arbitrary-box touch zones at runtime (a runtime trigger_multiple).
Curated built-in CS2 soundevent names (see
A CS2 weapon entity (CCSWeaponBase). All generated field accessors (clip1, clip2, fallbackPaintKit,
ownerEntity, inherited health/teamNum/...) are read+write; a stale weapon reads null.
Entry point for the Weapon entity object — wrap a raw EntityRef or enumerate weapons
by class name. Prefer Pawn's activeWeapon/weapons/giveNamedItem for owned weapons.
import { Weapon } from "@s2script/cs2";
// `ent` is an EntityRef, e.g. from Entity.onSpawn("weapon_*", …)
const weapon = Weapon.fromEntity(ent);
if (weapon) weapon.setAmmo(90);