Search docs
Search modules and symbols
Events

Events

Subscribe to game events on your plugin’s load-scope through ctx.events:

import { plugin } from '@s2script/sdk/plugin';
import { HookResult } from '@s2script/sdk/events';

export default plugin((ctx) => {
  ctx.events.on('player_spawn', (ev) => {
    const slot = ev.getPlayerSlot('userid');
  });

  ctx.events.onPre('round_start', (ev) => {
    ev.setInt('timelimit', 4242);
    return HookResult.Handled; // suppress the client broadcast
  });
});

The GameEvent accessors are synchronous and block-scoped — do not stash ev across await; a stashed event reads defaults.

CS2 ships a typed catalog overlay (272 events) so ctx.events.on('player_death', …) constrains the field keys. Fire custom events with the free Events.fire / Events.fireToClient from @s2script/sdk/events.

See the events module.

s2script — Source 2 plugin framework

GitHub