@s2script/sdk 0.12.0 → 0.13.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/package.json +1 -1
- package/plugin.d.ts +11 -0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s2script/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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
|
@@ -91,6 +91,17 @@ export interface CtxCommands {
|
|
|
91
91
|
registerServer(name: string, handler: (cmd: CommandInvocation) => void): void;
|
|
92
92
|
/** Register an admin command gated by `flags` (an `ADMFLAG` bitmask; fail-safe default-deny). */
|
|
93
93
|
registerAdmin(name: string, flags: number, handler: (cmd: CommandInvocation) => void): void;
|
|
94
|
+
/**
|
|
95
|
+
* Observe an existing CLIENT command by name — SourceMod's `AddCommandListener`.
|
|
96
|
+
*
|
|
97
|
+
* For engine-owned commands (`player_ping`, `jointeam`, `drop`), which {@link register} cannot
|
|
98
|
+
* claim. Observe-by-default: the engine still handles it unless the handler returns
|
|
99
|
+
* `>= HookResult.Handled`. Unsubscribed automatically when the plugin unloads.
|
|
100
|
+
*/
|
|
101
|
+
onClientCommand(
|
|
102
|
+
name: string,
|
|
103
|
+
handler: (slot: number, argString: string) => HookResultValue | void,
|
|
104
|
+
): void;
|
|
94
105
|
}
|
|
95
106
|
/** Config live-reload subscription on this plugin's load-scope ({@link PluginContext.config}). */
|
|
96
107
|
export interface CtxConfig {
|