@s2script/sdk 0.12.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.
- package/commands.d.ts +19 -0
- package/events.d.ts +19 -0
- package/package.json +1 -1
- package/plugin.d.ts +23 -1
package/commands.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** @s2script/commands — register server commands. NO runtime code (injected at load). */
|
|
2
2
|
|
|
3
|
+
import type { HookResultValue } from "./events";
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Where a command was invoked from — SourceMod's *reply source*. Set by the dispatch path and
|
|
5
7
|
* exposed as {@link CommandInvocation.replySource}; it is what {@link CommandInvocation.reply}
|
|
@@ -112,6 +114,23 @@ export declare const Commands: {
|
|
|
112
114
|
handleChatTrigger(slot: number, message: string): { silent: boolean; ran: boolean } | null;
|
|
113
115
|
/** The trigger characters — SM PublicChatTrigger (`"!"`) / SilentChatTrigger (`"/"`). Mutate to reconfigure. */
|
|
114
116
|
readonly triggers: { public: string; silent: string };
|
|
117
|
+
/**
|
|
118
|
+
* Observe a CLIENT command by name — SourceMod's `AddCommandListener`.
|
|
119
|
+
*
|
|
120
|
+
* Unlike {@link register}, which CREATES a command, this hooks one that already exists — including
|
|
121
|
+
* commands the engine itself owns (`player_ping`, `jointeam`, `drop`, `buy`). Registering a
|
|
122
|
+
* ConCommand of an engine-owned name fails outright ("unable to link multiple ConCommands named
|
|
123
|
+
* X"), so this is the only way to see those.
|
|
124
|
+
*
|
|
125
|
+
* OBSERVE-BY-DEFAULT: the engine still handles the command as normal. Return
|
|
126
|
+
* `>= HookResult.Handled` to suppress its engine-side handling — but note that for a command with
|
|
127
|
+
* a visible effect (a ping marker, a team change) suppressing is usually NOT what you want.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* // Middle-mouse ping opens the shop, and still places the ping.
|
|
131
|
+
* ctx.commands.onClientCommand("player_ping", (slot) => { openShop(slot); });
|
|
132
|
+
*/
|
|
133
|
+
onClientCommand(name: string, handler: (slot: number, argString: string) => HookResultValue | void): void;
|
|
115
134
|
/** Every globally-registered command with its required admin `flags`: `0` = anyone, `-1` = console/server-only,
|
|
116
135
|
* else the `ADMFLAG` bit mask (map bits→names in your plugin). The `sm_help` backend. */
|
|
117
136
|
list(): { name: string; flags: number }[];
|
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.
|
|
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
|
-
|
|
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. */
|
|
@@ -91,6 +102,17 @@ export interface CtxCommands {
|
|
|
91
102
|
registerServer(name: string, handler: (cmd: CommandInvocation) => void): void;
|
|
92
103
|
/** Register an admin command gated by `flags` (an `ADMFLAG` bitmask; fail-safe default-deny). */
|
|
93
104
|
registerAdmin(name: string, flags: number, handler: (cmd: CommandInvocation) => void): void;
|
|
105
|
+
/**
|
|
106
|
+
* Observe an existing CLIENT command by name — SourceMod's `AddCommandListener`.
|
|
107
|
+
*
|
|
108
|
+
* For engine-owned commands (`player_ping`, `jointeam`, `drop`), which {@link register} cannot
|
|
109
|
+
* claim. Observe-by-default: the engine still handles it unless the handler returns
|
|
110
|
+
* `>= HookResult.Handled`. Unsubscribed automatically when the plugin unloads.
|
|
111
|
+
*/
|
|
112
|
+
onClientCommand(
|
|
113
|
+
name: string,
|
|
114
|
+
handler: (slot: number, argString: string) => HookResultValue | void,
|
|
115
|
+
): void;
|
|
94
116
|
}
|
|
95
117
|
/** Config live-reload subscription on this plugin's load-scope ({@link PluginContext.config}). */
|
|
96
118
|
export interface CtxConfig {
|