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,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GTAC Event Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the base event system types used throughout GTA Connected.
|
|
5
|
+
* Events are dispatched by the engine when in-game actions occur (key presses,
|
|
6
|
+
* player connections, element creation, etc.). Some events can be cancelled
|
|
7
|
+
* to prevent their default behaviour.
|
|
8
|
+
*
|
|
9
|
+
* @module types/event
|
|
10
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Listen for a key press and cancel it if it's the escape key
|
|
14
|
+
* bindKey("Escape", function(event: KeyEvent) {
|
|
15
|
+
* if (event.key === 27) {
|
|
16
|
+
* message("Escape was pressed!");
|
|
17
|
+
* }
|
|
18
|
+
* });
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
// ===== Events =====
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Base event type — all specific event interfaces extend this type.
|
|
25
|
+
*
|
|
26
|
+
* This is the root of the event hierarchy. It carries no properties of its own
|
|
27
|
+
* but serves as the common type for event-related overloads and generic handlers.
|
|
28
|
+
*/
|
|
29
|
+
type Event = {}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* An event whose default behaviour can be cancelled.
|
|
33
|
+
*
|
|
34
|
+
* Cancellable events allow handlers to call `preventDefault()` to stop the
|
|
35
|
+
* engine from performing its built-in response. For example, cancelling a
|
|
36
|
+
* `OnPedWasted` event can prevent the ped from actually dying.
|
|
37
|
+
*
|
|
38
|
+
* @extends Event
|
|
39
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Prevent a player from dying
|
|
43
|
+
* addEventHandler("OnPedWasted", function(event: CancellableEvent, ped: Ped) {
|
|
44
|
+
* if (isImportantPed(ped)) {
|
|
45
|
+
* event.preventDefault(); // Ped will not die
|
|
46
|
+
* }
|
|
47
|
+
* });
|
|
48
|
+
*/
|
|
49
|
+
interface CancellableEvent extends Event {
|
|
50
|
+
/**
|
|
51
|
+
* Has this event's default behaviour been prevented?
|
|
52
|
+
*
|
|
53
|
+
* @returns `true` if `preventDefault()` has been called on this event.
|
|
54
|
+
*/
|
|
55
|
+
isDefaultPrevented(): boolean;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Prevents the engine's default behaviour for this event.
|
|
59
|
+
*
|
|
60
|
+
* After calling this, the engine will not perform the action it normally would.
|
|
61
|
+
* For example, preventing the `OnPedWasted` default stops the ped from dying.
|
|
62
|
+
* Does not prevent other event handlers from running.
|
|
63
|
+
*/
|
|
64
|
+
preventDefault(): void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A keyboard key event dispatched when a bound key is pressed or released.
|
|
69
|
+
*
|
|
70
|
+
* Key events carry the key code and whether the event is a key-up (release)
|
|
71
|
+
* or key-down (press). Use `bindKey()` to register key bindings that will
|
|
72
|
+
* fire these events.
|
|
73
|
+
*
|
|
74
|
+
* @extends Event
|
|
75
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* // Toggle the chat window with the T key
|
|
79
|
+
* bindKey("T", function(event: KeyEvent) {
|
|
80
|
+
* if (event.isUp()) return; // Only handle key-down
|
|
81
|
+
* chatWindowEnabled(!isChatOpen);
|
|
82
|
+
* });
|
|
83
|
+
*/
|
|
84
|
+
interface KeyEvent extends Event {
|
|
85
|
+
/**
|
|
86
|
+
* Determines whether this event represents a key release (key-up) as
|
|
87
|
+
* opposed to a key press (key-down).
|
|
88
|
+
*
|
|
89
|
+
* @returns `true` if the key was released (key-up event), `false` if pressed.
|
|
90
|
+
*/
|
|
91
|
+
isUp(): boolean;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The numeric key code identifying which key triggered this event.
|
|
95
|
+
*
|
|
96
|
+
* Key codes correspond to the standard virtual key codes:
|
|
97
|
+
* 27 = Escape, 13 = Enter, 32 = Space, etc.
|
|
98
|
+
*/
|
|
99
|
+
key: number;
|
|
100
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GTAC Shared Constant Defines
|
|
3
|
+
*
|
|
4
|
+
* Predefined numeric constants available globally in every GTA Connected script.
|
|
5
|
+
* These cover common colours, element type identifiers, GTA entity types,
|
|
6
|
+
* chat message types, and camera fade directions.
|
|
7
|
+
*
|
|
8
|
+
* All constants are declared as `var` globals — no import required.
|
|
9
|
+
*
|
|
10
|
+
* @module types/misc
|
|
11
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Check if an element is a player
|
|
15
|
+
* if (element.type === ELEMENT_PLAYER) {
|
|
16
|
+
* message("Found a player!");
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Fade the camera in using a predefined constant
|
|
21
|
+
* gta.fadeCamera(FADE_IN, 1000);
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
// ===== Shared Defines =====
|
|
25
|
+
|
|
26
|
+
// ===== Colour Constants =====
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* ARGB colour constant: fully transparent (alpha = 0).
|
|
30
|
+
* Useful for creating invisible elements or clearing colour values.
|
|
31
|
+
*/
|
|
32
|
+
declare var COLOUR_TRANSPARENT: number;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* ARGB colour constant: solid red (0xFFFF0000).
|
|
36
|
+
*/
|
|
37
|
+
declare var COLOUR_RED: number;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* ARGB colour constant: solid green (0xFF00FF00).
|
|
41
|
+
*/
|
|
42
|
+
declare var COLOUR_GREEN: number;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* ARGB colour constant: solid lime green (0xFF00FF00).
|
|
46
|
+
*/
|
|
47
|
+
declare var COLOUR_LIME: number;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* ARGB colour constant: solid blue (0xFF0000FF).
|
|
51
|
+
*/
|
|
52
|
+
declare var COLOUR_BLUE: number;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* ARGB colour constant: solid aqua/cyan (0xFF00FFFF).
|
|
56
|
+
*/
|
|
57
|
+
declare var COLOUR_AQUA: number;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* ARGB colour constant: solid fuchsia/magenta (0xFFFF00FF).
|
|
61
|
+
*/
|
|
62
|
+
declare var COLOUR_FUCHSIA: number;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* ARGB colour constant: solid yellow (0xFFFFFF00).
|
|
66
|
+
*/
|
|
67
|
+
declare var COLOUR_YELLOW: number;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* ARGB colour constant: solid orange (0xFFFFA500).
|
|
71
|
+
*/
|
|
72
|
+
declare var COLOUR_ORANGE: number;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* ARGB colour constant: solid white (0xFFFFFFFF).
|
|
76
|
+
*/
|
|
77
|
+
declare var COLOUR_WHITE: number;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* ARGB colour constant: solid black (0xFF000000).
|
|
81
|
+
*/
|
|
82
|
+
declare var COLOUR_BLACK: number;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* ARGB colour constant: silver/grey (0xFFC0C0C0).
|
|
86
|
+
*/
|
|
87
|
+
declare var COLOUR_SILVER: number;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* ARGB colour constant: sky blue (0xFF87CEEB).
|
|
91
|
+
*/
|
|
92
|
+
declare var COLOUR_SKYBLUE: number;
|
|
93
|
+
|
|
94
|
+
// ===== Element Type Constants =====
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Generic/base element type constant.
|
|
98
|
+
* Used to identify the root `Element` type — all elements are at least this type.
|
|
99
|
+
*/
|
|
100
|
+
declare var ELEMENT_ELEMENT: number;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Transformable element type constant.
|
|
104
|
+
* Elements that can be transformed (moved/rotated/scaled) fall under this category.
|
|
105
|
+
*/
|
|
106
|
+
declare var ELEMENT_TRANSFORMABLE: number;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Entity element type constant.
|
|
110
|
+
* Identifies `Entity` instances — elements with heading, bounding volumes, and collision data.
|
|
111
|
+
*/
|
|
112
|
+
declare var ELEMENT_ENTITY: number;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Physical element type constant.
|
|
116
|
+
* Identifies `Physical` instances — entities with mass, velocity, gravity, and physics.
|
|
117
|
+
*/
|
|
118
|
+
declare var ELEMENT_PHYSICAL: number;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Ped element type constant.
|
|
122
|
+
* Identifies `Ped` instances — character entities with health, armour, and vehicle occupancy.
|
|
123
|
+
*/
|
|
124
|
+
declare var ELEMENT_PED: number;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Civilian ped element type constant.
|
|
128
|
+
* Identifies `Ped` instances that are specifically civilian (non-player, non-cop) characters.
|
|
129
|
+
*/
|
|
130
|
+
declare var ELEMENT_CIVILIAN: number;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Player element type constant.
|
|
134
|
+
* Identifies `Player` instances — peds controlled by connected clients.
|
|
135
|
+
*/
|
|
136
|
+
declare var ELEMENT_PLAYER: number;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Vehicle element type constant.
|
|
140
|
+
* Identifies `Vehicle` instances — driveable vehicle entities.
|
|
141
|
+
*/
|
|
142
|
+
declare var ELEMENT_VEHICLE: number;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Blip element type constant.
|
|
146
|
+
* Identifies `Blip` instances — radar/minimap icons.
|
|
147
|
+
*/
|
|
148
|
+
declare var ELEMENT_BLIP: number;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Object element type constant.
|
|
152
|
+
* Identifies `Object` instances — placeable physical items with a model.
|
|
153
|
+
*/
|
|
154
|
+
declare var ELEMENT_OBJECT: number;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Train element type constant.
|
|
158
|
+
* Identifies `Train` instances — vehicles constrained to rail tracks.
|
|
159
|
+
*/
|
|
160
|
+
declare var ELEMENT_TRAIN: number;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Pickup element type constant.
|
|
164
|
+
* Identifies `Pickup` instances — collectible items in the world.
|
|
165
|
+
*/
|
|
166
|
+
declare var ELEMENT_PICKUP: number;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Marker element type constant.
|
|
170
|
+
* Identifies `Marker` instances — 3D world markers (checkpoints, arrows).
|
|
171
|
+
*/
|
|
172
|
+
declare var ELEMENT_MARKER: number;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Building element type constant.
|
|
176
|
+
* Identifies `Building` instances — static world geometry elements.
|
|
177
|
+
*/
|
|
178
|
+
declare var ELEMENT_BUILDING: number;
|
|
179
|
+
|
|
180
|
+
// ===== GTA Entity Type Constants =====
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* GTA entity type: building.
|
|
184
|
+
* Low-level engine classification for building/static geometry entities.
|
|
185
|
+
*/
|
|
186
|
+
declare var ENTITYTYPE_BUILDING: number;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* GTA entity type: vehicle.
|
|
190
|
+
* Low-level engine classification for vehicle entities.
|
|
191
|
+
*/
|
|
192
|
+
declare var ENTITYTYPE_VEHICLE: number;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* GTA entity type: ped.
|
|
196
|
+
* Low-level engine classification for pedestrian/character entities.
|
|
197
|
+
*/
|
|
198
|
+
declare var ENTITYTYPE_PED: number;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* GTA entity type: object.
|
|
202
|
+
* Low-level engine classification for dynamic object entities.
|
|
203
|
+
*/
|
|
204
|
+
declare var ENTITYTYPE_OBJECT: number;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* GTA entity type: object LOD (Level of Detail).
|
|
208
|
+
* Low-detail version of an object used for distant rendering.
|
|
209
|
+
*/
|
|
210
|
+
declare var ENTITYTYPE_OBJECT_LOD: number;
|
|
211
|
+
|
|
212
|
+
// ===== Chat Type Constants =====
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Chat message type: none/unknown.
|
|
216
|
+
* Used when the chat message type is not explicitly set.
|
|
217
|
+
*/
|
|
218
|
+
declare var CHAT_TYPE_NONE: number;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Chat message type: chat.
|
|
222
|
+
* Standard chat message sent by a player. Appears in the chat window.
|
|
223
|
+
*/
|
|
224
|
+
declare var CHAT_TYPE_CHAT: number;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Chat message type: info.
|
|
228
|
+
* Informational system message. Typically styled differently from chat messages.
|
|
229
|
+
*/
|
|
230
|
+
declare var CHAT_TYPE_INFO: number;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Chat message type: debug.
|
|
234
|
+
* Debug-level message used for development and troubleshooting output.
|
|
235
|
+
*/
|
|
236
|
+
declare var CHAT_TYPE_DEBUG: number;
|
|
237
|
+
|
|
238
|
+
// ===== Camera Fade Constants =====
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Camera fade direction: fade out (scene goes dark).
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* // Fade the screen to black over 2 seconds
|
|
245
|
+
* gta.fadeCamera(FADE_OUT, 2000);
|
|
246
|
+
*/
|
|
247
|
+
declare var FADE_OUT: number;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Camera fade direction: fade in (scene becomes visible).
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* // Reveal the screen from black over 1.5 seconds
|
|
254
|
+
* gta.fadeCamera(FADE_IN, 1500);
|
|
255
|
+
*/
|
|
256
|
+
declare var FADE_IN: number;
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GTAC Resource, Timer, and Runtime Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the types for GTA Connected resources (loaded scripts), timers
|
|
5
|
+
* (scheduling), streams, reflected functions, and the global console API.
|
|
6
|
+
* These types bridge the SpiderMonkey JS engine with GTAC-specific runtime
|
|
7
|
+
* concepts.
|
|
8
|
+
*
|
|
9
|
+
* All declarations are global — no import/export required.
|
|
10
|
+
*
|
|
11
|
+
* @module types/resource
|
|
12
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Access the current resource's info
|
|
16
|
+
* console.log("Running resource: " + thisResource.name);
|
|
17
|
+
* console.log("Resource path: " + thisResource.path);
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
// ===== Resource =====
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A loaded GTA Connected resource (script package).
|
|
24
|
+
*
|
|
25
|
+
* Resources are defined by a `meta.xml` manifest and contain server-side
|
|
26
|
+
* and/or client-side scripts. Each resource has a name, filesystem path,
|
|
27
|
+
* and a lifecycle state (running, stopped). Resources can be started, stopped,
|
|
28
|
+
* and restarted programmatically.
|
|
29
|
+
*
|
|
30
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
31
|
+
*/
|
|
32
|
+
interface Resource {
|
|
33
|
+
/**
|
|
34
|
+
* Resource name as defined in `meta.xml`.
|
|
35
|
+
* This is the unique identifier used to reference the resource.
|
|
36
|
+
*/
|
|
37
|
+
name: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Absolute filesystem path to the resource's root directory.
|
|
41
|
+
* Use this to locate resource-local files.
|
|
42
|
+
*/
|
|
43
|
+
path: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Current lifecycle state of the resource.
|
|
47
|
+
* Possible states: running, stopped, starting, stopping.
|
|
48
|
+
*/
|
|
49
|
+
state: number;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Starts the resource if it is currently stopped.
|
|
53
|
+
* Has no effect if the resource is already running.
|
|
54
|
+
*/
|
|
55
|
+
start(): void;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Stops the resource if it is currently running.
|
|
59
|
+
* Has no effect if the resource is already stopped.
|
|
60
|
+
*/
|
|
61
|
+
stop(): void;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Restarts the resource (stops then starts it).
|
|
65
|
+
* Equivalent to calling `stop()` followed by `start()`.
|
|
66
|
+
*/
|
|
67
|
+
restart(): void;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Global reference to the currently executing resource.
|
|
72
|
+
*
|
|
73
|
+
* Provides access to the `Resource` instance for the script currently running.
|
|
74
|
+
* Use this to get the resource's name, path, or to trigger lifecycle actions.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* console.log("Current resource: " + thisResource.name);
|
|
78
|
+
*/
|
|
79
|
+
declare var thisResource: Resource;
|
|
80
|
+
|
|
81
|
+
// ===== Timer / Stream =====
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A native GTAC timer created via `setTimer()`.
|
|
85
|
+
*
|
|
86
|
+
* Unlike JavaScript's built-in `setInterval`/`setTimeout` which return numeric IDs,
|
|
87
|
+
* GTAC's `setTimer()` returns a `Timer` object that can be destroyed to stop the
|
|
88
|
+
* timer permanently.
|
|
89
|
+
*
|
|
90
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* // Create a timer that fires 5 times, then stops
|
|
94
|
+
* const timer = setTimer(function() {
|
|
95
|
+
* message("Tick!");
|
|
96
|
+
* }, 1000, 5);
|
|
97
|
+
*
|
|
98
|
+
* // Manually destroy it early
|
|
99
|
+
* timer.destroy();
|
|
100
|
+
*/
|
|
101
|
+
interface Timer {
|
|
102
|
+
/**
|
|
103
|
+
* Stops and permanently destroys the timer.
|
|
104
|
+
* After calling this, the timer's callback will never fire again.
|
|
105
|
+
*/
|
|
106
|
+
destroy(): void;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A data stream handle (opaque type).
|
|
111
|
+
*
|
|
112
|
+
* Streams are used for binary data I/O and serialization.
|
|
113
|
+
* The internal structure is engine-defined and not directly accessible.
|
|
114
|
+
*/
|
|
115
|
+
type Stream = {}
|
|
116
|
+
|
|
117
|
+
// ===== ReflectedFunction =====
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* A function reference obtained via the reflection API (opaque type).
|
|
121
|
+
*
|
|
122
|
+
* ReflectedFunctions allow scripts to dynamically call functions by name
|
|
123
|
+
* or reference, supporting meta-programming patterns.
|
|
124
|
+
* The internal structure is engine-defined.
|
|
125
|
+
*/
|
|
126
|
+
type ReflectedFunction = {}
|
|
127
|
+
|
|
128
|
+
// ===== Timer Functions =====
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Creates a repeating interval timer (mirrors the JavaScript standard API).
|
|
132
|
+
*
|
|
133
|
+
* The provided callback function will be called every `ms` milliseconds
|
|
134
|
+
* until `clearInterval()` is called with the returned timer ID.
|
|
135
|
+
*
|
|
136
|
+
* @param fn - Callback function invoked on each tick.
|
|
137
|
+
* @param ms - Interval duration in milliseconds between invocations.
|
|
138
|
+
* @returns A numeric timer ID for use with `clearInterval()`.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* // Log a message every 5 seconds
|
|
142
|
+
* const intervalId = setInterval(function() {
|
|
143
|
+
* console.log("5 seconds passed");
|
|
144
|
+
* }, 5000);
|
|
145
|
+
*
|
|
146
|
+
* // Later, stop the interval
|
|
147
|
+
* clearInterval(intervalId);
|
|
148
|
+
*/
|
|
149
|
+
declare function setInterval(fn: () => void, ms: number): number;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Creates a one-shot timer (mirrors the JavaScript standard API).
|
|
153
|
+
*
|
|
154
|
+
* The provided callback function will be called once after `ms` milliseconds.
|
|
155
|
+
*
|
|
156
|
+
* @param fn - Callback function to invoke after the delay.
|
|
157
|
+
* @param ms - Delay duration in milliseconds before invocation.
|
|
158
|
+
* @returns A numeric timer ID for use with `clearTimeout()`.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* // Show a message after 3 seconds
|
|
162
|
+
* setTimeout(function() {
|
|
163
|
+
* message("Three seconds have passed!");
|
|
164
|
+
* }, 3000);
|
|
165
|
+
*/
|
|
166
|
+
declare function setTimeout(fn: () => void, ms: number): number;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Clears a repeating interval previously created with `setInterval()`.
|
|
170
|
+
*
|
|
171
|
+
* @param id - The timer ID returned by `setInterval()`.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* const id = setInterval(myFn, 1000);
|
|
175
|
+
* clearInterval(id); // Stops the interval
|
|
176
|
+
*/
|
|
177
|
+
declare function clearInterval(id: number): void;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Clears a one-shot timeout previously created with `setTimeout()`.
|
|
181
|
+
* Has no effect if the timeout has already fired.
|
|
182
|
+
*
|
|
183
|
+
* @param id - The timer ID returned by `setTimeout()`.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* const id = setTimeout(myFn, 5000);
|
|
187
|
+
* clearTimeout(id); // Cancels the timeout before it fires
|
|
188
|
+
*/
|
|
189
|
+
declare function clearTimeout(id: number): void;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Creates a native GTAC timer that fires a specified number of times.
|
|
193
|
+
*
|
|
194
|
+
* Unlike `setInterval`, this returns a `Timer` object and supports a finite
|
|
195
|
+
* fire count. Set `count` to `0` for infinite repetition.
|
|
196
|
+
*
|
|
197
|
+
* @param func - Callback function invoked on each tick.
|
|
198
|
+
* @param interval - Interval in milliseconds between ticks.
|
|
199
|
+
* @param count - Number of times to fire (`0` = infinite).
|
|
200
|
+
* @returns A `Timer` object that can be destroyed with `killTimer()`.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* // Create a timer that fires exactly 10 times
|
|
204
|
+
* const timer = setTimer(function() {
|
|
205
|
+
* message("Fire!");
|
|
206
|
+
* }, 500, 10);
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* // Create an infinite timer (like setInterval but returns Timer)
|
|
210
|
+
* const timer = setTimer(function() {
|
|
211
|
+
* updateGame();
|
|
212
|
+
* }, 16, 0);
|
|
213
|
+
*/
|
|
214
|
+
declare function setTimer(
|
|
215
|
+
func: () => void,
|
|
216
|
+
interval: number,
|
|
217
|
+
count: number
|
|
218
|
+
): Timer;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Destroys a native GTAC timer created with `setTimer()`.
|
|
222
|
+
*
|
|
223
|
+
* @param timer - The `Timer` object to destroy.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* const timer = setTimer(myFn, 1000, 0);
|
|
227
|
+
* // Later...
|
|
228
|
+
* killTimer(timer);
|
|
229
|
+
*/
|
|
230
|
+
declare function killTimer(timer: Timer): void;
|
|
231
|
+
|
|
232
|
+
// ===== Console =====
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Server/client console logging API.
|
|
236
|
+
*
|
|
237
|
+
* Provides a `log()` method for printing messages to the server console
|
|
238
|
+
* or client debug output. Mirrors the standard JavaScript `console.log` API.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* console.log("Hello, GTAC!");
|
|
242
|
+
* console.log("Player count:", getPlayerCount());
|
|
243
|
+
*/
|
|
244
|
+
declare var console: {
|
|
245
|
+
/**
|
|
246
|
+
* Logs one or more values to the console output.
|
|
247
|
+
* Values are coerced to strings and joined with spaces.
|
|
248
|
+
*
|
|
249
|
+
* @param args - Any number of values to log.
|
|
250
|
+
*/
|
|
251
|
+
log(...args: unknown[]): void;
|
|
252
|
+
};
|