Modules

Docs / API / Modules / admin

Admin

Admin & chat

@s2script/sdk/admin

engine-generic admin flag model + cache API. Resolved at runtime via globalThis.__s2pkg_admin; no game-specific symbols. Import: import { ADMFLAG, Admin } from "./admin";

4 exports

Import

import { ADMFLAG } from "@s2script/sdk/admin";

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.

const
ADMFLAG

SourceMod-parity admin flag bitmask constants (SM bit values).

readonly RESERVATION: number
Reserved-slot access (1<<0 = 1).
readonly GENERIC: number
Generic admin — the baseline "is an admin" flag (1<<1 = 2).
readonly KICK: number
May kick players (1<<2 = 4).
readonly BAN: number
May ban players (1<<3 = 8).
readonly UNBAN: number
May remove bans (1<<4 = 16).
readonly SLAY: number
May slay/slap players (1<<5 = 32).
readonly CHANGEMAP: number
May change the map (1<<6 = 64).
readonly CONVARS: number
May change most convars (1<<7 = 128).
readonly CONFIG: number
May execute config files (1<<8 = 256).
readonly CHAT: number
Admin-chat and other special chat privileges (1<<9 = 512).
readonly VOTE: number
May start votes (1<<10 = 1024).
readonly PASSWORD: number
May set the server password (1<<11 = 2048).
readonly RCON: number
May use rcon commands (1<<12 = 4096).
readonly CHEATS: number
May change cheat convars and use cheat commands (1<<13 = 8192).
readonly ROOT: number
Full access — implicitly satisfies every flag (1<<14 = 16384). See AdminInfo.hasFlags.
interface
AdminInfo

An admin entry: their SteamID64, their combined flag mask, and a helper to check flags.

readonly steamId: string
This admin's SteamID64 (decimal string).
readonly flags: number
Combined flag mask (union of file + runtime tiers and group flags) — test against ADMFLAG bits.
readonly immunity: number
Immunity level (0 = none). A lower-immunity admin cannot target a higher one.
readonly groups: readonly string[]
Names of the groups this admin belongs to.
hasFlags(required: number): boolean
True if required flags are all set, OR if this admin has ROOT (root ⇒ all).
interface
AdminGroup

A resolved admin group (from admin_groups.json): its flags, immunity, and per-command overrides.

readonly name: string
The group's name (its key in admin_groups.json).
readonly flags: number
Flag mask granted to every member — ADMFLAG bits.
readonly immunity: number
Immunity level conferred by membership (0 = none).
readonly overrides: Readonly<Record<string, { public: boolean; mask: number }>>
Per-command access overrides, keyed by command name: public opens it to all, mask is the required flags.
const
Admin

The admin API: add/remove runtime admins, look up by SteamID or slot, reload from file.

import { Admin, ADMFLAG } from "@s2script/sdk/admin";
const a = Admin.forSlot(p.slot);
const adminStr = a ? "yes(flags=0x" + a.flags.toString(16) + ")" : "no";
add(steamId: string, flags: number, immunity?: number): void
Add (or overwrite) a runtime admin. Not persisted to admins.json.
remove(steamId: string): void
Remove a runtime admin.
get(steamId: string): AdminInfo | null
Get an admin by SteamID64 (union of file + runtime tiers), or null if not an admin.
forSlot(slot: number): AdminInfo | null
Get an admin by player slot (resolves SteamID via engine), or null.
canTarget(callerSlot: number, targetSlot: number): boolean
True if callerSlot may act on targetSlot (console = infinite; blocked iff target immunity > caller).
getGroup(name: string): AdminGroup | null
A resolved group by name (from admin_groups.json), or null.
reload(): void
Re-read admins.json into the file tier (clears old file-tier entries first).
Back to modules All packages

s2script — Source 2 plugin framework

GitHub