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.
@@ -0,0 +1,890 @@
1
+ /**
2
+ * GTAC Server-Side Function Declarations
3
+ *
4
+ * Defines all server-side global functions and objects available in the
5
+ * GTA Connected server runtime. Includes network events (addNetworkHandler,
6
+ * triggerNetworkEvent), command handlers, client queries, element management,
7
+ * blip/building/object/ped/pickup/player/vehicle queries, messaging,
8
+ * key binding, resource management, server information, network statistics,
9
+ * HTTP requests, file I/O, the server-side `gta` world manipulation API,
10
+ * player spawning, camera fading, and platform timing.
11
+ *
12
+ * All declarations are global — no import required.
13
+ *
14
+ * @module types/server/functions
15
+ * @see https://wiki.gtaconnected.com — GTA Connected Wiki
16
+ *
17
+ * @example
18
+ * // Send a message to all players
19
+ * message("Welcome to the server!", COLOUR_GREEN);
20
+ *
21
+ * @example
22
+ * // Spawn a vehicle on the server
23
+ * const car = gta.createVehicle(141, 0, 0, 10, 0, 0, 0);
24
+ */
25
+
26
+ // ===== Network Events =====
27
+
28
+ /**
29
+ * Registers a handler for a custom network event triggered by clients.
30
+ * The handler receives the triggering `Client` as the first argument,
31
+ * followed by any additional data sent by the client.
32
+ *
33
+ * @param name - Network event name to listen for.
34
+ * @param handler - Callback receiving the triggering `Client` and any additional arguments.
35
+ *
36
+ * @example
37
+ * addNetworkHandler("onPlayerRequestSpawn", function(client, skinId) {
38
+ * spawnPlayer(client, new Vec3(0, 0, 10), 0, skinId);
39
+ * });
40
+ */
41
+ declare function addNetworkHandler(
42
+ name: string,
43
+ handler: (client: Client, ...args: any[]) => void
44
+ ): void;
45
+
46
+ /**
47
+ * Sends a custom network event to a specific client or all clients.
48
+ * Pass `null` as the client parameter to broadcast to all connected clients.
49
+ *
50
+ * @param name - Network event name to trigger.
51
+ * @param client - Target `Client`, or `null` to broadcast to everyone.
52
+ * @param args - Any number of additional arguments to send with the event.
53
+ *
54
+ * @example
55
+ * // Send to one client
56
+ * triggerNetworkEvent("onPlayerData", client, playerData);
57
+ *
58
+ * @example
59
+ * // Broadcast to all clients
60
+ * triggerNetworkEvent("onWeatherChange", null, newWeatherId);
61
+ */
62
+ declare function triggerNetworkEvent(
63
+ name: string,
64
+ client: Client | null,
65
+ ...args: any[]
66
+ ): void;
67
+
68
+ // ===== Command Handlers =====
69
+
70
+ /**
71
+ * Registers a handler for a chat command (e.g. `/cmd`).
72
+ * The handler receives the command name, the text after the command,
73
+ * and the `Client` who issued the command.
74
+ *
75
+ * @param name - Command name without the leading slash (e.g. `"help"`, `"kill"`).
76
+ * @param handler - Callback receiving (command, text, client).
77
+ *
78
+ * @example
79
+ * addCommandHandler("heal", function(cmd, text, client) {
80
+ * if (client.player) {
81
+ * client.player.health = 100;
82
+ * messageClient("You have been healed!", client, COLOUR_GREEN);
83
+ * }
84
+ * });
85
+ */
86
+ declare function addCommandHandler(
87
+ name: string,
88
+ handler: (cmd: string, text: string, client: Client) => void
89
+ ): void;
90
+
91
+ /**
92
+ * Checks whether a command handler is registered for a given name.
93
+ *
94
+ * @param name - Command name to check.
95
+ * @returns `true` if a handler is registered for this command.
96
+ */
97
+ declare function hasCommandHandler(name: string): boolean;
98
+
99
+ /**
100
+ * Removes a previously registered command handler.
101
+ *
102
+ * @param name - Command name to unregister.
103
+ */
104
+ declare function removeCommandHandler(name: string): void;
105
+
106
+ /**
107
+ * Executes a server console command programmatically.
108
+ *
109
+ * @param cmd - Command string to execute (as if typed in the server console).
110
+ */
111
+ declare function consoleCommand(cmd: string): void;
112
+
113
+ // ===== Client Queries =====
114
+
115
+ /**
116
+ * Finds a client by their display name (case-insensitive).
117
+ *
118
+ * @param name - Client display name to search for.
119
+ * @returns The matching `Client`, or `null` if no client has that name.
120
+ */
121
+ declare function getClient(name: string): Client | null;
122
+
123
+ /**
124
+ * Gets the `Client` object associated with a `Player` element.
125
+ *
126
+ * @param player - The `Player` element to look up.
127
+ * @returns The `Client` controlling that player.
128
+ */
129
+ declare function getClientFromPlayerElement(player: Player): Client;
130
+
131
+ /**
132
+ * Returns all currently connected clients.
133
+ *
134
+ * @returns Array of all `Client` instances.
135
+ */
136
+ declare function getClients(): Client[];
137
+
138
+ /**
139
+ * The server's own local client (console/shell).
140
+ * This represents the server console as a client for messaging purposes.
141
+ */
142
+ declare var localClient: Client;
143
+
144
+ // ===== Element Functions =====
145
+
146
+ /**
147
+ * Destroys an element, removing it from the game world and freeing resources.
148
+ *
149
+ * @param element - The element to destroy.
150
+ *
151
+ * @example
152
+ * // Clean up a blip when a mission ends
153
+ * destroyElement(missionBlip);
154
+ */
155
+ declare function destroyElement(element: Element): void;
156
+
157
+ /**
158
+ * Finds an element by its unique numeric ID.
159
+ *
160
+ * @param id - The element's numeric ID.
161
+ * @returns The matching `Element`, or `null` if no element has that ID.
162
+ */
163
+ declare function getElementFromId(id: number): Element | null;
164
+
165
+ /**
166
+ * Finds an element by its display name.
167
+ *
168
+ * @param name - The element name to search for.
169
+ * @returns The matching `Element`, or `null` if not found.
170
+ */
171
+ declare function getElementFromName(name: string): Element | null;
172
+
173
+ /**
174
+ * Gets all elements of a specific type.
175
+ *
176
+ * @param type - Element type string (e.g. `"player"`, `"vehicle"`, `"blip"`).
177
+ * @returns Array of matching `Element` instances.
178
+ */
179
+ declare function getElementsByType(type: string): Element[];
180
+
181
+ // ===== Blip Functions =====
182
+
183
+ /** Returns the total number of blips on the server. */
184
+ declare function getBlipCount(): number;
185
+
186
+ /** Returns all blip elements. @returns Array of `Blip`. */
187
+ declare function getBlips(): Blip[];
188
+
189
+ // ===== Building Functions =====
190
+
191
+ /** Returns the total number of buildings on the server. */
192
+ declare function getBuildingCount(): number;
193
+
194
+ /** Returns all building elements. @returns Array of `Building`. */
195
+ declare function getBuildings(): Building[];
196
+
197
+ // ===== Object Functions =====
198
+
199
+ /** Returns the total number of objects on the server. */
200
+ declare function getObjectCount(): number;
201
+
202
+ /** Returns all object elements. @returns Array of `Object`. */
203
+ declare function getObjects(): Object[];
204
+
205
+ // ===== Ped Functions =====
206
+
207
+ /** Returns the total number of peds on the server. */
208
+ declare function getPedCount(): number;
209
+
210
+ /** Returns all ped elements. @returns Array of `Ped`. */
211
+ declare function getPeds(): Ped[];
212
+
213
+ // ===== Pickup Functions =====
214
+
215
+ /** Returns the total number of pickups on the server. */
216
+ declare function getPickupCount(): number;
217
+
218
+ /** Returns all pickup elements. @returns Array of `Pickup`. */
219
+ declare function getPickups(): Pickup[];
220
+
221
+ // ===== Player Functions =====
222
+
223
+ /** Returns the total number of connected players. */
224
+ declare function getPlayerCount(): number;
225
+
226
+ /** Returns all player elements. @returns Array of `Player`. */
227
+ declare function getPlayers(): Player[];
228
+
229
+ /**
230
+ * Returns a random connected player, or `null` if no players are connected.
231
+ * Useful for picking a random target for events.
232
+ *
233
+ * @returns A random `Player`, or `null` if none exist.
234
+ */
235
+ declare function getRandomPlayer(): Player | null;
236
+
237
+ // ===== Vehicle Functions =====
238
+
239
+ /** Returns the total number of vehicles on the server. */
240
+ declare function getVehicleCount(): number;
241
+
242
+ /** Returns all vehicle elements. @returns Array of `Vehicle`. */
243
+ declare function getVehicles(): Vehicle[];
244
+
245
+ // ===== Messaging =====
246
+
247
+ /**
248
+ * Sends a message to all connected clients, displayed in their chat window.
249
+ *
250
+ * @param text - The message text to send.
251
+ * @param colour - Optional colour as a packed number (default: white).
252
+ *
253
+ * @example
254
+ * message("Server restart in 5 minutes!", COLOUR_RED);
255
+ */
256
+ declare function message(text: string, colour?: number): void;
257
+
258
+ /**
259
+ * Sends a message to all clients except one.
260
+ * Useful for broadcasting messages like "X has joined" without sending
261
+ * to the player who joined.
262
+ *
263
+ * @param client - The client to exclude from the broadcast.
264
+ * @param message - The message text to send.
265
+ *
266
+ * @example
267
+ * addEventHandler("OnPlayerJoin", function(client) {
268
+ * messageAllExcept(client, client.name + " has joined the server!");
269
+ * });
270
+ */
271
+ declare function messageAllExcept(client: Client, message: string): void;
272
+
273
+ /**
274
+ * Sends a private message to a specific client.
275
+ *
276
+ * @param text - The message text.
277
+ * @param client - The target client to send the message to.
278
+ * @param colour - Optional colour as a packed number.
279
+ *
280
+ * @example
281
+ * messageClient("Welcome back!", client, COLOUR_GREEN);
282
+ */
283
+ declare function messageClient(
284
+ text: string,
285
+ client: Client,
286
+ colour?: number
287
+ ): void;
288
+
289
+ // ===== Key Binding =====
290
+
291
+ /**
292
+ * Binds a key to a handler function on the server.
293
+ * The handler receives a `KeyEvent` with press/release and key code info.
294
+ *
295
+ * @param key - Key name to bind (e.g. `"F1"`, `"Escape"`, `"T"`).
296
+ * @param handler - Callback invoked with a `KeyEvent` when the key action occurs.
297
+ *
298
+ * @example
299
+ * bindKey("F1", function(event) {
300
+ * if (!event.isUp()) {
301
+ * message("F1 was pressed!");
302
+ * }
303
+ * });
304
+ */
305
+ declare function bindKey(
306
+ key: string,
307
+ handler: (keyEvent: KeyEvent) => void
308
+ ): void;
309
+
310
+ /**
311
+ * Unbinds a previously bound key, removing its handler.
312
+ *
313
+ * @param key - The key name to unbind.
314
+ */
315
+ declare function unbindKey(key: string): void;
316
+
317
+ // ===== Resource Functions =====
318
+
319
+ /**
320
+ * Gets a loaded resource by its name.
321
+ *
322
+ * @param name - Resource name (as defined in meta.xml).
323
+ * @returns The matching `Resource`, or `null` if not found.
324
+ */
325
+ declare function getResource(name: string): Resource | null;
326
+
327
+ /**
328
+ * Gets all currently loaded resources.
329
+ *
330
+ * @returns Array of all `Resource` instances.
331
+ */
332
+ declare function getResources(): Resource[];
333
+
334
+ /**
335
+ * Gets the current (calling) resource.
336
+ *
337
+ * @returns The `Resource` this script belongs to.
338
+ */
339
+ declare function getThisResource(): Resource;
340
+
341
+ // ===== Server Functions =====
342
+
343
+ /**
344
+ * Returns the server's listening port number.
345
+ *
346
+ * @returns The port number the server is listening on.
347
+ */
348
+ declare function getServerPort(): number;
349
+
350
+ /**
351
+ * Returns the server's game identifier string.
352
+ * Example: `"gta:vc"` for GTA Vice City.
353
+ *
354
+ * @returns Game identifier string.
355
+ */
356
+ declare function getServerGame(): string;
357
+
358
+ /**
359
+ * Returns the server's display name (shown in server browsers).
360
+ *
361
+ * @returns The current server name.
362
+ */
363
+ declare function getServerName(): string;
364
+
365
+ /**
366
+ * Sets the server's display name.
367
+ *
368
+ * @param name - The new server name.
369
+ */
370
+ declare function setServerName(name: string): void;
371
+
372
+ /**
373
+ * Sets the server password. Clients must provide this password to connect.
374
+ *
375
+ * @param pass - The new password. Pass an empty string `""` to remove the password requirement.
376
+ */
377
+ declare function setServerPassword(pass: string): void;
378
+
379
+ // ===== Network Stats =====
380
+
381
+ /**
382
+ * Returns network statistics for the server.
383
+ *
384
+ * @returns An object containing network performance metrics (bytes sent/received, packet counts, etc.).
385
+ */
386
+ declare function getNetworkStats(): object;
387
+
388
+ /**
389
+ * Returns the current packet loss percentage.
390
+ *
391
+ * @returns Packet loss as a numeric percentage (0.0 = no loss, 100.0 = all lost).
392
+ */
393
+ declare function getPacketLoss(): number;
394
+
395
+ // ===== HTTP =====
396
+
397
+ /**
398
+ * Represents an HTTP request handle (opaque type).
399
+ * Returned by `http.createRequest()`, used for configuring and sending HTTP requests.
400
+ */
401
+ type HTTPRequest = {}
402
+
403
+ /**
404
+ * HTTP request API for making web requests from the server.
405
+ * Supports creating requests, GET, and POST operations with callback-based responses.
406
+ *
407
+ * @example
408
+ * // Simple GET request
409
+ * http.get("https://api.example.com/data", function(data) {
410
+ * console.log("Response: " + data);
411
+ * });
412
+ *
413
+ * @example
414
+ * // POST request with JSON
415
+ * http.post("https://api.example.com/submit", '{"key":"value"}', function(data) {
416
+ * console.log("Server responded: " + data);
417
+ * });
418
+ */
419
+ declare var http: {
420
+ /**
421
+ * Creates an HTTP request handle for advanced request configuration.
422
+ *
423
+ * @param url - The request URL.
424
+ * @returns An `HTTPRequest` handle for further configuration before sending.
425
+ */
426
+ createRequest(url: string): HTTPRequest;
427
+
428
+ /**
429
+ * Sends a GET request to the specified URL.
430
+ *
431
+ * @param url - The request URL.
432
+ * @param callback - Callback invoked with the response body string when the request completes.
433
+ */
434
+ get(url: string, callback: (data: string) => void): void;
435
+
436
+ /**
437
+ * Sends a POST request with a body to the specified URL.
438
+ *
439
+ * @param url - The request URL.
440
+ * @param data - The POST body data (typically JSON or form-encoded).
441
+ * @param callback - Callback invoked with the response body string when the request completes.
442
+ */
443
+ post(url: string, data: string, callback: (data: string) => void): void;
444
+ };
445
+
446
+ // ===== File I/O =====
447
+
448
+ /**
449
+ * Checks whether a file exists on disk.
450
+ *
451
+ * @param path - File path (relative to resource root or absolute).
452
+ * @returns `true` if the file exists and is accessible.
453
+ */
454
+ declare function fileExists(path: string): boolean;
455
+
456
+ /**
457
+ * Opens a file for reading and/or writing.
458
+ *
459
+ * @param path - File path to open.
460
+ * @returns A `FileObject` handle, or `null` if the file could not be opened.
461
+ */
462
+ declare function fileOpen(path: string): FileObject | null;
463
+
464
+ /**
465
+ * Closes an open file handle.
466
+ *
467
+ * @param file - The `FileObject` to close.
468
+ */
469
+ declare function fileClose(file: FileObject): void;
470
+
471
+ /**
472
+ * Reads the entire remaining content of an open file.
473
+ *
474
+ * @param file - The `FileObject` to read from.
475
+ * @returns The file content as a string.
476
+ */
477
+ declare function fileRead(file: FileObject): string;
478
+
479
+ /**
480
+ * Writes data to an open file (appends at the current position).
481
+ *
482
+ * @param file - The `FileObject` to write to.
483
+ * @param data - The string data to write.
484
+ */
485
+ declare function fileWrite(file: FileObject, data: string): void;
486
+
487
+ /**
488
+ * Deletes a file from disk permanently.
489
+ *
490
+ * @param path - The file path to delete.
491
+ * @returns `true` if the file was successfully deleted, `false` on failure.
492
+ */
493
+ declare function fileDelete(path: string): boolean;
494
+
495
+ /**
496
+ * Gets the size of an open file in bytes.
497
+ *
498
+ * @param file - The `FileObject` to query.
499
+ * @returns The file size in bytes.
500
+ */
501
+ declare function fileGetSize(file: FileObject): number;
502
+
503
+ /**
504
+ * Gets the absolute path of an open file.
505
+ *
506
+ * @param file - The `FileObject` to query.
507
+ * @returns The absolute file path as a string.
508
+ */
509
+ declare function fileGetPath(file: FileObject): string;
510
+
511
+ /**
512
+ * Loads the complete text content of a file into memory.
513
+ * Convenience function — opens, reads, and closes the file in one call.
514
+ *
515
+ * @param path - File path to load.
516
+ * @returns The file content as a string, or `null` if the file could not be loaded.
517
+ */
518
+ declare function loadTextFile(path: string): string | null;
519
+
520
+ /**
521
+ * Saves text content to a file, overwriting any existing content.
522
+ *
523
+ * @param path - File path to save to.
524
+ * @param content - The text content to write.
525
+ * @returns `true` on success, `false` on failure.
526
+ */
527
+ declare function saveTextFile(path: string, content: string): boolean;
528
+
529
+ // ===== Game (gta) - Server-Side =====
530
+
531
+ /**
532
+ * Server-side GTA world manipulation API.
533
+ * Provides methods for creating and managing game world elements (blips,
534
+ * buildings, markers, objects, peds, pickups, vehicles), controlling time
535
+ * and weather, camera effects, and world physics.
536
+ *
537
+ * Note: The server-side `gta` is more limited than the client-side version
538
+ * — some properties only exist on the client.
539
+ *
540
+ * @see https://wiki.gtaconnected.com — GTA Connected Wiki
541
+ */
542
+ declare var gta: {
543
+ // -- Time --
544
+
545
+ /**
546
+ * Current in-game time as `{ hour, minute }`.
547
+ * Server-side time is synchronised to all clients.
548
+ *
549
+ * @example
550
+ * // Check if it's night
551
+ * if (gta.time.hour >= 20 || gta.time.hour < 6) {
552
+ * message("It's nighttime!");
553
+ * }
554
+ */
555
+ time: { hour: number; minute: number };
556
+
557
+ // -- Blips --
558
+
559
+ /**
560
+ * Creates a radar blip at a world position (server-side).
561
+ * Note: Server-side blip creation does not support colour or size parameters.
562
+ * Use client-side blip functions for custom colours and sizes.
563
+ *
564
+ * @param x - X coordinate.
565
+ * @param y - Y coordinate.
566
+ * @param z - Z coordinate.
567
+ * @param icon - Blip icon ID (see Icon enum).
568
+ * @param dimension - Dimension ID for the blip.
569
+ * @returns The created `Blip`.
570
+ */
571
+ createBlip(
572
+ x: number,
573
+ y: number,
574
+ z: number,
575
+ icon: number,
576
+ dimension: number
577
+ ): Blip;
578
+
579
+ /**
580
+ * Creates a blip attached to an element (server-side).
581
+ * The blip will follow the element's position automatically.
582
+ *
583
+ * @param element - The element to attach the blip to.
584
+ * @param icon - Blip icon ID (see Icon enum).
585
+ * @returns The created `Blip`.
586
+ */
587
+ createBlipAttachedTo(element: Element, icon: number): Blip;
588
+
589
+ // -- Buildings --
590
+
591
+ /**
592
+ * Creates a static building element on the server.
593
+ *
594
+ * @param model - Building model ID.
595
+ * @param x - X position.
596
+ * @param y - Y position.
597
+ * @param z - Z position.
598
+ * @param rx - X rotation (pitch) in degrees.
599
+ * @param ry - Y rotation (roll) in degrees.
600
+ * @param rz - Z rotation (yaw) in degrees.
601
+ * @returns The created `Building`.
602
+ */
603
+ createBuilding(
604
+ model: number,
605
+ x: number,
606
+ y: number,
607
+ z: number,
608
+ rx: number,
609
+ ry: number,
610
+ rz: number
611
+ ): Building;
612
+
613
+ // -- Camera --
614
+
615
+ /**
616
+ * Fades the camera in or out for all clients.
617
+ *
618
+ * @param fade - Fade direction: `FADE_IN` (show) or `FADE_OUT` (hide).
619
+ * @param duration - Duration of the fade in milliseconds.
620
+ * @param args - Additional arguments (e.g. fade colour).
621
+ */
622
+ fadeCamera(fade: number, duration: number, ...args: any[]): void;
623
+
624
+ // -- Markers --
625
+
626
+ /**
627
+ * Creates a 3D world marker at the specified position.
628
+ *
629
+ * @param x - X coordinate.
630
+ * @param y - Y coordinate.
631
+ * @param z - Z coordinate.
632
+ * @param type - Marker type (cylinder, arrow, checkpoint ring, etc.).
633
+ * @param size - Marker size/diameter in world units.
634
+ * @param r - Red colour component (0–255).
635
+ * @param g - Green colour component (0–255).
636
+ * @param b - Blue colour component (0–255).
637
+ * @param a - Alpha/opacity component (0–255).
638
+ * @returns The created `Marker`.
639
+ */
640
+ createMarker(
641
+ x: number,
642
+ y: number,
643
+ z: number,
644
+ type: number,
645
+ size: number,
646
+ r: number,
647
+ g: number,
648
+ b: number,
649
+ a: number
650
+ ): Marker;
651
+
652
+ // -- Objects --
653
+
654
+ /**
655
+ * Creates a placeable object on the server.
656
+ *
657
+ * @param model - Object model ID.
658
+ * @param x - X position.
659
+ * @param y - Y position.
660
+ * @param z - Z position.
661
+ * @param rx - X rotation (pitch) in degrees.
662
+ * @param ry - Y rotation (roll) in degrees.
663
+ * @param rz - Z rotation (yaw) in degrees.
664
+ * @returns The created `Object`.
665
+ */
666
+ createObject(
667
+ model: number,
668
+ x: number,
669
+ y: number,
670
+ z: number,
671
+ rx: number,
672
+ ry: number,
673
+ rz: number
674
+ ): Object;
675
+
676
+ // -- Peds --
677
+
678
+ /**
679
+ * Creates a pedestrian (AI character) on the server.
680
+ *
681
+ * @param model - Ped model/skin ID (see PedSkin enum).
682
+ * @param x - X position.
683
+ * @param y - Y position.
684
+ * @param z - Z position.
685
+ * @param rz - Z rotation (heading) in degrees.
686
+ * @returns The created `Ped`.
687
+ */
688
+ createPed(model: number, x: number, y: number, z: number, rz: number): Ped;
689
+
690
+ // -- Pickups --
691
+
692
+ /**
693
+ * Creates a collectible pickup on the server.
694
+ *
695
+ * @param model - Pickup model ID (see PickupModel enum).
696
+ * @param type - Pickup type constant.
697
+ * @param x - X position.
698
+ * @param y - Y position.
699
+ * @param z - Z position.
700
+ * @returns The created `Pickup`.
701
+ */
702
+ createPickup(
703
+ model: number,
704
+ type: number,
705
+ x: number,
706
+ y: number,
707
+ z: number
708
+ ): Pickup;
709
+
710
+ // -- Vehicles --
711
+
712
+ /**
713
+ * Creates a vehicle on the server at a position with optional colours.
714
+ *
715
+ * @param model - Vehicle model ID (see VehicleModel enum).
716
+ * @param x - X position.
717
+ * @param y - Y position.
718
+ * @param z - Z position.
719
+ * @param rz - Z rotation (heading) in degrees.
720
+ * @param c1 - Primary colour ID (optional).
721
+ * @param c2 - Secondary colour ID (optional).
722
+ * @returns The created `Vehicle`.
723
+ *
724
+ * @example
725
+ * const infernus = gta.createVehicle(141, 0, 0, 10, 0, 0, 0);
726
+ * message("Infernus spawned!");
727
+ */
728
+ createVehicle(
729
+ model: number,
730
+ x: number,
731
+ y: number,
732
+ z: number,
733
+ rz: number,
734
+ c1?: number,
735
+ c2?: number
736
+ ): Vehicle;
737
+
738
+ /**
739
+ * Creates a vehicle at a Vec3 position (convenience overload).
740
+ *
741
+ * @param model - Vehicle model ID.
742
+ * @param position - World position as a `Vec3`.
743
+ * @returns The created `Vehicle`, or `null` on failure.
744
+ */
745
+ createVehicle(model: number, position: Vec3): Vehicle | null;
746
+
747
+ // -- Time --
748
+
749
+ /**
750
+ * Gets the real-time duration of one in-game minute in milliseconds.
751
+ *
752
+ * @returns Duration in milliseconds (default: 1000 for a 24-minute game day).
753
+ */
754
+ getMinuteDuration(): number;
755
+
756
+ /**
757
+ * Sets the real-time duration of one in-game minute.
758
+ * Affects how fast the in-game clock advances.
759
+ *
760
+ * @param ms - Duration per in-game minute in milliseconds.
761
+ */
762
+ setMinuteDuration(ms: number): void;
763
+
764
+ /**
765
+ * Gets the current in-game time.
766
+ *
767
+ * @returns Object with `hour` (0–23) and `minute` (0–59).
768
+ */
769
+ getTime(): { hour: number; minute: number };
770
+
771
+ /**
772
+ * Sets the in-game time (synchronised to all clients).
773
+ *
774
+ * @param h - Hour (0–23).
775
+ * @param m - Minute (0–59).
776
+ */
777
+ setTime(h: number, m: number): void;
778
+
779
+ // -- Weather --
780
+
781
+ /**
782
+ * Gets the current weather ID.
783
+ *
784
+ * @returns Weather ID (0 = sunny, 1 = cloudy, 2 = rainy, 3 = foggy).
785
+ */
786
+ getWeather(): number;
787
+
788
+ /**
789
+ * Sets the current weather immediately (synchronised to all clients).
790
+ *
791
+ * @param weather - Weather ID to apply.
792
+ */
793
+ setWeather(weather: number): void;
794
+
795
+ /**
796
+ * Smoothly blends between two weather states over time.
797
+ *
798
+ * @param w1 - Source weather ID.
799
+ * @param w2 - Target weather ID.
800
+ * @param percent - Blend percentage (0.0 = all source, 1.0 = all target).
801
+ */
802
+ setWeatherBlend(w1: number, w2: number, percent: number): void;
803
+
804
+ // -- World --
805
+
806
+ /**
807
+ * Gets the current global gravity multiplier.
808
+ *
809
+ * @returns Gravity value (default ~0.008).
810
+ */
811
+ getGravity(): number;
812
+
813
+ /**
814
+ * Sets the global gravity multiplier (affects all clients).
815
+ *
816
+ * @param g - Gravity value (0.008 = normal, 0.002 = moon-like).
817
+ */
818
+ setGravity(g: number): void;
819
+
820
+ /**
821
+ * Gets the current game speed multiplier.
822
+ *
823
+ * @returns Game speed (1.0 = normal).
824
+ */
825
+ getGameSpeed(): number;
826
+
827
+ /**
828
+ * Sets the game speed multiplier (affects all clients).
829
+ *
830
+ * @param speed - Speed value (1.0 = normal, 2.0 = double, 0.5 = slow motion).
831
+ */
832
+ setGameSpeed(speed: number): void;
833
+ };
834
+
835
+ // ===== Player Spawning (Legacy API) =====
836
+
837
+ /**
838
+ * Spawns a player at a specified position with a given skin and rotation.
839
+ *
840
+ * @param client - The target client to spawn a player for.
841
+ * @param position - Spawn position as a `Vec3` or `[x, y, z]` array.
842
+ * @param rotation - Spawn heading/rotation in degrees.
843
+ * @param skin - Player skin/model ID (see PedSkin enum).
844
+ *
845
+ * @example
846
+ * // Spawn a new player at the default position
847
+ * addEventHandler("OnPlayerJoin", function(client) {
848
+ * spawnPlayer(client, new Vec3(0, 0, 10), 0, 0);
849
+ * });
850
+ */
851
+ declare function spawnPlayer(
852
+ client: Client,
853
+ position: Vec3 | number[],
854
+ rotation: number,
855
+ skin: number
856
+ ): void;
857
+
858
+ /**
859
+ * Fades the camera for a specific client.
860
+ *
861
+ * @param client - The target client.
862
+ * @param state - `true` to fade in (show), `false` to fade out (hide).
863
+ * @param duration - Optional fade duration in milliseconds.
864
+ *
865
+ * @example
866
+ * // Fade out, teleport, fade in
867
+ * fadeCamera(client, false, 1000);
868
+ * setTimeout(function() {
869
+ * client.player.position = new Vec3(100, 200, 10);
870
+ * fadeCamera(client, true, 1000);
871
+ * }, 1000);
872
+ */
873
+ declare function fadeCamera(
874
+ client: Client,
875
+ state: boolean,
876
+ duration?: number
877
+ ): void;
878
+
879
+ // ===== Platform =====
880
+
881
+ /**
882
+ * Platform-level timing information for the server.
883
+ */
884
+ declare var platform: {
885
+ /**
886
+ * High-resolution tick count in milliseconds since the server started.
887
+ * Use for delta-time calculations, uptime tracking, and performance metrics.
888
+ */
889
+ ticks: number;
890
+ };