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,809 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GTAC Client-Specific Event Handler Declarations
|
|
3
|
+
*
|
|
4
|
+
* Defines typed overloads for `addEventHandler()`, `removeEventHandler()`, and
|
|
5
|
+
* `bindEventHandler()` for all client-side events dispatched by the GTA Connected
|
|
6
|
+
* engine. Each overload specifies the exact handler signature for a given event
|
|
7
|
+
* name, providing type safety and auto-completion for event-driven code.
|
|
8
|
+
*
|
|
9
|
+
* Events cover: camera processing, input (keyboard/mouse/cursor), element
|
|
10
|
+
* lifecycle (stream in/out, destroy), entity processing, GUI interactions,
|
|
11
|
+
* HUD rendering, ped actions (enter/exit vehicle, jump, crouch, weapon, death),
|
|
12
|
+
* pickup collection, vehicle explosions, resource lifecycle, and generic fallbacks.
|
|
13
|
+
*
|
|
14
|
+
* All declarations are global — no import required.
|
|
15
|
+
*
|
|
16
|
+
* @module types/client/events
|
|
17
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Listen for player key presses
|
|
21
|
+
* addEventHandler("OnKeyDown", function(key: number) {
|
|
22
|
+
* console.log("Key pressed: " + key);
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Listen for ped entering a vehicle and check which seat
|
|
27
|
+
* addEventHandler("OnPedEnteredVehicle", function(ped, vehicle, seat) {
|
|
28
|
+
* if (seat === 0) {
|
|
29
|
+
* message(ped.name + " is now driving " + vehicle.name);
|
|
30
|
+
* }
|
|
31
|
+
* });
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
// ===== Camera Events =====
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Fired before the camera is processed each frame.
|
|
38
|
+
* Use this to override or adjust camera logic before the engine updates it.
|
|
39
|
+
*
|
|
40
|
+
* @param name - `"OnBeforeProcessCamera"`
|
|
41
|
+
* @param handler - Callback with no arguments.
|
|
42
|
+
*/
|
|
43
|
+
declare function addEventHandler(
|
|
44
|
+
name: "OnBeforeProcessCamera",
|
|
45
|
+
handler: () => void
|
|
46
|
+
): void;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Fired each frame when the camera is processed.
|
|
50
|
+
* Use this to apply custom camera transformations.
|
|
51
|
+
*
|
|
52
|
+
* @param name - `"OnCameraProcess"`
|
|
53
|
+
* @param handler - Callback with no arguments.
|
|
54
|
+
*/
|
|
55
|
+
declare function addEventHandler(
|
|
56
|
+
name: "OnCameraProcess",
|
|
57
|
+
handler: () => void
|
|
58
|
+
): void;
|
|
59
|
+
|
|
60
|
+
// ===== Chat Events =====
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Fired when a chat message is output to the chat window.
|
|
64
|
+
* Allows interception and modification of chat text before display.
|
|
65
|
+
*
|
|
66
|
+
* @param name - `"OnChatOutput"`
|
|
67
|
+
* @param handler - Callback receiving the chat text string.
|
|
68
|
+
*/
|
|
69
|
+
declare function addEventHandler(
|
|
70
|
+
name: "OnChatOutput",
|
|
71
|
+
handler: (text: string) => void
|
|
72
|
+
): void;
|
|
73
|
+
|
|
74
|
+
// ===== Cursor Events =====
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Fired when a mouse button is pressed down while the cursor is visible.
|
|
78
|
+
*
|
|
79
|
+
* @param name - `"OnCursorDown"`
|
|
80
|
+
* @param handler - Callback receiving the cursor (x, y) screen coordinates.
|
|
81
|
+
*/
|
|
82
|
+
declare function addEventHandler(
|
|
83
|
+
name: "OnCursorDown",
|
|
84
|
+
handler: (x: number, y: number) => void
|
|
85
|
+
): void;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Fired continuously when the cursor moves across the screen.
|
|
89
|
+
*
|
|
90
|
+
* @param name - `"OnCursorMove"`
|
|
91
|
+
* @param handler - Callback receiving the cursor (x, y) screen coordinates.
|
|
92
|
+
*/
|
|
93
|
+
declare function addEventHandler(
|
|
94
|
+
name: "OnCursorMove",
|
|
95
|
+
handler: (x: number, y: number) => void
|
|
96
|
+
): void;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Fired when a mouse button is released while the cursor is visible.
|
|
100
|
+
*
|
|
101
|
+
* @param name - `"OnCursorUp"`
|
|
102
|
+
* @param handler - Callback receiving the cursor (x, y) screen coordinates.
|
|
103
|
+
*/
|
|
104
|
+
declare function addEventHandler(
|
|
105
|
+
name: "OnCursorUp",
|
|
106
|
+
handler: (x: number, y: number) => void
|
|
107
|
+
): void;
|
|
108
|
+
|
|
109
|
+
// ===== Element Events =====
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Fired when any element is destroyed.
|
|
113
|
+
* Use this to clean up references or trigger effects when elements disappear.
|
|
114
|
+
*
|
|
115
|
+
* @param name - `"OnElementDestroy"`
|
|
116
|
+
* @param handler - Callback receiving the destroyed `Element`.
|
|
117
|
+
*/
|
|
118
|
+
declare function addEventHandler(
|
|
119
|
+
name: "OnElementDestroy",
|
|
120
|
+
handler: (element: Element) => void
|
|
121
|
+
): void;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Fired when an element streams in (becomes visible/active) for the local client.
|
|
125
|
+
*
|
|
126
|
+
* @param name - `"OnElementStreamIn"`
|
|
127
|
+
* @param handler - Callback receiving the streamed-in `Element`.
|
|
128
|
+
*/
|
|
129
|
+
declare function addEventHandler(
|
|
130
|
+
name: "OnElementStreamIn",
|
|
131
|
+
handler: (element: Element) => void
|
|
132
|
+
): void;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Fired when an element streams out (unloads from memory) for the local client.
|
|
136
|
+
*
|
|
137
|
+
* @param name - `"OnElementStreamOut"`
|
|
138
|
+
* @param handler - Callback receiving the streamed-out `Element`.
|
|
139
|
+
*/
|
|
140
|
+
declare function addEventHandler(
|
|
141
|
+
name: "OnElementStreamOut",
|
|
142
|
+
handler: (element: Element) => void
|
|
143
|
+
): void;
|
|
144
|
+
|
|
145
|
+
// ===== Entity Events =====
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Fired each frame for every `Entity` being processed.
|
|
149
|
+
* Use for per-entity custom logic (but be mindful of performance with many entities).
|
|
150
|
+
*
|
|
151
|
+
* @param name - `"OnEntityProcess"`
|
|
152
|
+
* @param handler - Callback receiving the `Entity` being processed.
|
|
153
|
+
*/
|
|
154
|
+
declare function addEventHandler(
|
|
155
|
+
name: "OnEntityProcess",
|
|
156
|
+
handler: (entity: Entity) => void
|
|
157
|
+
): void;
|
|
158
|
+
|
|
159
|
+
// ===== Focus Events =====
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Fired when the game window gains focus (user clicks on it or alt-tabs back).
|
|
163
|
+
*
|
|
164
|
+
* @param name - `"OnFocus"`
|
|
165
|
+
* @param handler - Callback with no arguments.
|
|
166
|
+
*/
|
|
167
|
+
declare function addEventHandler(
|
|
168
|
+
name: "OnFocus",
|
|
169
|
+
handler: () => void
|
|
170
|
+
): void;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Fired when the game window loses focus (user alt-tabs away or clicks outside).
|
|
174
|
+
*
|
|
175
|
+
* @param name - `"OnLostFocus"`
|
|
176
|
+
* @param handler - Callback with no arguments.
|
|
177
|
+
*/
|
|
178
|
+
declare function addEventHandler(
|
|
179
|
+
name: "OnLostFocus",
|
|
180
|
+
handler: () => void
|
|
181
|
+
): void;
|
|
182
|
+
|
|
183
|
+
// ===== GUI Events =====
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Fired when an anchor (`<a>`) element in a GUI HTML view is clicked.
|
|
187
|
+
*
|
|
188
|
+
* @param name - `"OnGUIAnchorClick"`
|
|
189
|
+
* @param handler - Callback receiving the `GUIElement` that was clicked.
|
|
190
|
+
*/
|
|
191
|
+
declare function addEventHandler(
|
|
192
|
+
name: "OnGUIAnchorClick",
|
|
193
|
+
handler: (element: GUIElement) => void
|
|
194
|
+
): void;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Fired when any GUI element is clicked.
|
|
198
|
+
*
|
|
199
|
+
* @param name - `"OnGUIClick"`
|
|
200
|
+
* @param handler - Callback receiving the `GUIElement` that was clicked.
|
|
201
|
+
*/
|
|
202
|
+
declare function addEventHandler(
|
|
203
|
+
name: "OnGUIClick",
|
|
204
|
+
handler: (element: GUIElement) => void
|
|
205
|
+
): void;
|
|
206
|
+
|
|
207
|
+
// ===== HUD Events =====
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Fired before the game HUD (radar, health bar, ammo, etc.) is drawn.
|
|
211
|
+
* Use this to hide or modify HUD elements before they render.
|
|
212
|
+
*
|
|
213
|
+
* @param name - `"OnBeforeDrawHUD"`
|
|
214
|
+
* @param handler - Callback with no arguments.
|
|
215
|
+
*/
|
|
216
|
+
declare function addEventHandler(
|
|
217
|
+
name: "OnBeforeDrawHUD",
|
|
218
|
+
handler: () => void
|
|
219
|
+
): void;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Fired while the game HUD is being drawn.
|
|
223
|
+
* Use this to overlay custom graphics on top of the standard HUD.
|
|
224
|
+
*
|
|
225
|
+
* @param name - `"OnDrawHUD"`
|
|
226
|
+
* @param handler - Callback with no arguments.
|
|
227
|
+
*/
|
|
228
|
+
declare function addEventHandler(
|
|
229
|
+
name: "OnDrawHUD",
|
|
230
|
+
handler: () => void
|
|
231
|
+
): void;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Fired after the game HUD has finished drawing.
|
|
235
|
+
* Use this for post-HUD effects or cleanup.
|
|
236
|
+
*
|
|
237
|
+
* @param name - `"OnDrawnHUD"`
|
|
238
|
+
* @param handler - Callback with no arguments.
|
|
239
|
+
*/
|
|
240
|
+
declare function addEventHandler(
|
|
241
|
+
name: "OnDrawnHUD",
|
|
242
|
+
handler: () => void
|
|
243
|
+
): void;
|
|
244
|
+
|
|
245
|
+
// ===== Character Input Events =====
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Fired when a character is typed (text input, not bound keys).
|
|
249
|
+
*
|
|
250
|
+
* @param name - `"OnCharacter"`
|
|
251
|
+
* @param handler - Callback receiving the typed character as a string.
|
|
252
|
+
*/
|
|
253
|
+
declare function addEventHandler(
|
|
254
|
+
name: "OnCharacter",
|
|
255
|
+
handler: (char: string) => void
|
|
256
|
+
): void;
|
|
257
|
+
|
|
258
|
+
// ===== Keyboard Events =====
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Fired when a key is pressed down.
|
|
262
|
+
*
|
|
263
|
+
* @param name - `"OnKeyDown"`
|
|
264
|
+
* @param handler - Callback receiving the numeric key code of the pressed key.
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* addEventHandler("OnKeyDown", function(key) {
|
|
268
|
+
* if (key === 27) console.log("Escape pressed");
|
|
269
|
+
* });
|
|
270
|
+
*/
|
|
271
|
+
declare function addEventHandler(
|
|
272
|
+
name: "OnKeyDown",
|
|
273
|
+
handler: (key: number) => void
|
|
274
|
+
): void;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Fired when a key is released.
|
|
278
|
+
*
|
|
279
|
+
* @param name - `"OnKeyUp"`
|
|
280
|
+
* @param handler - Callback receiving the numeric key code of the released key.
|
|
281
|
+
*/
|
|
282
|
+
declare function addEventHandler(
|
|
283
|
+
name: "OnKeyUp",
|
|
284
|
+
handler: (key: number) => void
|
|
285
|
+
): void;
|
|
286
|
+
|
|
287
|
+
// ===== Mouse Events =====
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Fired when a mouse device is connected.
|
|
291
|
+
*
|
|
292
|
+
* @param name - `"OnMouseConnected"`
|
|
293
|
+
* @param handler - Callback with no arguments.
|
|
294
|
+
*/
|
|
295
|
+
declare function addEventHandler(
|
|
296
|
+
name: "OnMouseConnected",
|
|
297
|
+
handler: () => void
|
|
298
|
+
): void;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Fired when a mouse device is disconnected.
|
|
302
|
+
*
|
|
303
|
+
* @param name - `"OnMouseDisconnected"`
|
|
304
|
+
* @param handler - Callback with no arguments.
|
|
305
|
+
*/
|
|
306
|
+
declare function addEventHandler(
|
|
307
|
+
name: "OnMouseDisconnected",
|
|
308
|
+
handler: () => void
|
|
309
|
+
): void;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Fired when a mouse button is pressed down.
|
|
313
|
+
*
|
|
314
|
+
* @param name - `"OnMouseDown"`
|
|
315
|
+
* @param handler - Callback receiving the button number and (x, y) screen coordinates.
|
|
316
|
+
*/
|
|
317
|
+
declare function addEventHandler(
|
|
318
|
+
name: "OnMouseDown",
|
|
319
|
+
handler: (button: number, x: number, y: number) => void
|
|
320
|
+
): void;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Fired when a mouse button is released.
|
|
324
|
+
*
|
|
325
|
+
* @param name - `"OnMouseUp"`
|
|
326
|
+
* @param handler - Callback receiving the button number and (x, y) screen coordinates.
|
|
327
|
+
*/
|
|
328
|
+
declare function addEventHandler(
|
|
329
|
+
name: "OnMouseUp",
|
|
330
|
+
handler: (button: number, x: number, y: number) => void
|
|
331
|
+
): void;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Fired continuously when the mouse moves across the screen.
|
|
335
|
+
*
|
|
336
|
+
* @param name - `"OnMouseMove"`
|
|
337
|
+
* @param handler - Callback receiving the (x, y) screen coordinates.
|
|
338
|
+
*/
|
|
339
|
+
declare function addEventHandler(
|
|
340
|
+
name: "OnMouseMove",
|
|
341
|
+
handler: (x: number, y: number) => void
|
|
342
|
+
): void;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Fired when the mouse cursor leaves the game window.
|
|
346
|
+
*
|
|
347
|
+
* @param name - `"OnMouseLeave"`
|
|
348
|
+
* @param handler - Callback with no arguments.
|
|
349
|
+
*/
|
|
350
|
+
declare function addEventHandler(
|
|
351
|
+
name: "OnMouseLeave",
|
|
352
|
+
handler: () => void
|
|
353
|
+
): void;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Fired when the mouse wheel is scrolled.
|
|
357
|
+
*
|
|
358
|
+
* @param name - `"OnMouseWheel"`
|
|
359
|
+
* @param handler - Callback receiving the scroll delta (positive = scroll up, negative = scroll down).
|
|
360
|
+
*/
|
|
361
|
+
declare function addEventHandler(
|
|
362
|
+
name: "OnMouseWheel",
|
|
363
|
+
handler: (delta: number) => void
|
|
364
|
+
): void;
|
|
365
|
+
|
|
366
|
+
// ===== Connection Events =====
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Fired when the client disconnects from the server.
|
|
370
|
+
* Use this to clean up resources or show a disconnection message.
|
|
371
|
+
*
|
|
372
|
+
* @param name - `"OnDisconnect"`
|
|
373
|
+
* @param handler - Callback with no arguments.
|
|
374
|
+
*/
|
|
375
|
+
declare function addEventHandler(
|
|
376
|
+
name: "OnDisconnect",
|
|
377
|
+
handler: () => void
|
|
378
|
+
): void;
|
|
379
|
+
|
|
380
|
+
// ===== Ped Events =====
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Fired when a ped is busted (arrested by police).
|
|
384
|
+
*
|
|
385
|
+
* @param name - `"OnPedBusted"`
|
|
386
|
+
* @param handler - Callback receiving the busted `Ped`.
|
|
387
|
+
*/
|
|
388
|
+
declare function addEventHandler(
|
|
389
|
+
name: "OnPedBusted",
|
|
390
|
+
handler: (ped: Ped) => void
|
|
391
|
+
): void;
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Fired when a ped changes their currently equipped weapon.
|
|
395
|
+
*
|
|
396
|
+
* @param name - `"OnPedChangeWeapon"`
|
|
397
|
+
* @param handler - Callback receiving the `Ped` and the new weapon ID.
|
|
398
|
+
*/
|
|
399
|
+
declare function addEventHandler(
|
|
400
|
+
name: "OnPedChangeWeapon",
|
|
401
|
+
handler: (ped: Ped, weapon: number) => void
|
|
402
|
+
): void;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Fired when a ped crouches.
|
|
406
|
+
*
|
|
407
|
+
* @param name - `"OnPedCrouch"`
|
|
408
|
+
* @param handler - Callback receiving the `Ped` that crouched.
|
|
409
|
+
*/
|
|
410
|
+
declare function addEventHandler(
|
|
411
|
+
name: "OnPedCrouch",
|
|
412
|
+
handler: (ped: Ped) => void
|
|
413
|
+
): void;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Fired when a ped uncrouches (stands back up).
|
|
417
|
+
*
|
|
418
|
+
* @param name - `"OnPedUncrouch"`
|
|
419
|
+
* @param handler - Callback receiving the `Ped` that uncrouched.
|
|
420
|
+
*/
|
|
421
|
+
declare function addEventHandler(
|
|
422
|
+
name: "OnPedUncrouch",
|
|
423
|
+
handler: (ped: Ped) => void
|
|
424
|
+
): void;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Fired when a ped dies (reaches 0 health).
|
|
428
|
+
* Note: `OnPedWasted` is a separate event that fires on the server.
|
|
429
|
+
*
|
|
430
|
+
* @param name - `"OnPedDead"`
|
|
431
|
+
* @param handler - Callback receiving the dead `Ped`.
|
|
432
|
+
*/
|
|
433
|
+
declare function addEventHandler(
|
|
434
|
+
name: "OnPedDead",
|
|
435
|
+
handler: (ped: Ped) => void
|
|
436
|
+
): void;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Fired when a ped starts entering a vehicle (opening door, climbing in).
|
|
440
|
+
*
|
|
441
|
+
* @param name - `"OnPedEnterVehicle"`
|
|
442
|
+
* @param handler - Callback receiving the `Ped`, the `Vehicle`, and the target seat number.
|
|
443
|
+
*/
|
|
444
|
+
declare function addEventHandler(
|
|
445
|
+
name: "OnPedEnterVehicle",
|
|
446
|
+
handler: (ped: Ped, vehicle: Vehicle, seat: number) => void
|
|
447
|
+
): void;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Fired when a ped starts exiting a vehicle.
|
|
451
|
+
*
|
|
452
|
+
* @param name - `"OnPedExitVehicle"`
|
|
453
|
+
* @param handler - Callback receiving the `Ped` and the `Vehicle` being exited.
|
|
454
|
+
*/
|
|
455
|
+
declare function addEventHandler(
|
|
456
|
+
name: "OnPedExitVehicle",
|
|
457
|
+
handler: (ped: Ped, vehicle: Vehicle) => void
|
|
458
|
+
): void;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Fired when a ped has fully entered a vehicle (seated).
|
|
462
|
+
*
|
|
463
|
+
* @param name - `"OnPedEnteredVehicle"`
|
|
464
|
+
* @param handler - Callback receiving the `Ped`, the `Vehicle`, and the occupied seat.
|
|
465
|
+
*/
|
|
466
|
+
declare function addEventHandler(
|
|
467
|
+
name: "OnPedEnteredVehicle",
|
|
468
|
+
handler: (ped: Ped, vehicle: Vehicle, seat: number) => void
|
|
469
|
+
): void;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Fired when a ped has fully exited a vehicle (standing outside).
|
|
473
|
+
*
|
|
474
|
+
* @param name - `"OnPedExitedVehicle"`
|
|
475
|
+
* @param handler - Callback receiving the `Ped` and the `Vehicle` that was exited.
|
|
476
|
+
*/
|
|
477
|
+
declare function addEventHandler(
|
|
478
|
+
name: "OnPedExitedVehicle",
|
|
479
|
+
handler: (ped: Ped, vehicle: Vehicle) => void
|
|
480
|
+
): void;
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Fired when a ped is in the process of entering a vehicle (animation playing).
|
|
484
|
+
*
|
|
485
|
+
* @param name - `"OnPedEnteringVehicle"`
|
|
486
|
+
* @param handler - Callback receiving the `Ped`, the `Vehicle`, and the target seat.
|
|
487
|
+
*/
|
|
488
|
+
declare function addEventHandler(
|
|
489
|
+
name: "OnPedEnteringVehicle",
|
|
490
|
+
handler: (ped: Ped, vehicle: Vehicle, seat: number) => void
|
|
491
|
+
): void;
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Fired when a ped is in the process of exiting a vehicle (animation playing).
|
|
495
|
+
*
|
|
496
|
+
* @param name - `"OnPedExitingVehicle"`
|
|
497
|
+
* @param handler - Callback receiving the `Ped` and the `Vehicle` being exited.
|
|
498
|
+
*/
|
|
499
|
+
declare function addEventHandler(
|
|
500
|
+
name: "OnPedExitingVehicle",
|
|
501
|
+
handler: (ped: Ped, vehicle: Vehicle) => void
|
|
502
|
+
): void;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Fired when a ped falls (loses footing and falls to the ground).
|
|
506
|
+
*
|
|
507
|
+
* @param name - `"OnPedFall"`
|
|
508
|
+
* @param handler - Callback receiving the fallen `Ped`.
|
|
509
|
+
*/
|
|
510
|
+
declare function addEventHandler(
|
|
511
|
+
name: "OnPedFall",
|
|
512
|
+
handler: (ped: Ped) => void
|
|
513
|
+
): void;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Fired when a ped fires a projectile (rocket, grenade, etc.).
|
|
517
|
+
*
|
|
518
|
+
* @param name - `"OnPedFireProjectile"`
|
|
519
|
+
* @param handler - Callback receiving the `Ped` that fired.
|
|
520
|
+
*/
|
|
521
|
+
declare function addEventHandler(
|
|
522
|
+
name: "OnPedFireProjectile",
|
|
523
|
+
handler: (ped: Ped) => void
|
|
524
|
+
): void;
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Fired when a ped inflicts damage on another ped.
|
|
528
|
+
*
|
|
529
|
+
* @param name - `"OnPedInflictDamage"`
|
|
530
|
+
* @param handler - Callback receiving the attacking `Ped`, the target `Ped`, and the damage amount.
|
|
531
|
+
*/
|
|
532
|
+
declare function addEventHandler(
|
|
533
|
+
name: "OnPedInflictDamage",
|
|
534
|
+
handler: (ped: Ped, target: Ped, damage: number) => void
|
|
535
|
+
): void;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Fired when a ped jumps.
|
|
539
|
+
*
|
|
540
|
+
* @param name - `"OnPedJump"`
|
|
541
|
+
* @param handler - Callback receiving the jumping `Ped`.
|
|
542
|
+
*/
|
|
543
|
+
declare function addEventHandler(
|
|
544
|
+
name: "OnPedJump",
|
|
545
|
+
handler: (ped: Ped) => void
|
|
546
|
+
): void;
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Fired when a ped spawns (appears in the world for the first time).
|
|
550
|
+
*
|
|
551
|
+
* @param name - `"OnPedSpawn"`
|
|
552
|
+
* @param handler - Callback receiving the spawned `Ped`.
|
|
553
|
+
*/
|
|
554
|
+
declare function addEventHandler(
|
|
555
|
+
name: "OnPedSpawn",
|
|
556
|
+
handler: (ped: Ped) => void
|
|
557
|
+
): void;
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Fired when a ped starts closing a vehicle door.
|
|
561
|
+
*
|
|
562
|
+
* @param name - `"OnPedStartClosingVehicleDoor"`
|
|
563
|
+
* @param handler - Callback receiving the `Ped`, the `Vehicle`, and the door index.
|
|
564
|
+
*/
|
|
565
|
+
declare function addEventHandler(
|
|
566
|
+
name: "OnPedStartClosingVehicleDoor",
|
|
567
|
+
handler: (ped: Ped, vehicle: Vehicle, door: number) => void
|
|
568
|
+
): void;
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Fired when a ped starts a fight attack (melee or weapon).
|
|
572
|
+
*
|
|
573
|
+
* @param name - `"OnPedStartFightAttack"`
|
|
574
|
+
* @param handler - Callback receiving the attacking `Ped` and the target `Ped`.
|
|
575
|
+
*/
|
|
576
|
+
declare function addEventHandler(
|
|
577
|
+
name: "OnPedStartFightAttack",
|
|
578
|
+
handler: (ped: Ped, target: Ped) => void
|
|
579
|
+
): void;
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Fired when a ped starts defending against a fight attack.
|
|
583
|
+
*
|
|
584
|
+
* @param name - `"OnPedStartFightDefend"`
|
|
585
|
+
* @param handler - Callback receiving the defending `Ped` and the attacker `Ped`.
|
|
586
|
+
*/
|
|
587
|
+
declare function addEventHandler(
|
|
588
|
+
name: "OnPedStartFightDefend",
|
|
589
|
+
handler: (ped: Ped, attacker: Ped) => void
|
|
590
|
+
): void;
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Fired when a ped starts opening a vehicle door.
|
|
594
|
+
*
|
|
595
|
+
* @param name - `"OnPedStartOpeningVehicleDoor"`
|
|
596
|
+
* @param handler - Callback receiving the `Ped`, the `Vehicle`, and the door index.
|
|
597
|
+
*/
|
|
598
|
+
declare function addEventHandler(
|
|
599
|
+
name: "OnPedStartOpeningVehicleDoor",
|
|
600
|
+
handler: (ped: Ped, vehicle: Vehicle, door: number) => void
|
|
601
|
+
): void;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Fired when a ped uses/equips a weapon.
|
|
605
|
+
*
|
|
606
|
+
* @param name - `"OnPedUseWeapon"`
|
|
607
|
+
* @param handler - Callback receiving the `Ped` and the weapon ID.
|
|
608
|
+
*/
|
|
609
|
+
declare function addEventHandler(
|
|
610
|
+
name: "OnPedUseWeapon",
|
|
611
|
+
handler: (ped: Ped, weapon: number) => void
|
|
612
|
+
): void;
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Fired when a ped is wasted/killed.
|
|
616
|
+
* Note: this is a client-side notification. Server also has `OnPedWasted`.
|
|
617
|
+
*
|
|
618
|
+
* @param name - `"OnPedWasted"`
|
|
619
|
+
* @param handler - Callback receiving the wasted `Ped`.
|
|
620
|
+
*/
|
|
621
|
+
declare function addEventHandler(
|
|
622
|
+
name: "OnPedWasted",
|
|
623
|
+
handler: (ped: Ped) => void
|
|
624
|
+
): void;
|
|
625
|
+
|
|
626
|
+
// ===== Pickup Events =====
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Fired when a pickup is collected by a player.
|
|
630
|
+
*
|
|
631
|
+
* @param name - `"OnPickupCollected"`
|
|
632
|
+
* @param handler - Callback receiving the collected `Pickup` and the `Player` who collected it.
|
|
633
|
+
*/
|
|
634
|
+
declare function addEventHandler(
|
|
635
|
+
name: "OnPickupCollected",
|
|
636
|
+
handler: (pickup: Pickup, player: Player) => void
|
|
637
|
+
): void;
|
|
638
|
+
|
|
639
|
+
// ===== Process/Render Events =====
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Fired every game tick (frame). Main update loop event.
|
|
643
|
+
* Use this for continuous logic that needs to run each frame.
|
|
644
|
+
*
|
|
645
|
+
* @param name - `"OnProcess"`
|
|
646
|
+
* @param handler - Callback with no arguments.
|
|
647
|
+
*/
|
|
648
|
+
declare function addEventHandler(
|
|
649
|
+
name: "OnProcess",
|
|
650
|
+
handler: () => void
|
|
651
|
+
): void;
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Fired after 3D rendering but before 2D/HUD rendering.
|
|
655
|
+
* Use this to draw custom 2D graphics that sit behind the HUD.
|
|
656
|
+
*
|
|
657
|
+
* @param name - `"OnPostRender2D"`
|
|
658
|
+
* @param handler - Callback with no arguments.
|
|
659
|
+
*/
|
|
660
|
+
declare function addEventHandler(
|
|
661
|
+
name: "OnPostRender2D",
|
|
662
|
+
handler: () => void
|
|
663
|
+
): void;
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Fired before the 3D scene is rendered.
|
|
667
|
+
* Use this to modify the scene before the engine draws it.
|
|
668
|
+
*
|
|
669
|
+
* @param name - `"OnPreRender"`
|
|
670
|
+
* @param handler - Callback with no arguments.
|
|
671
|
+
*/
|
|
672
|
+
declare function addEventHandler(
|
|
673
|
+
name: "OnPreRender",
|
|
674
|
+
handler: () => void
|
|
675
|
+
): void;
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Fired during the 3D scene rendering.
|
|
679
|
+
* Use this for custom 3D drawing (text, lines, shapes in the world).
|
|
680
|
+
*
|
|
681
|
+
* @param name - `"OnRender"`
|
|
682
|
+
* @param handler - Callback with no arguments.
|
|
683
|
+
*/
|
|
684
|
+
declare function addEventHandler(
|
|
685
|
+
name: "OnRender",
|
|
686
|
+
handler: () => void
|
|
687
|
+
): void;
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Fired during 2D rendering (screen-space graphics).
|
|
691
|
+
* Use this to draw custom UI elements on screen.
|
|
692
|
+
*
|
|
693
|
+
* @param name - `"OnRender2D"`
|
|
694
|
+
* @param handler - Callback with no arguments.
|
|
695
|
+
*/
|
|
696
|
+
declare function addEventHandler(
|
|
697
|
+
name: "OnRender2D",
|
|
698
|
+
handler: () => void
|
|
699
|
+
): void;
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Fired when visual effects are being rendered (particles, coronas, etc.).
|
|
703
|
+
* Use this to inject custom rendering effects.
|
|
704
|
+
*
|
|
705
|
+
* @param name - `"OnRenderEffects"`
|
|
706
|
+
* @param handler - Callback with no arguments.
|
|
707
|
+
*/
|
|
708
|
+
declare function addEventHandler(
|
|
709
|
+
name: "OnRenderEffects",
|
|
710
|
+
handler: () => void
|
|
711
|
+
): void;
|
|
712
|
+
|
|
713
|
+
// ===== Resource Events =====
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Fired when a resource finishes loading and is ready to use.
|
|
717
|
+
*
|
|
718
|
+
* @param name - `"OnResourceReady"`
|
|
719
|
+
* @param handler - Callback receiving the ready `Resource`.
|
|
720
|
+
*/
|
|
721
|
+
declare function addEventHandler(
|
|
722
|
+
name: "OnResourceReady",
|
|
723
|
+
handler: (resource: Resource) => void
|
|
724
|
+
): void;
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Fired when a resource starts running.
|
|
728
|
+
*
|
|
729
|
+
* @param name - `"OnResourceStart"`
|
|
730
|
+
* @param handler - Callback receiving the started `Resource`.
|
|
731
|
+
*/
|
|
732
|
+
declare function addEventHandler(
|
|
733
|
+
name: "OnResourceStart",
|
|
734
|
+
handler: (resource: Resource) => void
|
|
735
|
+
): void;
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Fired when a resource stops running.
|
|
739
|
+
*
|
|
740
|
+
* @param name - `"OnResourceStop"`
|
|
741
|
+
* @param handler - Callback receiving the stopped `Resource`.
|
|
742
|
+
*/
|
|
743
|
+
declare function addEventHandler(
|
|
744
|
+
name: "OnResourceStop",
|
|
745
|
+
handler: (resource: Resource) => void
|
|
746
|
+
): void;
|
|
747
|
+
|
|
748
|
+
// ===== Vehicle Events =====
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Fired when a vehicle explodes (reaches 0 health and detonates).
|
|
752
|
+
*
|
|
753
|
+
* @param name - `"OnVehicleExplode"`
|
|
754
|
+
* @param handler - Callback receiving the exploding `Vehicle`.
|
|
755
|
+
*/
|
|
756
|
+
declare function addEventHandler(
|
|
757
|
+
name: "OnVehicleExplode",
|
|
758
|
+
handler: (vehicle: Vehicle) => void
|
|
759
|
+
): void;
|
|
760
|
+
|
|
761
|
+
// ===== Generic Fallback =====
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Generic fallback overload for any event name not explicitly typed above.
|
|
765
|
+
* Allows listening for custom or future event names with any number of arguments.
|
|
766
|
+
*
|
|
767
|
+
* @param name - The event name string.
|
|
768
|
+
* @param handler - Callback receiving any number of variadic arguments.
|
|
769
|
+
*/
|
|
770
|
+
declare function addEventHandler(
|
|
771
|
+
name: string,
|
|
772
|
+
handler: (...args: any[]) => void
|
|
773
|
+
): void;
|
|
774
|
+
|
|
775
|
+
// ===== Event Unregistration =====
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Removes a previously registered event handler.
|
|
779
|
+
*
|
|
780
|
+
* @param name - The event name to stop listening to.
|
|
781
|
+
* @param handler - The exact handler function reference that was previously registered.
|
|
782
|
+
* Must be the same function object, not a copy or new closure.
|
|
783
|
+
*
|
|
784
|
+
* @example
|
|
785
|
+
* function onKeyDown(key: number) { console.log(key); }
|
|
786
|
+
* addEventHandler("OnKeyDown", onKeyDown);
|
|
787
|
+
* // Later:
|
|
788
|
+
* removeEventHandler("OnKeyDown", onKeyDown);
|
|
789
|
+
*/
|
|
790
|
+
declare function removeEventHandler(
|
|
791
|
+
name: string,
|
|
792
|
+
handler: (...args: any[]) => void
|
|
793
|
+
): void;
|
|
794
|
+
|
|
795
|
+
// ===== Bound Event Handlers =====
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Registers a handler bound to a specific resource for lifecycle events.
|
|
799
|
+
* When the resource stops, the handler is automatically removed.
|
|
800
|
+
*
|
|
801
|
+
* @param name - Event name: `"OnResourceReady"` or `"OnResourceStart"`.
|
|
802
|
+
* @param resource - The `Resource` object to bind the handler's lifetime to.
|
|
803
|
+
* @param handler - Callback receiving variadic arguments.
|
|
804
|
+
*/
|
|
805
|
+
declare function bindEventHandler(
|
|
806
|
+
name: "OnResourceReady" | "OnResourceStart",
|
|
807
|
+
resource: object,
|
|
808
|
+
handler: (...args: any[]) => void
|
|
809
|
+
): void;
|