gtac-types 0.0.1
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/LICENSE +201 -0
- package/README.md +435 -0
- package/bin/gtac.js +35 -0
- package/index.js +6 -0
- package/lib/build.js +186 -0
- package/package.json +51 -0
- package/src/index.d.ts +22 -0
- package/src/runtime/shared/constants.ts +146 -0
- package/src/runtime/shared/utils.ts +26 -0
- package/src/types/client/animations.d.ts +902 -0
- package/src/types/client/events.d.ts +809 -0
- package/src/types/client/functions.d.ts +715 -0
- package/src/types/client/gta.d.ts +724 -0
- package/src/types/client/natives.d.ts +1091 -0
- package/src/types/element.d.ts +853 -0
- package/src/types/event.d.ts +100 -0
- package/src/types/misc.d.ts +256 -0
- package/src/types/resource.d.ts +252 -0
- package/src/types/server/client.d.ts +144 -0
- package/src/types/server/events.d.ts +407 -0
- package/src/types/server/functions.d.ts +890 -0
- package/src/types/vec.d.ts +594 -0
- package/src/types/xml.d.ts +232 -0
- package/templates/meta.xml +4 -0
- package/templates/tsconfig.json +12 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GTAC Client Connection Type (Server-Side)
|
|
3
|
+
*
|
|
4
|
+
* Defines the `Client` interface used server-side to represent a connected
|
|
5
|
+
* player's network session. Each connected player has a `Client` object
|
|
6
|
+
* with properties for identification (name, IP, ping, game version),
|
|
7
|
+
* permissions (admin, console access), and methods for data storage,
|
|
8
|
+
* player management, and disconnection.
|
|
9
|
+
*
|
|
10
|
+
* All declarations are global — no import required.
|
|
11
|
+
*
|
|
12
|
+
* @module types/server/client
|
|
13
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Handle a new player connecting
|
|
17
|
+
* addEventHandler("OnPlayerConnect", function(client) {
|
|
18
|
+
* console.log(client.name + " connected from " + client.ip);
|
|
19
|
+
* client.setData("joinTime", Date.now());
|
|
20
|
+
* });
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Represents a network client connection (a connected player).
|
|
25
|
+
*
|
|
26
|
+
* The `Client` interface provides access to connection metadata (IP, ping,
|
|
27
|
+
* game version), permissions (admin, console), and associated player element.
|
|
28
|
+
* Custom data can be stored on the client using `setData()`/`getData()`,
|
|
29
|
+
* which persists for the lifetime of the connection.
|
|
30
|
+
*
|
|
31
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
32
|
+
*/
|
|
33
|
+
interface Client {
|
|
34
|
+
/**
|
|
35
|
+
* Whether this client has server administrator privileges.
|
|
36
|
+
* Admin clients can execute server commands and have elevated permissions.
|
|
37
|
+
*/
|
|
38
|
+
administrator: boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Whether this client has access to the server console.
|
|
42
|
+
* Console access allows viewing logs and running console commands.
|
|
43
|
+
*/
|
|
44
|
+
console: boolean;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Game identifier string indicating which game the client connected with.
|
|
48
|
+
* Example values: `"gta:vc"`, `"gta:iii"`, `"gta:sa"`.
|
|
49
|
+
*/
|
|
50
|
+
game: string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Full game version string reported by the client (e.g. `"1.0.0"`).
|
|
54
|
+
*/
|
|
55
|
+
gameVersion: string;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Numeric client index assigned by the server.
|
|
59
|
+
* Unique identifier for this connection within the current server instance.
|
|
60
|
+
*/
|
|
61
|
+
index: number;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Client's IP address as a string (e.g. `"192.168.1.100"`).
|
|
65
|
+
*/
|
|
66
|
+
ip: string;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Client's display name.
|
|
70
|
+
* This is the name shown in chat and player lists.
|
|
71
|
+
*/
|
|
72
|
+
name: string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Client's current network latency/ping in milliseconds.
|
|
76
|
+
* Higher values indicate a slower connection.
|
|
77
|
+
*/
|
|
78
|
+
ping: number;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The `Player` element associated with this client, or `null` if the
|
|
82
|
+
* client has not yet spawned a player character.
|
|
83
|
+
*/
|
|
84
|
+
player: Player | null;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The camera interior ID for this client's view.
|
|
88
|
+
* 0 = exterior/world, other values = specific interiors.
|
|
89
|
+
*/
|
|
90
|
+
cameraInterior: number;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Retrieves a custom data value previously stored on this client.
|
|
94
|
+
* Data is dynamically typed (SpiderMonkey engine) and persists until
|
|
95
|
+
* the client disconnects or the key is removed.
|
|
96
|
+
*
|
|
97
|
+
* @param key - The string key identifying the stored data.
|
|
98
|
+
* @returns The stored value, or `undefined` if no data exists for the key.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* const joinTime = client.getData("joinTime");
|
|
102
|
+
* console.log("Player joined at: " + new Date(joinTime));
|
|
103
|
+
*/
|
|
104
|
+
getData(key: string): any;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Stores a custom data value on this client.
|
|
108
|
+
* The data persists until removed or until the client disconnects.
|
|
109
|
+
*
|
|
110
|
+
* @param key - The string key to store the data under.
|
|
111
|
+
* @param value - Any value to store (number, string, object, array, etc.).
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* client.setData("score", 100);
|
|
115
|
+
* client.setData("lastAction", "jump");
|
|
116
|
+
*/
|
|
117
|
+
setData(key: string, value: any): void;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Removes a custom data key and its associated value from this client.
|
|
121
|
+
*
|
|
122
|
+
* @param key - The string key to remove.
|
|
123
|
+
*/
|
|
124
|
+
removeData(key: string): void;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Despawns the client's player, removing them from the world visually
|
|
128
|
+
* but keeping the connection alive. The player can be respawned later.
|
|
129
|
+
*/
|
|
130
|
+
despawnPlayer(): void;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Disconnects the client from the server.
|
|
134
|
+
* The connection is terminated and the player element is destroyed.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* // Kick an abusive player
|
|
138
|
+
* if (isAbusive(client)) {
|
|
139
|
+
* messageClient("You have been kicked.", client, COLOUR_RED);
|
|
140
|
+
* client.disconnect();
|
|
141
|
+
* }
|
|
142
|
+
*/
|
|
143
|
+
disconnect(): void;
|
|
144
|
+
}
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GTAC Server-Side Event Handler Declarations
|
|
3
|
+
*
|
|
4
|
+
* Defines typed overloads for `addEventHandler()` for all server-side events
|
|
5
|
+
* dispatched by the GTA Connected server engine. Each overload specifies the
|
|
6
|
+
* exact handler signature for a given event name, providing type safety and
|
|
7
|
+
* auto-completion for server event-driven code.
|
|
8
|
+
*
|
|
9
|
+
* Events cover: element lifecycle (destroy, stream in/out), ped actions
|
|
10
|
+
* (crouch, uncrouch, enter/exit vehicle, fall, jump, spawn, wasted),
|
|
11
|
+
* pickup collection, player chat/commands, client connection lifecycle
|
|
12
|
+
* (connect, join, joined, quit), server ticks (OnProcess), resource
|
|
13
|
+
* lifecycle (start, stop), server startup, and deprecated IV-only events.
|
|
14
|
+
* Generic fallback overloads handle custom/unknown events.
|
|
15
|
+
*
|
|
16
|
+
* All declarations are global — no import required.
|
|
17
|
+
*
|
|
18
|
+
* @module types/server/events
|
|
19
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Handle player chat messages
|
|
23
|
+
* addEventHandler("OnPlayerChat", function(client, text) {
|
|
24
|
+
* console.log(client.name + ": " + text);
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Run code every server tick
|
|
29
|
+
* addEventHandler("OnProcess", function() {
|
|
30
|
+
* // Update game state...
|
|
31
|
+
* });
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
// ===== Element Events =====
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Fired when any element is destroyed on the server.
|
|
38
|
+
* Use this to clean up associated data or trigger effects.
|
|
39
|
+
*
|
|
40
|
+
* @param name - `"OnElementDestroy"`
|
|
41
|
+
* @param handler - Callback receiving the destroyed `Element`.
|
|
42
|
+
*/
|
|
43
|
+
declare function addEventHandler(
|
|
44
|
+
name: "OnElementDestroy",
|
|
45
|
+
handler: (element: Element) => void
|
|
46
|
+
): void;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Fired when an element streams in for a specific client.
|
|
50
|
+
* Use this to send client-specific data or trigger effects when
|
|
51
|
+
* an element becomes visible to a player.
|
|
52
|
+
*
|
|
53
|
+
* @param name - `"OnElementStreamIn"`
|
|
54
|
+
* @param handler - Callback receiving the streamed-in `Element`.
|
|
55
|
+
*/
|
|
56
|
+
declare function addEventHandler(
|
|
57
|
+
name: "OnElementStreamIn",
|
|
58
|
+
handler: (element: Element) => void
|
|
59
|
+
): void;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Fired when an element streams out for a specific client.
|
|
63
|
+
* Use this to clean up client-specific state when an element is
|
|
64
|
+
* no longer relevant to a player.
|
|
65
|
+
*
|
|
66
|
+
* @param name - `"OnElementStreamOut"`
|
|
67
|
+
* @param handler - Callback receiving the streamed-out `Element`.
|
|
68
|
+
*/
|
|
69
|
+
declare function addEventHandler(
|
|
70
|
+
name: "OnElementStreamOut",
|
|
71
|
+
handler: (element: Element) => void
|
|
72
|
+
): void;
|
|
73
|
+
|
|
74
|
+
// ===== Ped Events =====
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Fired when a ped crouches.
|
|
78
|
+
*
|
|
79
|
+
* @param name - `"OnPedCrouch"`
|
|
80
|
+
* @param handler - Callback receiving the `Ped` that crouched.
|
|
81
|
+
*/
|
|
82
|
+
declare function addEventHandler(
|
|
83
|
+
name: "OnPedCrouch",
|
|
84
|
+
handler: (ped: Ped) => void
|
|
85
|
+
): void;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Fired when a ped starts entering a vehicle (opening door, climbing in).
|
|
89
|
+
*
|
|
90
|
+
* @param name - `"OnPedEnterVehicle"`
|
|
91
|
+
* @param handler - Callback receiving the `Ped`, the `Vehicle`, and the target seat number.
|
|
92
|
+
*/
|
|
93
|
+
declare function addEventHandler(
|
|
94
|
+
name: "OnPedEnterVehicle",
|
|
95
|
+
handler: (ped: Ped, vehicle: Vehicle, seat: number) => void
|
|
96
|
+
): void;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Fired when a ped starts exiting a vehicle.
|
|
100
|
+
*
|
|
101
|
+
* @param name - `"OnPedExitVehicle"`
|
|
102
|
+
* @param handler - Callback receiving the `Ped` and the `Vehicle` being exited.
|
|
103
|
+
*/
|
|
104
|
+
declare function addEventHandler(
|
|
105
|
+
name: "OnPedExitVehicle",
|
|
106
|
+
handler: (ped: Ped, vehicle: Vehicle) => void
|
|
107
|
+
): void;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Fired when a ped falls (loses footing and hits the ground).
|
|
111
|
+
*
|
|
112
|
+
* @param name - `"OnPedFall"`
|
|
113
|
+
* @param handler - Callback receiving the fallen `Ped`.
|
|
114
|
+
*/
|
|
115
|
+
declare function addEventHandler(
|
|
116
|
+
name: "OnPedFall",
|
|
117
|
+
handler: (ped: Ped) => void
|
|
118
|
+
): void;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Fired when a ped jumps.
|
|
122
|
+
*
|
|
123
|
+
* @param name - `"OnPedJump"`
|
|
124
|
+
* @param handler - Callback receiving the jumping `Ped`.
|
|
125
|
+
*/
|
|
126
|
+
declare function addEventHandler(
|
|
127
|
+
name: "OnPedJump",
|
|
128
|
+
handler: (ped: Ped) => void
|
|
129
|
+
): void;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Fired when a ped spawns in the game world.
|
|
133
|
+
*
|
|
134
|
+
* @param name - `"OnPedSpawn"`
|
|
135
|
+
* @param handler - Callback receiving the spawned `Ped`.
|
|
136
|
+
*/
|
|
137
|
+
declare function addEventHandler(
|
|
138
|
+
name: "OnPedSpawn",
|
|
139
|
+
handler: (ped: Ped) => void
|
|
140
|
+
): void;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Fired when a ped uncrouches (stands back up).
|
|
144
|
+
*
|
|
145
|
+
* @param name - `"OnPedUncrouch"`
|
|
146
|
+
* @param handler - Callback receiving the `Ped` that uncrouched.
|
|
147
|
+
*/
|
|
148
|
+
declare function addEventHandler(
|
|
149
|
+
name: "OnPedUncrouch",
|
|
150
|
+
handler: (ped: Ped) => void
|
|
151
|
+
): void;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Fired when a ped is wasted (killed, reaches 0 health).
|
|
155
|
+
*
|
|
156
|
+
* @param name - `"OnPedWasted"`
|
|
157
|
+
* @param handler - Callback receiving the wasted `Ped`.
|
|
158
|
+
*/
|
|
159
|
+
declare function addEventHandler(
|
|
160
|
+
name: "OnPedWasted",
|
|
161
|
+
handler: (ped: Ped) => void
|
|
162
|
+
): void;
|
|
163
|
+
|
|
164
|
+
// ===== Pickup Events =====
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Fired when a pickup is collected by a player.
|
|
168
|
+
*
|
|
169
|
+
* @param name - `"OnPickupCollected"`
|
|
170
|
+
* @param handler - Callback receiving the collected `Pickup` and the `Player` who collected it.
|
|
171
|
+
*/
|
|
172
|
+
declare function addEventHandler(
|
|
173
|
+
name: "OnPickupCollected",
|
|
174
|
+
handler: (pickup: Pickup, player: Player) => void
|
|
175
|
+
): void;
|
|
176
|
+
|
|
177
|
+
// ===== Player Events =====
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Fired when a player sends a chat message.
|
|
181
|
+
*
|
|
182
|
+
* @param name - `"OnPlayerChat"`
|
|
183
|
+
* @param handler - Callback receiving the sending `Client` and the chat text string.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* addEventHandler("OnPlayerChat", function(client, text) {
|
|
187
|
+
* message(client.name + ": " + text);
|
|
188
|
+
* });
|
|
189
|
+
*/
|
|
190
|
+
declare function addEventHandler(
|
|
191
|
+
name: "OnPlayerChat",
|
|
192
|
+
handler: (client: Client, text: string) => void
|
|
193
|
+
): void;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Fired when a player sends a command (e.g. /help, /kill).
|
|
197
|
+
* Note: use `addCommandHandler()` for a more convenient command API.
|
|
198
|
+
*
|
|
199
|
+
* @param name - `"OnPlayerCommand"`
|
|
200
|
+
* @param handler - Callback receiving the `Client`, the command name, and arguments string.
|
|
201
|
+
*/
|
|
202
|
+
declare function addEventHandler(
|
|
203
|
+
name: "OnPlayerCommand",
|
|
204
|
+
handler: (client: Client, cmd: string, args: string) => void
|
|
205
|
+
): void;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Fired when a client establishes a connection to the server (before joining).
|
|
209
|
+
* Use this for authentication or pre-join checks.
|
|
210
|
+
*
|
|
211
|
+
* @param name - `"OnPlayerConnect"`
|
|
212
|
+
* @param handler - Callback receiving the connecting `Client`.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* addEventHandler("OnPlayerConnect", function(client) {
|
|
216
|
+
* console.log(client.name + " is connecting...");
|
|
217
|
+
* client.setData("connectTime", Date.now());
|
|
218
|
+
* });
|
|
219
|
+
*/
|
|
220
|
+
declare function addEventHandler(
|
|
221
|
+
name: "OnPlayerConnect",
|
|
222
|
+
handler: (client: Client) => void
|
|
223
|
+
): void;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Fired when a client has completed the join process and is fully in-game.
|
|
227
|
+
* This is the standard event for initializing a player's state.
|
|
228
|
+
*
|
|
229
|
+
* @param name - `"OnPlayerJoin"`
|
|
230
|
+
* @param handler - Callback receiving the joined `Client`.
|
|
231
|
+
*/
|
|
232
|
+
declare function addEventHandler(
|
|
233
|
+
name: "OnPlayerJoin",
|
|
234
|
+
handler: (client: Client) => void
|
|
235
|
+
): void;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Fired when a client has joined. Similar to `OnPlayerJoin` but the handler
|
|
239
|
+
* also receives the event name as the first argument.
|
|
240
|
+
*
|
|
241
|
+
* @param name - `"OnPlayerJoined"`
|
|
242
|
+
* @param handler - Callback receiving the event name string and the `Client`.
|
|
243
|
+
*/
|
|
244
|
+
declare function addEventHandler(
|
|
245
|
+
name: "OnPlayerJoined",
|
|
246
|
+
handler: (event: string, client: Client) => void
|
|
247
|
+
): void;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Fired when a player quits or disconnects from the server.
|
|
251
|
+
* Use this to clean up the player's state, save data, and broadcast departure.
|
|
252
|
+
*
|
|
253
|
+
* @param name - `"OnPlayerQuit"`
|
|
254
|
+
* @param handler - Callback receiving the event name and the `Client` who quit.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* addEventHandler("OnPlayerQuit", function(event, client) {
|
|
258
|
+
* message(client.name + " has left the server.");
|
|
259
|
+
* });
|
|
260
|
+
*/
|
|
261
|
+
declare function addEventHandler(
|
|
262
|
+
name: "OnPlayerQuit",
|
|
263
|
+
handler: (event: string, client: Client) => void
|
|
264
|
+
): void;
|
|
265
|
+
|
|
266
|
+
// ===== Process Event =====
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Fired every server tick (frame). This is the main server update loop.
|
|
270
|
+
* Use this for continuous game logic: AI updates, position checks, timer logic.
|
|
271
|
+
* Be mindful of performance — avoid heavy operations in the OnProcess handler.
|
|
272
|
+
*
|
|
273
|
+
* @param name - `"OnProcess"`
|
|
274
|
+
* @param handler - Callback with no arguments.
|
|
275
|
+
*/
|
|
276
|
+
declare function addEventHandler(
|
|
277
|
+
name: "OnProcess",
|
|
278
|
+
handler: () => void
|
|
279
|
+
): void;
|
|
280
|
+
|
|
281
|
+
// ===== Resource Events =====
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Fired when a resource starts running.
|
|
285
|
+
* This includes the current resource when the server starts.
|
|
286
|
+
*
|
|
287
|
+
* @param name - `"OnResourceStart"`
|
|
288
|
+
* @param handler - Callback receiving the started `Resource`.
|
|
289
|
+
*/
|
|
290
|
+
declare function addEventHandler(
|
|
291
|
+
name: "OnResourceStart",
|
|
292
|
+
handler: (resource: Resource) => void
|
|
293
|
+
): void;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Fired when a resource stops running.
|
|
297
|
+
* Use this to clean up any elements or state created by the resource.
|
|
298
|
+
*
|
|
299
|
+
* @param name - `"OnResourceStop"`
|
|
300
|
+
* @param handler - Callback receiving the stopped `Resource`.
|
|
301
|
+
*/
|
|
302
|
+
declare function addEventHandler(
|
|
303
|
+
name: "OnResourceStop",
|
|
304
|
+
handler: (resource: Resource) => void
|
|
305
|
+
): void;
|
|
306
|
+
|
|
307
|
+
// ===== Server Event =====
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Fired when the server starts up.
|
|
311
|
+
* Use this to initialize global state, load configuration, and start
|
|
312
|
+
* background processes.
|
|
313
|
+
*
|
|
314
|
+
* @param name - `"OnServerStart"`
|
|
315
|
+
* @param handler - Callback with no arguments.
|
|
316
|
+
*/
|
|
317
|
+
declare function addEventHandler(
|
|
318
|
+
name: "OnServerStart",
|
|
319
|
+
handler: () => void
|
|
320
|
+
): void;
|
|
321
|
+
|
|
322
|
+
// ===== Deprecated IV Events =====
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* **Deprecated:** GTA IV only! Fired when an IV network event is added.
|
|
326
|
+
* Not usable with GTA Vice City.
|
|
327
|
+
*
|
|
328
|
+
* @param name - `"OnAddIVNetworkEvent"`
|
|
329
|
+
* @param handler - Callback receiving variadic arguments.
|
|
330
|
+
* @deprecated This event is for GTA IV only and has no effect in GTA VC.
|
|
331
|
+
*/
|
|
332
|
+
declare function addEventHandler(
|
|
333
|
+
name: "OnAddIVNetworkEvent",
|
|
334
|
+
handler: (...args: any[]) => void
|
|
335
|
+
): void;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* **Deprecated:** GTA IV only! Fired on a session request.
|
|
339
|
+
* Not usable with GTA Vice City.
|
|
340
|
+
*
|
|
341
|
+
* @param name - `"OnRequestSession"`
|
|
342
|
+
* @param handler - Callback receiving variadic arguments.
|
|
343
|
+
* @deprecated This event is for GTA IV only and has no effect in GTA VC.
|
|
344
|
+
*/
|
|
345
|
+
declare function addEventHandler(
|
|
346
|
+
name: "OnRequestSession",
|
|
347
|
+
handler: (...args: any[]) => void
|
|
348
|
+
): void;
|
|
349
|
+
|
|
350
|
+
// ===== Generic Fallbacks =====
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Generic fallback: Registers a handler for any named server-side event
|
|
354
|
+
* where the handler receives the event name and a client as arguments.
|
|
355
|
+
*
|
|
356
|
+
* @param name - The event name.
|
|
357
|
+
* @param handler - Callback receiving the event name string and `Client`.
|
|
358
|
+
*/
|
|
359
|
+
declare function addEventHandler(
|
|
360
|
+
name: string,
|
|
361
|
+
handler: (event: string, client: Client) => void
|
|
362
|
+
): void;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Fully generic fallback: Registers a handler for any named server-side event
|
|
366
|
+
* with any number of variadic arguments.
|
|
367
|
+
*
|
|
368
|
+
* @param name - The event name.
|
|
369
|
+
* @param handler - Callback receiving any number and type of arguments.
|
|
370
|
+
*/
|
|
371
|
+
declare function addEventHandler(
|
|
372
|
+
name: string,
|
|
373
|
+
handler: (...args: any[]) => void
|
|
374
|
+
): void;
|
|
375
|
+
|
|
376
|
+
// ===== Event Unregistration =====
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Removes a previously registered event handler.
|
|
380
|
+
*
|
|
381
|
+
* @param name - The event name to stop listening to.
|
|
382
|
+
* @param handler - The exact handler function reference that was registered.
|
|
383
|
+
* Must be the same function object, not a copy or new closure.
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* function onPlayerChat(client, text) { ... }
|
|
387
|
+
* addEventHandler("OnPlayerChat", onPlayerChat);
|
|
388
|
+
* // Later:
|
|
389
|
+
* removeEventHandler("OnPlayerChat", onPlayerChat);
|
|
390
|
+
*/
|
|
391
|
+
declare function removeEventHandler(
|
|
392
|
+
name: string,
|
|
393
|
+
handler: (...args: any[]) => void
|
|
394
|
+
): void;
|
|
395
|
+
|
|
396
|
+
// ===== Network Event Unregistration =====
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Removes a previously registered network event handler.
|
|
400
|
+
*
|
|
401
|
+
* @param name - The network event name.
|
|
402
|
+
* @param handler - The handler function to remove (must be the same reference).
|
|
403
|
+
*/
|
|
404
|
+
declare function removeNetworkHandler(
|
|
405
|
+
name: string,
|
|
406
|
+
handler: (...args: any[]) => void
|
|
407
|
+
): void;
|