Search docs
Search modules and symbols
Commands

Commands

Register console and chat commands through ctx.commands:

import { plugin } from '@s2script/sdk/plugin';
import { ADMFLAG } from '@s2script/sdk/admin';

export default plugin((ctx) => {
  ctx.commands.register('hello', (cmd) => {
    cmd.reply(`hi from slot ${cmd.callerSlot}`);
  });

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

The cmd invocation 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 the commands module and admin module.

s2script — Source 2 plugin framework

GitHub