Commands

Commands

Register console and chat commands through @s2script/commands:

import { Commands } from '@s2script/commands';
import { ADMFLAG } from '@s2script/admin';

Commands.register('hello', (ctx) => {
  ctx.reply(`hi from slot ${ctx.callerSlot}`);
});

Commands.registerAdmin('sm_kick', ADMFLAG.KICK, (ctx) => {
  // …
});
  • register — anyone / console
  • registerServer — server console only (callerSlot < 0)
  • registerAdmin — flag-gated via the host admin cache

ctx is engine-generic (callerSlot, args, argString, reply). Chat ! / / triggers reach the same registry. Player replies are deferred one frame so they land after the chat line (SourceMod parity).

See commands and admin.

s2script — Source 2 plugin framework

GitHub