Modules

Docs / API / Modules / bans

Bans

Admin & chat

@s2script/sdk/bans

engine-generic SteamID64 ban store + bans.json persistence. Resolved at runtime via globalThis.__s2pkg_bans; no game-specific symbols. Import: import { Bans } from "./bans"; The store is host-global in core, populated from addons/s2script/configs/bans.json via the config bridge. Enforcement is JS-driven: a ban plugin (e.g. @s2script/basebans) registers a Clients.onConnect handler that looks a connecting SteamID64 up here and, if banned, shows the reason then kicks (Client.kickWithReason) — a banned player is admitted, shown their reason, and kicked, not instant-rejected. A 3rd-party ban system registers its own onConnect against its own store.

3 exports

Import

import { BanInfo } from "@s2script/sdk/bans";

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.

interface
BanInfo

A ban entry's value: expiry + reason. until === 0 = permanent, else unix-second expiry.

until: number
Unix-second expiry, or 0 for a permanent ban.
reason: string
The ban reason (may be empty).
interface
BanEntry

A ban entry as listed by Bans.list(): the SteamID64 plus its value.

steamid: string
The banned SteamID64 (decimal string).
until: number
Unix-second expiry, or 0 for a permanent ban.
reason: string
The ban reason (may be empty).
const
Bans

The ban API: add/remove bans, look up by SteamID64, list, and reload from bans.json.

import { Bans } from "@s2script/sdk/bans";
// Connect-time enforcement inside a Clients.onConnect handler.
const b = Bans.get(c.steamId);
if (b && (b.until === 0 || b.until > Date.now() / 1000)) c.kickWithReason(b.reason);
add(steamId: string, minutes: number, reason?: string): void
Add (or overwrite) a ban and persist it to bans.json. minutes <= 0 = permanent.
remove(steamId: string): boolean
Remove a ban and persist. Returns whether the SteamID64 was banned.
get(steamId: string): BanInfo | null
Get a ban by SteamID64, or null if not banned.
list(): BanEntry[]
List every ban currently in the cache.
reload(): void
Re-read bans.json into the cache (clears the old cache first).
Back to modules All packages

s2script — Source 2 plugin framework

GitHub