Events

Events

Game events flow through an engine-generic bus (@s2script/events):

import { Events, HookResult } from '@s2script/events';

Events.on('player_spawn', (ev) => {
  const slot = ev.getPlayerSlot('userid');
});

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

GameEvent accessors are synchronous and block-scoped — do not stash ev across await.

CS2 ships a typed catalog overlay so Events.on('player_death', …) constrains field keys. Fire custom events with Events.fire / Events.fireToClient.

See the events module.

s2script — Source 2 plugin framework

GitHub