@s2script/sdk 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/events.d.ts +19 -0
  2. package/package.json +1 -1
  3. package/plugin.d.ts +12 -1
package/events.d.ts CHANGED
@@ -55,5 +55,24 @@ export declare const Events: {
55
55
  /** Fire a game event. Returns the engine FireEvent result. */
56
56
  fire(name: string, fields?: Record<string, number | string | boolean | bigint>, dontBroadcast?: boolean): boolean;
57
57
  /** Fire a game event to ONE client (SourceMod FireToClient). Same field type-inference as `fire`. Returns false on miss. */
58
+ /**
59
+ * Restrict the event currently being pre-dispatched to `slots`, instead of hiding it from everyone.
60
+ *
61
+ * Only meaningful from inside an `onPre` handler that ALSO returns `HookResult.Handled`. The pair
62
+ * means "do not broadcast this normally — deliver it to exactly these viewers". An empty array hides
63
+ * it from every client.
64
+ *
65
+ * This exists because CS2 fans a game event out to clients as one message PER CLIENT, so plain
66
+ * suppression is all-or-nothing. Naming recipients keeps every field the engine populated, which
67
+ * re-firing a rebuilt copy per viewer does not.
68
+ *
69
+ * @example
70
+ * ctx.events.onPre("player_death", () => {
71
+ * Events.setRecipients(traitorSlots); // only Traitors see the kill
72
+ * return HookResult.Handled;
73
+ * });
74
+ */
75
+ setRecipients(slots: readonly number[]): void;
76
+
58
77
  fireToClient(slot: number, name: string, fields?: Record<string, string | number | boolean | bigint>): boolean;
59
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s2script/sdk",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "license": "MIT OR Apache-2.0",
5
5
  "description": "s2script SDK — the builtin capability types (imported as @s2script/sdk/entity, …) plus the `s2s` CLI for building Source 2 / CS2 plugins.",
6
6
  "type": "module",
package/plugin.d.ts CHANGED
@@ -77,7 +77,18 @@ export interface CtxEntities {
77
77
  /** Per-frame + map/precache hooks on this plugin's load-scope ({@link PluginContext.server}). */
78
78
  export interface CtxServer {
79
79
  /** Run `fn` every game frame. @param opts - `priority` orders it within the frame (`monitor` runs last, read-only). */
80
- onGameFrame(fn: () => void, opts?: { priority?: "high" | "normal" | "low" | "monitor" }): void;
80
+ /**
81
+ * Run `fn` every game frame.
82
+ *
83
+ * `phase` picks WHERE in the frame it runs and defaults to `"pre"` (before simulation). Use
84
+ * `"post"` when the work must land after the engine's own per-frame writes — re-asserting a netvar
85
+ * the engine re-derives during simulation is overwritten if written in `"pre"`, because the
86
+ * derivation happens after and the outgoing snapshot carries the engine's value.
87
+ */
88
+ onGameFrame(
89
+ fn: () => void,
90
+ opts?: { priority?: "high" | "normal" | "low" | "monitor"; phase?: "pre" | "post" },
91
+ ): void;
81
92
  /** A new map became live; `mapName` is the BSP name. */
82
93
  onMapStart(handler: (mapName: string) => void): void;
83
94
  /** Precache window — register models/sounds to precache for the current map. */