Modules

Docs / API / Modules / clients

Clients

Players & world

@s2script/sdk/clients

engine-generic client handle + lifecycle events. Resolved at runtime via globalThis.__s2pkg_clients. Import: import { Client, Clients } from "./clients";

Import

import { Client } from "@s2script/sdk/clients";

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.

class
Client

A connected client, identified by its 0-based slot (CPlayerSlot). Slot-backed; getters read live.

readonly slot: number
The client's 0-based engine slot (CPlayerSlot) — the handle's stable identity for its connection.
isValid(): boolean
True while a client occupies this slot.
readonly steamId: string
Decimal SteamID64; "0" for a bot or an unauthenticated client.
readonly name: string
Display name; "" if unavailable.
readonly userId: number
Engine user-id; -1 if none.
readonly signonState: number
Tracked signon state: 0 = none/disconnected, 2 = connected, 5 = spawned, 6 = full (in-game); -1 if the slot is out of range.
readonly isBot: boolean
True for a fake client (bot) — derived from steamId === "0".
kick(reason?: string): void
Disconnect this client.
chat(message: string): void
Send a chat (SayText2) line to this client.
print(message: string): void
Print one line to this client's developer console (skipped for bots).
readonly ip: string
This client's IP address (":port" stripped); "" for a bot.
kickWithReason(reason: string, delaySeconds?: number): void
Show reason (chat + console) once the client is in-game, then kick after delaySeconds (default 5). Intended to be called from a Clients.onConnect handler.
voiceMuted: boolean
Server-side voice mute: while true, this client's OUTGOING voice is silenced for every receiver. Framework state (not an engine field): cleared automatically on disconnect, persists across map changes while connected. If the voice descriptor is degraded (hook/validation failure — named reason in the server log), setting is an inert no-op and reads stay false.
const
Clients

Look up connected clients by slot or enumerate them all.

import { Clients } from "@s2script/sdk/clients";
console.log(`onLoad — all()=${Clients.all().length} clients`);
fromSlot(slot: number): Client | null
The client in slot, or null if the slot is empty.
all(): Client[]
Every currently-connected client (bots included).
Back to modules All packages

s2script — Source 2 plugin framework

GitHub