@nativewrappers/server 0.0.64 → 0.0.72

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.
Files changed (52) hide show
  1. package/README.md +45 -0
  2. package/cfx/StateBagChangeHandler.d.ts +1 -3
  3. package/common/Command.d.ts +30 -0
  4. package/common/Convar.d.ts +13 -0
  5. package/common/GlobalData.d.ts +8 -0
  6. package/common/Kvp.d.ts +69 -0
  7. package/common/Resource.d.ts +14 -0
  8. package/common/decors/Events.d.ts +54 -0
  9. package/common/index.d.ts +8 -0
  10. package/common/net/NetworkedMap.d.ts +28 -0
  11. package/common/types.d.ts +5 -0
  12. package/common/utils/ClassTypes.d.ts +11 -0
  13. package/common/utils/Color.d.ts +14 -0
  14. package/common/utils/Maths.d.ts +4 -0
  15. package/common/utils/PointF.d.ts +12 -0
  16. package/common/utils/Quaternion.d.ts +10 -0
  17. package/common/utils/Vector.d.ts +429 -0
  18. package/common/utils/Vector2.d.ts +1 -0
  19. package/common/utils/Vector3.d.ts +1 -0
  20. package/common/utils/Vector4.d.ts +1 -0
  21. package/common/utils/cleanPlayerName.d.ts +6 -0
  22. package/common/utils/enumValues.d.ts +12 -0
  23. package/common/utils/getStringFromUInt8Array.d.ts +8 -0
  24. package/common/utils/getUInt32FromUint8Array.d.ts +8 -0
  25. package/common/utils/index.d.ts +12 -0
  26. package/entities/BaseEntity.d.ts +3 -3
  27. package/entities/Ped.d.ts +1 -1
  28. package/entities/Vehicle.d.ts +3 -3
  29. package/index.d.ts +1 -1
  30. package/index.js +1807 -7
  31. package/package.json +7 -5
  32. package/type/Anticheat.d.ts +1 -1
  33. package/utils/index.d.ts +1 -1
  34. package/Events.js +0 -79
  35. package/Game.js +0 -55
  36. package/cfx/StateBagChangeHandler.js +0 -1
  37. package/cfx/index.js +0 -1
  38. package/entities/BaseEntity.js +0 -135
  39. package/entities/Entity.js +0 -12
  40. package/entities/Ped.js +0 -81
  41. package/entities/Player.js +0 -136
  42. package/entities/Prop.js +0 -32
  43. package/entities/Vehicle.js +0 -175
  44. package/entities/index.js +0 -5
  45. package/enum/PopulationType.js +0 -14
  46. package/enum/VehicleLockStatus.js +0 -10
  47. package/enum/VehicleType.js +0 -11
  48. package/enum/eEntityType.js +0 -6
  49. package/enum/index.js +0 -4
  50. package/type/Anticheat.js +0 -1
  51. package/type/Hash.js +0 -1
  52. package/utils/index.js +0 -1
package/index.js CHANGED
@@ -1,7 +1,1807 @@
1
- export * from "./utils";
2
- export * from "./Events";
3
- export * from "./Game";
4
- export { Convar, Kvp, Resource, Command } from "../common/index";
5
- export * from "./utils/index";
6
- export * from "./entities/index";
7
- export * from "./cfx/index";
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/common/utils/Vector.ts
5
+ var EXT_VECTOR2 = 20;
6
+ var EXT_VECTOR3 = 21;
7
+ var EXT_VECTOR4 = 22;
8
+ var size = Symbol("size");
9
+ var Vector = class _Vector {
10
+ static {
11
+ __name(this, "Vector");
12
+ }
13
+ static create(x, y = x, z, w) {
14
+ if (typeof x === "object") ({ x, y, z, w } = x);
15
+ const size2 = this instanceof _Vector && this.size || [x, y, z, w].filter((arg) => arg !== void 0).length;
16
+ switch (size2) {
17
+ case 1:
18
+ case 2:
19
+ return new Vector2(x, y);
20
+ case 3:
21
+ return new Vector3(x, y, z);
22
+ case 4:
23
+ return new Vector4(x, y, z, w);
24
+ default:
25
+ throw new Error(`Cannot instantiate Vector with size of ${size2}.`);
26
+ }
27
+ }
28
+ /**
29
+ * Creates a deep copy of the provided vector.
30
+ * @param obj The vector to clone.
31
+ * @returns A new vector instance that is a copy of the provided vector.
32
+ */
33
+ static clone(obj) {
34
+ return this.create(obj);
35
+ }
36
+ /**
37
+ * Creates a vector from binary data in a MsgpackBuffer.
38
+ * @param msgpackBuffer The buffer containing binary data.
39
+ * @returns A new vector instance.
40
+ */
41
+ static fromBuffer({ buffer, type }) {
42
+ if (type !== EXT_VECTOR2 && type !== EXT_VECTOR3 && type !== EXT_VECTOR4)
43
+ throw new Error("Buffer type is not a valid Vector.");
44
+ const arr = new Array(buffer.length / 4);
45
+ for (let i = 0; i < arr.length; i++)
46
+ arr[i] = Number(buffer.readFloatLE(i * 4).toPrecision(7));
47
+ return this.fromArray(arr);
48
+ }
49
+ /**
50
+ * Performs an operation between a vector and either another vector or scalar value.
51
+ * @param a - The first vector.
52
+ * @param b - The second vector or scalar value.
53
+ * @param operator - The function defining the operation to perform.
54
+ * @returns A new vector resulting from the operation.
55
+ */
56
+ static operate(a, b, operator) {
57
+ let { x, y, z, w } = a;
58
+ const isNumber = typeof b === "number";
59
+ x = operator(x, isNumber ? b : b.x ?? 0);
60
+ y = operator(y, isNumber ? b : b.y ?? 0);
61
+ if (z !== void 0) z = operator(z, isNumber ? b : b.z ?? 0);
62
+ if (w !== void 0) w = operator(w, isNumber ? b : b.w ?? 0);
63
+ return this.create(x, y, z, w);
64
+ }
65
+ /**
66
+ * Adds two vectors or a scalar value to a vector.
67
+ * @param a - The first vector or scalar value.
68
+ * @param b - The second vector or scalar value.
69
+ * @returns A new vector with incremented components.
70
+ */
71
+ static add(a, b) {
72
+ return this.operate(a, b, (x, y) => x + y);
73
+ }
74
+ /**
75
+ * Adds a scalar value to the x-component of a vector.
76
+ * @param obj - The vector.
77
+ * @param x - The value to add to the x-component.
78
+ * @returns A new vector with the x-component incremented.
79
+ */
80
+ static addX(obj, x) {
81
+ return this.create(obj.x + x, obj.y, obj.z, obj.w);
82
+ }
83
+ /**
84
+ * Adds a scalar value to the y-component of a vector.
85
+ * @param obj - The vector.
86
+ * @param y - The value to add to the y-component.
87
+ * @returns A new vector with the y-component incremented.
88
+ */
89
+ static addY(obj, y) {
90
+ return this.create(obj.x, obj.y + y, obj.z, obj.w);
91
+ }
92
+ /**
93
+ * Adds a scalar value to the z-component of a vector.
94
+ * @param obj - The vector.
95
+ * @param z - The value to add to the z-component.
96
+ * @returns A new vector with the z-component incremented.
97
+ */
98
+ static addZ(obj, z) {
99
+ return this.create(
100
+ obj.x,
101
+ obj.y,
102
+ obj.z + z,
103
+ obj.w
104
+ );
105
+ }
106
+ /**
107
+ * Adds a scalar value to the w-component of a vector.
108
+ * @param obj - The vector.
109
+ * @param w - The value to add to the w-component.
110
+ * @returns A new vector with the w-component incremented.
111
+ */
112
+ static addW(obj, w) {
113
+ return this.create(obj.x, obj.y, obj.z, obj.w + w);
114
+ }
115
+ /**
116
+ * Subtracts one vector from another or subtracts a scalar value from a vector.
117
+ * @param a - The vector.
118
+ * @param b - The second vector or scalar value.
119
+ * @returns A new vector with subtracted components.
120
+ */
121
+ static subtract(a, b) {
122
+ return this.operate(a, b, (x, y) => x - y);
123
+ }
124
+ /**
125
+ * Multiplies two vectors by their components, or multiplies a vector by a scalar value.
126
+ * @param a - The vector.
127
+ * @param b - The second vector or scalar value.
128
+ * @returns A new vector with multiplied components.
129
+ */
130
+ static multiply(a, b) {
131
+ return this.operate(a, b, (x, y) => x * y);
132
+ }
133
+ /**
134
+ * Divides two vectors by their components, or divides a vector by a scalar value.
135
+ * @param a - The vector.
136
+ * @param b - The second vector or scalar vector.
137
+ * @returns A new vector with divided components.
138
+ */
139
+ static divide(a, b) {
140
+ return this.operate(a, b, (x, y) => x / y);
141
+ }
142
+ /**
143
+ * Performs an operation between a vector and either another vector or scalar value converting the vector into absolute values.
144
+ * @param a - The first vector.
145
+ * @param b - The second vector or scalar value.
146
+ * @param operator - The function defining the operation to perform.
147
+ * @returns A new vector resulting from the operation.
148
+ */
149
+ static operateAbsolute(a, b, operator) {
150
+ let { x, y, z, w } = a;
151
+ const isNumber = typeof b === "number";
152
+ x = operator(Math.abs(x), isNumber ? b : Math.abs(b.x ?? 0));
153
+ y = operator(Math.abs(y), isNumber ? b : Math.abs(b.y ?? 0));
154
+ if (z !== void 0)
155
+ z = operator(Math.abs(z), isNumber ? b : Math.abs(b.z ?? 0));
156
+ if (w !== void 0)
157
+ w = operator(Math.abs(w), isNumber ? b : Math.abs(b.w ?? 0));
158
+ return this.create(x, y, z, w);
159
+ }
160
+ /**
161
+ * Adds two vectors or a scalar value to a vector.
162
+ * @param a - The first vector or scalar value.
163
+ * @param b - The second vector or scalar value.
164
+ * @returns A new vector with incremented components.
165
+ */
166
+ static addAbsolute(a, b) {
167
+ return this.operateAbsolute(a, b, (x, y) => x + y);
168
+ }
169
+ /**
170
+ * Subtracts one vector from another or subtracts a scalar value from a vector.
171
+ * @param a - The vector.
172
+ * @param b - The second vector or scalar value.
173
+ * @returns A new vector with subtracted components.
174
+ */
175
+ static subtractAbsolute(a, b) {
176
+ return this.operateAbsolute(a, b, (x, y) => x - y);
177
+ }
178
+ /**
179
+ * Multiplies two vectors by their components, or multiplies a vector by a scalar value.
180
+ * @param a - The vector.
181
+ * @param b - The second vector or scalar value.
182
+ * @returns A new vector with multiplied components.
183
+ */
184
+ static multiplyAbsolute(a, b) {
185
+ return this.operateAbsolute(a, b, (x, y) => x * y);
186
+ }
187
+ /**
188
+ * Divides two vectors by their components, or divides a vector by a scalar value
189
+ * @param a - The vector.
190
+ * @param b - The second vector or scalar vector.
191
+ * @returns A new vector with divided components.
192
+ */
193
+ static divideAbsolute(a, b) {
194
+ return this.operateAbsolute(a, b, (x, y) => x / y);
195
+ }
196
+ /**
197
+ * Calculates the dot product of two vectors.
198
+ * @param a - The first vector.
199
+ * @param b - The second vector.
200
+ * @returns A scalar value representing the degree of alignment between the input vectors.
201
+ */
202
+ static dotProduct(a, b) {
203
+ let result = 0;
204
+ for (const key of ["x", "y", "z", "w"]) {
205
+ const x = a[key];
206
+ const y = b[key];
207
+ if (!!x && !!y) result += x * y;
208
+ else if (x || y)
209
+ throw new Error("Vectors must have the same dimensions.");
210
+ }
211
+ return result;
212
+ }
213
+ /**
214
+ * Calculates the cross product of two vectors in three-dimensional space.
215
+ * @param a - The first vector.
216
+ * @param b - The second vector.
217
+ * @returns A new vector perpendicular to both input vectors.
218
+ */
219
+ static crossProduct(a, b) {
220
+ const { x: ax, y: ay, z: az, w: aw } = a;
221
+ const { x: bx, y: by, z: bz } = b;
222
+ if (ax === void 0 || ay === void 0 || az === void 0 || bx === void 0 || by === void 0 || bz === void 0)
223
+ throw new Error(
224
+ "Vector.crossProduct requires two three-dimensional vectors."
225
+ );
226
+ return this.create(
227
+ ay * bz - az * by,
228
+ az * bx - ax * bz,
229
+ ax * by - ay * bx,
230
+ aw
231
+ );
232
+ }
233
+ /**
234
+ * Normalizes a vector, producing a new vector with the same direction but with a magnitude of 1.
235
+ * @param vector - The vector to be normalized.
236
+ * @returns The new normalized vector.
237
+ */
238
+ static normalize(a) {
239
+ const length = a instanceof _Vector ? a.Length : this.Length(a);
240
+ return this.divide(a, length);
241
+ }
242
+ /**
243
+ * Creates a vector from an array of numbers.
244
+ * @param primitive An array of numbers (usually returned by a native).
245
+ */
246
+ static fromArray(primitive) {
247
+ const [x, y, z, w] = primitive;
248
+ return this.create(x, y, z, w);
249
+ }
250
+ /**
251
+ * Creates a vector from an array or object containing vector components.
252
+ * @param primitive The object to use as a vector.
253
+ */
254
+ static fromObject(primitive) {
255
+ if (Array.isArray(primitive))
256
+ return this.fromArray(primitive);
257
+ if ("buffer" in primitive) return this.fromBuffer(primitive);
258
+ const { x, y, z, w } = primitive;
259
+ return this.create(x, y, z, w);
260
+ }
261
+ /**
262
+ * Creates an array of vectors from an array of number arrays
263
+ * @param primitives A multi-dimensional array of number arrays
264
+ */
265
+ static fromArrays(primitives) {
266
+ return primitives.map(this.fromArray);
267
+ }
268
+ /**
269
+ * Calculates the length (magnitude) of a vector.
270
+ * @param obj - The vector for which to calculate the length.
271
+ * @returns The magnitude of the vector.
272
+ */
273
+ static Length(obj) {
274
+ let sum = 0;
275
+ for (const key of ["x", "y", "z", "w"]) {
276
+ if (key in obj) {
277
+ const value = obj[key];
278
+ sum += value * value;
279
+ }
280
+ }
281
+ return Math.sqrt(sum);
282
+ }
283
+ type;
284
+ [size] = 2;
285
+ x = 0;
286
+ y = 0;
287
+ z;
288
+ w;
289
+ /**
290
+ * Constructs a new vector.
291
+ * @param x The x-component of the vector.
292
+ * @param y The y-component of the vector (optional, defaults to x).
293
+ * @param z The z-component of the vector (optional).
294
+ * @param w The w-component of the vector (optional).
295
+ */
296
+ constructor(x, y = x, z, w) {
297
+ for (let i = 0; i < arguments.length; i++) {
298
+ if (typeof arguments[i] !== "number") {
299
+ throw new TypeError(
300
+ `${this.constructor.name} argument at index ${i} must be a number, but got ${typeof arguments[i]}`
301
+ );
302
+ }
303
+ }
304
+ this.x = x;
305
+ this.y = y;
306
+ }
307
+ *[Symbol.iterator]() {
308
+ yield this.x;
309
+ yield this.y;
310
+ if (this.z !== void 0) yield this.z;
311
+ if (this.w !== void 0) yield this.w;
312
+ }
313
+ get size() {
314
+ return this[size];
315
+ }
316
+ toString() {
317
+ return `vector${this.size}(${this.toArray().join(", ")})`;
318
+ }
319
+ /**
320
+ * @see Vector.clone
321
+ */
322
+ clone() {
323
+ return _Vector.clone(this);
324
+ }
325
+ /**
326
+ * The product of the Euclidean magnitudes of this and another Vector.
327
+ *
328
+ * @param v Vector to find Euclidean magnitude between.
329
+ * @returns Euclidean magnitude with another vector.
330
+ */
331
+ distanceSquared(v) {
332
+ const w = this.subtract(v);
333
+ return _Vector.dotProduct(w, w);
334
+ }
335
+ /**
336
+ * The distance between two Vectors.
337
+ *
338
+ * @param v Vector to find distance between.
339
+ * @returns Distance between this and another vector.
340
+ */
341
+ distance(v) {
342
+ return Math.sqrt(this.distanceSquared(v));
343
+ }
344
+ /**
345
+ * @see Vector.normalize
346
+ */
347
+ normalize() {
348
+ return _Vector.normalize(this);
349
+ }
350
+ /**
351
+ * @see Vector.dotProduct
352
+ */
353
+ dotProduct(v) {
354
+ return _Vector.dotProduct(this, v);
355
+ }
356
+ /**
357
+ * @see Vector.add
358
+ */
359
+ add(v) {
360
+ return _Vector.add(this, v);
361
+ }
362
+ /**
363
+ * @see Vector.addX
364
+ */
365
+ addX(x) {
366
+ return _Vector.addX(this, x);
367
+ }
368
+ /**
369
+ * @see Vector.addY
370
+ */
371
+ addY(y) {
372
+ return _Vector.addY(this, y);
373
+ }
374
+ /**
375
+ * @see Vector.subtract
376
+ */
377
+ subtract(v) {
378
+ return _Vector.subtract(this, v);
379
+ }
380
+ /**
381
+ * @see Vector.multiply
382
+ */
383
+ multiply(v) {
384
+ return _Vector.multiply(this, v);
385
+ }
386
+ /**
387
+ * @see Vector.divide
388
+ */
389
+ divide(v) {
390
+ return _Vector.divide(this, v);
391
+ }
392
+ /**
393
+ * @see Vector.addAbsolute
394
+ */
395
+ addAbsolute(v) {
396
+ return _Vector.addAbsolute(this, v);
397
+ }
398
+ /**
399
+ * @see Vector.subtractAbsolute
400
+ */
401
+ subtractAbsolute(v) {
402
+ return _Vector.subtractAbsolute(this, v);
403
+ }
404
+ /**
405
+ * @see Vector.multiply
406
+ */
407
+ multiplyAbsolute(v) {
408
+ return _Vector.multiplyAbsolute(this, v);
409
+ }
410
+ /**
411
+ * @see Vector.divide
412
+ */
413
+ divideAbsolute(v) {
414
+ return _Vector.divideAbsolute(this, v);
415
+ }
416
+ /**
417
+ * Converts the vector to an array of its components.
418
+ */
419
+ toArray() {
420
+ return [...this];
421
+ }
422
+ /**
423
+ * Replaces the components of the vector with the components of another vector object.
424
+ * @param v - The object whose components will replace the current vector's components.
425
+ */
426
+ replace(v) {
427
+ for (const key of ["x", "y", "z", "w"]) {
428
+ if (key in this && key in v) this[key] = v[key];
429
+ }
430
+ }
431
+ /**
432
+ * Calculates the length (magnitude) of a vector.
433
+ * @returns The magnitude of the vector.
434
+ */
435
+ get Length() {
436
+ let sum = 0;
437
+ for (const value of this) sum += value * value;
438
+ return Math.sqrt(sum);
439
+ }
440
+ swizzle(components) {
441
+ if (!/^[xyzw]+$/.test(components))
442
+ throw new Error(`Invalid key in swizzle components (${components}).`);
443
+ const arr = components.split("").map((char) => this[char] ?? 0);
444
+ return _Vector.create(...arr);
445
+ }
446
+ };
447
+ var Vector2 = class _Vector2 extends Vector {
448
+ static {
449
+ __name(this, "Vector2");
450
+ }
451
+ // DO NOT USE, ONLY EXPOSED BECAUSE TS IS TRASH, THIS TYPE IS NOT GUARANTEED
452
+ // TO EXIST, CHANGING IT WILL BREAK STUFF
453
+ type = 5 /* Vector2 */;
454
+ [size] = 2;
455
+ static Zero = new _Vector2(0, 0);
456
+ /**
457
+ * Constructs a new 2D vector.
458
+ * @param x The x-component of the vector.
459
+ * @param y The y-component of the vector (optional, defaults to x).
460
+ */
461
+ constructor(x, y = x) {
462
+ super(x, y);
463
+ }
464
+ /**
465
+ * Creates a new vector based on the provided parameters.
466
+ * @param x The x-component of the vector.
467
+ * @param y The y-component of the vector (optional, defaults to the value of x).
468
+ * @returns A new vector instance.
469
+ */
470
+ static create(x, y = x) {
471
+ if (typeof x === "object") ({ x, y } = x);
472
+ return new this(x, y);
473
+ }
474
+ };
475
+ var Vector3 = class _Vector3 extends Vector {
476
+ static {
477
+ __name(this, "Vector3");
478
+ }
479
+ // DO NOT USE, ONLY EXPOSED BECAUSE TS IS TRASH, THIS TYPE IS NOT GUARANTEED
480
+ // TO EXIST, CHANGING IT WILL BREAK STUFF
481
+ type = 6 /* Vector3 */;
482
+ [size] = 3;
483
+ z = 0;
484
+ static Zero = new _Vector3(0, 0, 0);
485
+ static UnitX = new _Vector3(1, 0, 0);
486
+ static UnitY = new _Vector3(0, 1, 0);
487
+ static UnitZ = new _Vector3(0, 0, 1);
488
+ static One = new _Vector3(1, 1, 1);
489
+ static Up = new _Vector3(0, 0, 1);
490
+ static Down = new _Vector3(0, 0, -1);
491
+ static Left = new _Vector3(-1, 0, 0);
492
+ static Right = new _Vector3(1, 0, 0);
493
+ static ForwardRH = new _Vector3(0, 1, 0);
494
+ static ForwardLH = new _Vector3(0, -1, 0);
495
+ static BackwardRH = new _Vector3(0, -1, 0);
496
+ static BackwardLH = new _Vector3(0, 1, 0);
497
+ static Backward = _Vector3.BackwardRH;
498
+ /**
499
+ * Constructs a new 3D vector.
500
+ * @param x The x-component of the vector.
501
+ * @param y The y-component of the vector (optional, defaults to x).
502
+ * @param z The z-component of the vector (optional, defaults to y).
503
+ */
504
+ constructor(x, y = x, z = y) {
505
+ super(x, y, z);
506
+ this.z = z;
507
+ }
508
+ /**
509
+ * Creates a new vector based on the provided parameters.
510
+ * @param x The x-component of the vector.
511
+ * @param y The y-component of the vector (optional, defaults to the value of x).
512
+ * @param z The z-component of the vector (optional, defaults to the value of y).
513
+ * @returns A new vector instance.
514
+ */
515
+ static create(x, y = x, z = y) {
516
+ if (typeof x === "object") ({ x, y, z = y } = x);
517
+ return new this(x, y, z);
518
+ }
519
+ /**
520
+ * @see Vector.addZ
521
+ */
522
+ addZ(z) {
523
+ return Vector.addZ(this, z);
524
+ }
525
+ /**
526
+ * @see Vector.crossProduct
527
+ */
528
+ crossProduct(v) {
529
+ return Vector.crossProduct(this, v);
530
+ }
531
+ /**
532
+ * @returns the x and y values as Vec2
533
+ */
534
+ toVec2() {
535
+ return new Vector2(this.x, this.y);
536
+ }
537
+ };
538
+ var Vector4 = class _Vector4 extends Vector {
539
+ static {
540
+ __name(this, "Vector4");
541
+ }
542
+ // DO NOT USE, ONLY EXPOSED BECAUSE TS IS TRASH, THIS TYPE IS NOT GUARANTEED
543
+ // TO EXIST, CHANGING IT WILL BREAK STUFF
544
+ type = 7 /* Vector4 */;
545
+ [size] = 4;
546
+ z = 0;
547
+ w = 0;
548
+ static Zero = new _Vector4(0, 0, 0, 0);
549
+ /**
550
+ * Constructs a new 4D vector.
551
+ * @param x The x-component of the vector.
552
+ * @param y The y-component of the vector (optional, defaults to x).
553
+ * @param z The z-component of the vector (optional, defaults to y).
554
+ * @param w The w-component of the vector (optional, defaults to z).
555
+ */
556
+ constructor(x, y = x, z = y, w = z) {
557
+ super(x, y, z, w);
558
+ this.z = z;
559
+ this.w = w;
560
+ }
561
+ /**
562
+ * Creates a new vector based on the provided parameters.
563
+ * @param x The x-component of the vector.
564
+ * @param y The y-component of the vector (optional, defaults to the value of x).
565
+ * @param z The z-component of the vector (optional, defaults to the value of y).
566
+ * @param w The w-component of the vector (optional, defaults to the value of z).
567
+ * @returns A new vector instance.
568
+ */
569
+ static create(x, y = x, z = y, w = z) {
570
+ if (typeof x === "object") ({ x, y, z = y, w = z } = x);
571
+ return new this(x, y, z, w);
572
+ }
573
+ /**
574
+ * @see Vector.addZ
575
+ */
576
+ addZ(z) {
577
+ return Vector.addZ(this, z);
578
+ }
579
+ /**
580
+ * @see Vector.addW
581
+ */
582
+ addW(w) {
583
+ return Vector.addW(this, w);
584
+ }
585
+ /**
586
+ * @see Vector.crossProduct
587
+ */
588
+ crossProduct(v) {
589
+ return Vector.crossProduct(this, v);
590
+ }
591
+ /**
592
+ * @returns the x and y values as Vec2
593
+ */
594
+ toVec2() {
595
+ return new Vector2(this.x, this.y);
596
+ }
597
+ /**
598
+ * @returns the x and y values as Vec3
599
+ */
600
+ toVec3() {
601
+ return new Vector3(this.x, this.y, this.z);
602
+ }
603
+ };
604
+
605
+ // src/common/utils/Maths.ts
606
+ var Maths = class {
607
+ static {
608
+ __name(this, "Maths");
609
+ }
610
+ static clamp(num, min, max) {
611
+ return num <= min ? min : num >= max ? max : num;
612
+ }
613
+ static getRandomInt(min, max) {
614
+ min = Math.ceil(min);
615
+ max = Math.floor(max);
616
+ return Math.floor(Math.random() * (max - min)) + min;
617
+ }
618
+ };
619
+
620
+ // src/common/utils/Quaternion.ts
621
+ var Quaternion = class {
622
+ static {
623
+ __name(this, "Quaternion");
624
+ }
625
+ x;
626
+ y;
627
+ z;
628
+ w;
629
+ constructor(valueXOrVector, yOrW, z, w) {
630
+ if (valueXOrVector instanceof Vector3) {
631
+ this.x = valueXOrVector.x;
632
+ this.y = valueXOrVector.y;
633
+ this.z = valueXOrVector.z;
634
+ this.w = yOrW ?? 0;
635
+ } else if (yOrW === void 0) {
636
+ this.x = valueXOrVector;
637
+ this.y = valueXOrVector;
638
+ this.z = valueXOrVector;
639
+ this.w = valueXOrVector;
640
+ } else {
641
+ this.x = valueXOrVector;
642
+ this.y = yOrW;
643
+ this.z = z ?? 0;
644
+ this.w = w ?? 0;
645
+ }
646
+ }
647
+ };
648
+
649
+ // src/common/utils/Color.ts
650
+ var Color = class _Color {
651
+ static {
652
+ __name(this, "Color");
653
+ }
654
+ static Transparent = new _Color(0, 0, 0, 0);
655
+ static Black = new _Color(0, 0, 0);
656
+ static White = new _Color(255, 255, 255);
657
+ static WhiteSmoke = new _Color(245, 245, 245);
658
+ static fromArgb(a, r, g, b) {
659
+ return new _Color(r, g, b, a);
660
+ }
661
+ static fromRgb(r, g, b) {
662
+ return new _Color(r, g, b);
663
+ }
664
+ static fromArray(primitive) {
665
+ return new _Color(primitive[0], primitive[1], primitive[2], 255);
666
+ }
667
+ a;
668
+ r;
669
+ g;
670
+ b;
671
+ constructor(r, g, b, a = 255) {
672
+ this.r = r;
673
+ this.g = g;
674
+ this.b = b;
675
+ this.a = a;
676
+ }
677
+ };
678
+
679
+ // src/common/utils/cleanPlayerName.ts
680
+ var cleanPlayerName = /* @__PURE__ */ __name((original) => {
681
+ let displayName = original.substring(0, 75).replace(
682
+ /[\u0000-\u001F\u007F-\u009F\u200B-\u200D\uFEFF\u200E\uA9C1-\uA9C5\u239B-\u23AD]/g,
683
+ ""
684
+ ).replace(
685
+ /~(HUD_\S+|HC_\S+|[a-z]|[a1]_\d+|bold|italic|ws|wanted_star|nrt|EX_R\*|BLIP_\S+|ACCEPT|CANCEL|PAD_\S+|INPUT_\S+|INPUTGROUP_\S+)~/gi,
686
+ ""
687
+ ).replace(/\^\d/gi, "").replace(/\p{Mark}{2,}/gu, "").replace(/\s+/g, " ").trim();
688
+ if (!displayName.length) displayName = "empty name";
689
+ return displayName;
690
+ }, "cleanPlayerName");
691
+
692
+ // src/common/utils/enumValues.ts
693
+ function* enumValues(enumObj) {
694
+ let isStringEnum = true;
695
+ for (const property in enumObj) {
696
+ if (typeof enumObj[property] === "number") {
697
+ isStringEnum = false;
698
+ break;
699
+ }
700
+ }
701
+ for (const property in enumObj) {
702
+ if (isStringEnum || typeof enumObj[property] === "number") {
703
+ yield enumObj[property];
704
+ }
705
+ }
706
+ }
707
+ __name(enumValues, "enumValues");
708
+
709
+ // src/common/utils/getStringFromUInt8Array.ts
710
+ var getStringFromUInt8Array = /* @__PURE__ */ __name((buffer, start, end) => String.fromCharCode(...buffer.slice(start, end)).replace(/\u0000/g, ""), "getStringFromUInt8Array");
711
+
712
+ // src/common/utils/getUInt32FromUint8Array.ts
713
+ var getUInt32FromUint8Array = /* @__PURE__ */ __name((buffer, start, end) => new Uint32Array(buffer.slice(start, end).buffer)[0], "getUInt32FromUint8Array");
714
+
715
+ // src/common/utils/index.ts
716
+ var Delay = /* @__PURE__ */ __name((milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)), "Delay");
717
+
718
+ // src/server/cfx/index.ts
719
+ var cfx_default = { Entity, Player };
720
+
721
+ // src/server/entities/BaseEntity.ts
722
+ var BaseEntity = class _BaseEntity {
723
+ constructor(handle) {
724
+ this.handle = handle;
725
+ }
726
+ static {
727
+ __name(this, "BaseEntity");
728
+ }
729
+ type = 3 /* Entity */;
730
+ // Replaces the current handle for the entity used on, this hsould be used sparringly, mainly
731
+ // in situations where you're going to reuse an entity over and over and don't want to make a
732
+ // new entity every time.
733
+ //
734
+ // **WARNING**: This does no checks, if you provide it an invalid entity it will use it
735
+ //
736
+ // ```ts
737
+ // const REUSABLE_ENTITY = new Entity(entityHandle);
738
+ //
739
+ // onNet("entityHandler", (entNetId: number) => {
740
+ // // if no net entity we should ignore
741
+ // const entId = NetworkGetEntityFromNetworkId(entNetId);
742
+ // if (entId === 0) return;
743
+ //
744
+ // // Reuse our entity so we don't have to initialize a new one
745
+ // REUSABLE_ENTITY.replaceHandle(entId);
746
+ // // Do something with REUSABLE_ENTITY entity
747
+ // })
748
+ // ```
749
+ replaceHandle(newHandle) {
750
+ this.handle = newHandle;
751
+ }
752
+ static fromNetworkId(networkId) {
753
+ const ent = NetworkGetEntityFromNetworkId(networkId);
754
+ if (ent === 0) return null;
755
+ return new _BaseEntity(ent);
756
+ }
757
+ static fromStateBagName(stateBagName) {
758
+ const ent = GetEntityFromStateBagName(stateBagName);
759
+ if (ent === 0) return null;
760
+ return new _BaseEntity(ent);
761
+ }
762
+ get State() {
763
+ return cfx_default.Entity(this.handle).state;
764
+ }
765
+ get Handle() {
766
+ return this.handle;
767
+ }
768
+ get Owner() {
769
+ return NetworkGetEntityOwner(this.handle);
770
+ }
771
+ get FirstOwner() {
772
+ return NetworkGetFirstEntityOwner(this.handle);
773
+ }
774
+ get Exists() {
775
+ return this.handle !== 0 && DoesEntityExist(this.handle);
776
+ }
777
+ /**
778
+ * @returns the entity that the calling entity is attached to, or null if
779
+ * there is none
780
+ */
781
+ get AttachedTo() {
782
+ const ent = GetEntityAttachedTo(this.handle);
783
+ if (ent === 0) return null;
784
+ return new _BaseEntity(ent);
785
+ }
786
+ get Position() {
787
+ return Vector3.fromArray(GetEntityCoords(this.handle));
788
+ }
789
+ get Heading() {
790
+ return GetEntityHeading(this.handle);
791
+ }
792
+ get PositionAndHeading() {
793
+ return Vector4.fromArray([
794
+ ...GetEntityCoords(this.handle),
795
+ GetEntityHeading(this.handle)
796
+ ]);
797
+ }
798
+ get Health() {
799
+ return GetEntityHealth(this.handle);
800
+ }
801
+ get MaxHealth() {
802
+ return GetEntityMaxHealth(this.handle);
803
+ }
804
+ get Model() {
805
+ return GetEntityModel(this.handle);
806
+ }
807
+ get PopulationType() {
808
+ return GetEntityPopulationType(this.handle);
809
+ }
810
+ get Rotation() {
811
+ return Vector3.fromArray(GetEntityRotation(this.handle));
812
+ }
813
+ get RotationVelocity() {
814
+ return Vector3.fromArray(GetEntityRotationVelocity(this.handle));
815
+ }
816
+ get RoutingBucket() {
817
+ return GetEntityRoutingBucket(this.handle);
818
+ }
819
+ /**
820
+ * @returns The script that made the entity
821
+ */
822
+ get Script() {
823
+ return GetEntityScript(this.handle);
824
+ }
825
+ get Speed() {
826
+ return GetEntitySpeed(this.handle);
827
+ }
828
+ get Type() {
829
+ return GetEntityType(this.handle);
830
+ }
831
+ /**
832
+ * @returns the entitys velocity, if the entity is a ped it will return Vector3(0, 0, 0)
833
+ */
834
+ get Velocity() {
835
+ return Vector3.fromArray(GetEntityVelocity(this.handle));
836
+ }
837
+ get IsVisible() {
838
+ return IsEntityVisible(this.handle);
839
+ }
840
+ get NetworkId() {
841
+ return NetworkGetNetworkIdFromEntity(this.handle);
842
+ }
843
+ get IsNoLongerNeeded() {
844
+ return HasEntityBeenMarkedAsNoLongerNeeded(this.handle);
845
+ }
846
+ delete() {
847
+ if (this.Exists) {
848
+ DeleteEntity(this.handle);
849
+ }
850
+ }
851
+ };
852
+
853
+ // src/server/entities/Entity.ts
854
+ var Entity2 = class _Entity extends BaseEntity {
855
+ static {
856
+ __name(this, "Entity");
857
+ }
858
+ constructor(handle) {
859
+ super(handle);
860
+ }
861
+ static fromNetworkId(netId) {
862
+ return new _Entity(NetworkGetEntityFromNetworkId(netId));
863
+ }
864
+ static fromHandle(handle) {
865
+ return new _Entity(handle);
866
+ }
867
+ };
868
+
869
+ // src/server/entities/Vehicle.ts
870
+ var Vehicle = class _Vehicle extends BaseEntity {
871
+ static {
872
+ __name(this, "Vehicle");
873
+ }
874
+ type = 2 /* Vehicle */;
875
+ constructor(handle) {
876
+ super(handle);
877
+ }
878
+ /**
879
+ * Get an interable list of vehicles currently on the server
880
+ * @returns Iterable list of Vehicles.
881
+ */
882
+ static *AllVehicles() {
883
+ for (const veh of GetAllVehicles()) {
884
+ yield new _Vehicle(veh);
885
+ }
886
+ }
887
+ static fromNetworkId(networkId) {
888
+ const ent = NetworkGetEntityFromNetworkId(networkId);
889
+ if (ent === 0) return null;
890
+ return new _Vehicle(ent);
891
+ }
892
+ static fromStateBagName(stateBageName) {
893
+ const ent = GetEntityFromStateBagName(stateBageName);
894
+ if (ent === 0) return null;
895
+ return new _Vehicle(ent);
896
+ }
897
+ get IsEngineRunning() {
898
+ return GetIsVehicleEngineRunning(this.handle);
899
+ }
900
+ get IsPrimaryColourCustom() {
901
+ return GetIsVehiclePrimaryColourCustom(this.handle);
902
+ }
903
+ get IsSecondaryColourCustom() {
904
+ return GetIsVehicleSecondaryColourCustom(this.handle);
905
+ }
906
+ get BodyHealth() {
907
+ return GetVehicleBodyHealth(this.handle);
908
+ }
909
+ get VehicleColours() {
910
+ return GetVehicleColours(this.handle);
911
+ }
912
+ get CustomPrimaryColour() {
913
+ return Color.fromArray(GetVehicleCustomPrimaryColour(this.handle));
914
+ }
915
+ get CustomSecondaryColour() {
916
+ return Color.fromArray(GetVehicleCustomSecondaryColour(this.handle));
917
+ }
918
+ get DashboardColour() {
919
+ return GetVehicleDashboardColour(this.handle);
920
+ }
921
+ get DirtLevel() {
922
+ return GetVehicleDirtLevel(this.handle);
923
+ }
924
+ get LockStatus() {
925
+ return GetVehicleDoorLockStatus(this.handle);
926
+ }
927
+ getDoorStatus(doorIndex) {
928
+ return GetVehicleDoorStatus(this.handle, doorIndex);
929
+ }
930
+ get DoorsLockedForPlayer() {
931
+ return GetVehicleDoorsLockedForPlayer(this.handle);
932
+ }
933
+ get EngineHealth() {
934
+ return GetVehicleEngineHealth(this.handle);
935
+ }
936
+ get ExtraColours() {
937
+ return GetVehicleExtraColours(this.handle);
938
+ }
939
+ get FlightNozzlePosition() {
940
+ return GetVehicleFlightNozzlePosition(this.handle);
941
+ }
942
+ get Handbrake() {
943
+ return GetVehicleHandbrake(this.handle);
944
+ }
945
+ get HeadlightsColour() {
946
+ return GetVehicleHeadlightsColour(this.handle);
947
+ }
948
+ get HomingLockonState() {
949
+ return GetVehicleHomingLockonState(this.handle);
950
+ }
951
+ get InteriorColour() {
952
+ return GetVehicleInteriorColour(this.handle);
953
+ }
954
+ get LightsState() {
955
+ const [_, lightsOn, highbeansOn] = GetVehicleLightsState(this.handle);
956
+ return [lightsOn, highbeansOn];
957
+ }
958
+ get Livery() {
959
+ return GetVehicleLivery(this.handle);
960
+ }
961
+ get LockOnTarget() {
962
+ return new _Vehicle(GetVehicleLockOnTarget(this.handle));
963
+ }
964
+ get Plate() {
965
+ return GetVehicleNumberPlateText(this.handle);
966
+ }
967
+ get PlateTrimmed() {
968
+ return this.Plate.trim();
969
+ }
970
+ get PlateIndex() {
971
+ return GetVehicleNumberPlateTextIndex(this.handle);
972
+ }
973
+ get PetrolTankHealth() {
974
+ return GetVehiclePetrolTankHealth(this.handle);
975
+ }
976
+ get RadioStation() {
977
+ return GetVehicleRadioStationIndex(this.handle);
978
+ }
979
+ get RoofLivery() {
980
+ return GetVehicleRoofLivery(this.handle);
981
+ }
982
+ get SteeringAngle() {
983
+ return GetVehicleSteeringAngle(this.handle);
984
+ }
985
+ get VehicleType() {
986
+ return GetVehicleType(this.handle);
987
+ }
988
+ get TyreSmokeColour() {
989
+ return Color.fromArray(GetVehicleTyreSmokeColor(this.handle));
990
+ }
991
+ get WheelType() {
992
+ return GetVehicleWheelType(this.handle);
993
+ }
994
+ get WindowTint() {
995
+ return GetVehicleWindowTint(this.handle);
996
+ }
997
+ get HasBeenOwnedByPlayer() {
998
+ return HasVehicleBeenOwnedByPlayer(this.handle);
999
+ }
1000
+ get IsEngineStarting() {
1001
+ return IsVehicleEngineStarting(this.handle);
1002
+ }
1003
+ get IsSirenOn() {
1004
+ return IsVehicleSirenOn(this.handle);
1005
+ }
1006
+ get MaxHealth() {
1007
+ return GetEntityMaxHealth(this.handle);
1008
+ }
1009
+ get ScriptTaskCommand() {
1010
+ return GetPedScriptTaskCommand(this.handle);
1011
+ }
1012
+ get ScriptTaskStage() {
1013
+ return GetPedScriptTaskStage(this.handle);
1014
+ }
1015
+ get MainRotorHealth() {
1016
+ return GetHeliMainRotorHealth(this.handle);
1017
+ }
1018
+ get TailRotorHealth() {
1019
+ return GetHeliTailRotorHealth(this.handle);
1020
+ }
1021
+ /**
1022
+ * This might supposed to be TrainEngineHealth?
1023
+ */
1024
+ get TrainCarriageEngine() {
1025
+ return GetTrainCarriageEngine(this.handle);
1026
+ }
1027
+ get TrainCarriageIndex() {
1028
+ return GetTrainCarriageIndex(this.handle);
1029
+ }
1030
+ isTyreBurst(wheelId, completely) {
1031
+ return IsVehicleTyreBurst(this.handle, wheelId, completely);
1032
+ }
1033
+ isExtraTurnedOn(extraId) {
1034
+ return IsVehicleExtraTurnedOn(this.handle, extraId);
1035
+ }
1036
+ getPedInSeat(seatIndex) {
1037
+ return GetPedInVehicleSeat(this.handle, seatIndex);
1038
+ }
1039
+ getLastPedInSeat(seatIndex) {
1040
+ return GetLastPedInVehicleSeat(this.handle, seatIndex);
1041
+ }
1042
+ };
1043
+
1044
+ // src/server/entities/Ped.ts
1045
+ var Ped = class _Ped extends BaseEntity {
1046
+ static {
1047
+ __name(this, "Ped");
1048
+ }
1049
+ type = 0 /* Ped */;
1050
+ constructor(handle) {
1051
+ super(handle);
1052
+ }
1053
+ /**
1054
+ * Get an interable list of peds currently on the server
1055
+ * @returns Iterable list of Peds.
1056
+ */
1057
+ static *AllPeds() {
1058
+ for (const pedId of GetAllPeds()) {
1059
+ yield new _Ped(pedId);
1060
+ }
1061
+ }
1062
+ static fromNetworkId(netId) {
1063
+ const ent = NetworkGetEntityFromNetworkId(netId);
1064
+ if (ent === 0) return null;
1065
+ return new _Ped(ent);
1066
+ }
1067
+ static fromStateBagName(stateBagName) {
1068
+ const handle = GetEntityFromStateBagName(stateBagName);
1069
+ if (handle === 0) return null;
1070
+ return new _Ped(handle);
1071
+ }
1072
+ static fromSource(source2) {
1073
+ return new _Ped(GetPlayerPed(source2));
1074
+ }
1075
+ get Armour() {
1076
+ return GetPedArmour(this.handle);
1077
+ }
1078
+ get CauseOfDeath() {
1079
+ return GetPedCauseOfDeath(this.handle);
1080
+ }
1081
+ get DesiredHeading() {
1082
+ return GetPedDesiredHeading(this.handle);
1083
+ }
1084
+ get MaxHealth() {
1085
+ return GetPedMaxHealth(this.handle);
1086
+ }
1087
+ get TaskCommand() {
1088
+ return GetPedScriptTaskCommand(this.handle);
1089
+ }
1090
+ get TaskStage() {
1091
+ return GetPedScriptTaskStage(this.handle);
1092
+ }
1093
+ get LastSourceOfDamage() {
1094
+ return GetPedSourceOfDamage(this.handle);
1095
+ }
1096
+ get DeathCause() {
1097
+ return GetPedCauseOfDeath(this.handle);
1098
+ }
1099
+ get Weapon() {
1100
+ return GetSelectedPedWeapon(this.handle);
1101
+ }
1102
+ /**
1103
+ * @returns the current vehicle the ped is in, or null if it doesn't exist
1104
+ */
1105
+ get CurrentVehicle() {
1106
+ const vehicle = GetVehiclePedIsIn(this.handle, false);
1107
+ if (vehicle === 0) return null;
1108
+ return new Vehicle(vehicle);
1109
+ }
1110
+ get LastVehicle() {
1111
+ const vehicle = GetVehiclePedIsIn(this.handle, false);
1112
+ if (vehicle === 0) return null;
1113
+ return new Vehicle(GetVehiclePedIsIn(this.handle, true));
1114
+ }
1115
+ get IsPlayer() {
1116
+ return IsPedAPlayer(this.handle);
1117
+ }
1118
+ getSpecificTaskType(index) {
1119
+ return GetPedSpecificTaskType(this.handle, index);
1120
+ }
1121
+ };
1122
+
1123
+ // src/server/entities/Player.ts
1124
+ var Player2 = class _Player {
1125
+ constructor(source2) {
1126
+ this.source = source2;
1127
+ }
1128
+ static {
1129
+ __name(this, "Player");
1130
+ }
1131
+ type = 4 /* Player */;
1132
+ /**
1133
+ * Get an interable list of players currently on the server
1134
+ * @returns Iterable list of Players.
1135
+ */
1136
+ static *AllPlayers() {
1137
+ const num = GetNumPlayerIndices();
1138
+ for (let i = 0; i < num; i++) {
1139
+ yield new _Player(Number.parseInt(GetPlayerFromIndex(i)));
1140
+ }
1141
+ }
1142
+ get Exists() {
1143
+ return this.source !== 0;
1144
+ }
1145
+ get Source() {
1146
+ return this.source;
1147
+ }
1148
+ get State() {
1149
+ return cfx_default.Player(this.source).state;
1150
+ }
1151
+ /**
1152
+ * Returns the player source casted as a string
1153
+ */
1154
+ get Src() {
1155
+ return this.source;
1156
+ }
1157
+ get Ped() {
1158
+ return new Ped(GetPlayerPed(this.Src));
1159
+ }
1160
+ get Tokens() {
1161
+ return getPlayerTokens(this.source);
1162
+ }
1163
+ get Identifiers() {
1164
+ return getPlayerIdentifiers(this.source);
1165
+ }
1166
+ get Endpoint() {
1167
+ return GetPlayerEndpoint(this.Src);
1168
+ }
1169
+ get CamerRotation() {
1170
+ return Vector3.fromArray(GetPlayerCameraRotation(this.Src));
1171
+ }
1172
+ /**
1173
+ * Returns the time since the last player UDP message
1174
+ */
1175
+ get LastMessage() {
1176
+ return GetPlayerLastMsg(this.Src);
1177
+ }
1178
+ get MaxArmour() {
1179
+ return GetPlayerMaxArmour(this.Src);
1180
+ }
1181
+ get MaxHealth() {
1182
+ return GetPlayerMaxHealth(this.Src);
1183
+ }
1184
+ get MeleeModifier() {
1185
+ return GetPlayerMeleeWeaponDamageModifier(this.Src);
1186
+ }
1187
+ /**
1188
+ * @returns the players name
1189
+ */
1190
+ get Name() {
1191
+ return GetPlayerName(this.Src);
1192
+ }
1193
+ /**
1194
+ * @returns the players name with any color code unicode, etc removed, this can lead to there being no name at all
1195
+ */
1196
+ filteredName() {
1197
+ return cleanPlayerName(this.Name);
1198
+ }
1199
+ /**
1200
+ * @returns the players round trip ping
1201
+ */
1202
+ get Ping() {
1203
+ return GetPlayerPing(this.Src);
1204
+ }
1205
+ /**
1206
+ * @returns the current routhing bucket the player is in, default is 0
1207
+ */
1208
+ get RoutingBucket() {
1209
+ return GetPlayerRoutingBucket(this.Src);
1210
+ }
1211
+ get Team() {
1212
+ return GetPlayerTeam(this.Src);
1213
+ }
1214
+ get WantedPosition() {
1215
+ return Vector3.fromArray(GetPlayerWantedCentrePosition(this.Src));
1216
+ }
1217
+ get WantedLevel() {
1218
+ return GetPlayerWantedLevel(this.Src);
1219
+ }
1220
+ get IsEvadingWanted() {
1221
+ return IsPlayerEvadingWantedLevel(this.Src);
1222
+ }
1223
+ get WeaponDamageModifier() {
1224
+ return GetPlayerWeaponDamageModifier(this.Src);
1225
+ }
1226
+ get WeaponDefenseModifier() {
1227
+ return GetPlayerWeaponDefenseModifier(this.Src);
1228
+ }
1229
+ get WeaponDefenseModifier2() {
1230
+ return GetPlayerWeaponDefenseModifier_2(this.Src);
1231
+ }
1232
+ get AirDragMultiplier() {
1233
+ return GetAirDragMultiplierForPlayersVehicle(this.Src);
1234
+ }
1235
+ get IsUsingSuperJump() {
1236
+ return IsPlayerUsingSuperJump(this.Src);
1237
+ }
1238
+ get IsMuted() {
1239
+ return MumbleIsPlayerMuted(this.source);
1240
+ }
1241
+ set IsMuted(isMuted) {
1242
+ MumbleSetPlayerMuted(this.source, isMuted);
1243
+ }
1244
+ isAceAllowed(object) {
1245
+ return IsPlayerAceAllowed(this.Src, object);
1246
+ }
1247
+ timeInPersuit(lastPursuit = false) {
1248
+ return GetPlayerTimeInPursuit(this.Src, lastPursuit);
1249
+ }
1250
+ drop(reason = "No reason specified") {
1251
+ DropPlayer(this.Src, reason);
1252
+ }
1253
+ emit(eventName, ...args) {
1254
+ TriggerClientEvent(eventName, this.source, ...args);
1255
+ }
1256
+ };
1257
+
1258
+ // src/server/entities/Prop.ts
1259
+ var Prop = class _Prop extends BaseEntity {
1260
+ static {
1261
+ __name(this, "Prop");
1262
+ }
1263
+ type = 1 /* Prop */;
1264
+ constructor(handle) {
1265
+ super(handle);
1266
+ }
1267
+ /**
1268
+ * Get an interable list of props currently on the server
1269
+ * @returns Iterable list of Props.
1270
+ */
1271
+ static *AllProps() {
1272
+ for (const prop of GetAllObjects()) {
1273
+ yield new _Prop(prop);
1274
+ }
1275
+ }
1276
+ static fromNetworkId(networkId) {
1277
+ const ent = NetworkGetEntityFromNetworkId(networkId);
1278
+ if (ent === 0) return null;
1279
+ return new _Prop(ent);
1280
+ }
1281
+ static fromStateBagName(stateBagName) {
1282
+ const ent = GetEntityFromStateBagName(stateBagName);
1283
+ if (ent === 0) return null;
1284
+ return new _Prop(ent);
1285
+ }
1286
+ static fromHandle(handle) {
1287
+ return new _Prop(handle);
1288
+ }
1289
+ };
1290
+
1291
+ // src/server/Events.ts
1292
+ var getClassFromArguments = /* @__PURE__ */ __name((...args) => {
1293
+ const newArgs = [];
1294
+ for (const arg of args) {
1295
+ if (!arg.type) {
1296
+ newArgs.push(arg);
1297
+ continue;
1298
+ }
1299
+ switch (arg.type) {
1300
+ case 5 /* Vector2 */: {
1301
+ newArgs.push(Vector2.fromObject(arg));
1302
+ continue;
1303
+ }
1304
+ case 6 /* Vector3 */: {
1305
+ newArgs.push(Vector3.fromObject(arg));
1306
+ continue;
1307
+ }
1308
+ case 7 /* Vector4 */: {
1309
+ newArgs.push(Vector4.fromObject(arg));
1310
+ continue;
1311
+ }
1312
+ case 0 /* Ped */: {
1313
+ newArgs.push(Ped.fromNetworkId(arg.handle));
1314
+ continue;
1315
+ }
1316
+ case 4 /* Player */: {
1317
+ newArgs.push(new Player2(arg.source));
1318
+ continue;
1319
+ }
1320
+ case 1 /* Prop */: {
1321
+ newArgs.push(Prop.fromNetworkId(arg.handle));
1322
+ continue;
1323
+ }
1324
+ case 2 /* Vehicle */: {
1325
+ newArgs.push(Vehicle.fromNetworkId(arg.netId));
1326
+ continue;
1327
+ }
1328
+ case 3 /* Entity */: {
1329
+ newArgs.push(Entity2.fromNetworkId(arg.netId));
1330
+ continue;
1331
+ }
1332
+ default: {
1333
+ newArgs.push(arg);
1334
+ }
1335
+ }
1336
+ }
1337
+ return newArgs;
1338
+ }, "getClassFromArguments");
1339
+ var Events = class {
1340
+ static {
1341
+ __name(this, "Events");
1342
+ }
1343
+ static cancel() {
1344
+ CancelEvent();
1345
+ }
1346
+ static wasCanceled() {
1347
+ return WasEventCanceled();
1348
+ }
1349
+ static get InvokingResource() {
1350
+ return GetInvokingResource();
1351
+ }
1352
+ /**
1353
+ * An onNet wrapper that properly converts the type into the correct type
1354
+ */
1355
+ static onNet = /* @__PURE__ */ __name((eventName, event) => {
1356
+ onNet(eventName, (...args) => {
1357
+ const ply = new Player2(source);
1358
+ event(ply, ...getClassFromArguments(...args));
1359
+ });
1360
+ }, "onNet");
1361
+ /**
1362
+ * An on wrapper that properly converts the classes
1363
+ */
1364
+ static on = /* @__PURE__ */ __name((eventName, event) => {
1365
+ on(eventName, (...args) => {
1366
+ event(...getClassFromArguments(...args));
1367
+ });
1368
+ }, "on");
1369
+ };
1370
+
1371
+ // src/server/Game.ts
1372
+ var Game = class {
1373
+ static {
1374
+ __name(this, "Game");
1375
+ }
1376
+ // A map containing generated hashes.
1377
+ static hashCache = /* @__PURE__ */ new Map();
1378
+ /**
1379
+ * Calculate the Jenkins One At A Time (joaat) has from the given string.
1380
+ *
1381
+ * @param input The input string to calculate the hash
1382
+ */
1383
+ static generateHash(input) {
1384
+ if (typeof input === "undefined") {
1385
+ return 0;
1386
+ }
1387
+ const _hash = this.hashCache.get(input);
1388
+ if (_hash) return _hash;
1389
+ const hash = GetHashKey(input);
1390
+ this.hashCache.set(input, hash);
1391
+ return hash;
1392
+ }
1393
+ /**
1394
+ * Gets how many milliseconds the game has been open this session
1395
+ */
1396
+ static get GameTime() {
1397
+ return GetGameTimer();
1398
+ }
1399
+ static get GameBuild() {
1400
+ return GetGameBuildNumber();
1401
+ }
1402
+ static get GameName() {
1403
+ return GetGameName();
1404
+ }
1405
+ static registerCommand(name, handler, restricted = false) {
1406
+ RegisterCommand(
1407
+ name,
1408
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1409
+ (source2, args) => {
1410
+ const player = new Player2(Number.parseInt(source2));
1411
+ handler(player, args);
1412
+ },
1413
+ restricted
1414
+ );
1415
+ }
1416
+ static get RegisteredCommands() {
1417
+ return GetRegisteredCommands();
1418
+ }
1419
+ /**
1420
+ * Get an iterable list of players currently on the server.
1421
+ * @returns Iterable list of Player objects.
1422
+ */
1423
+ static *PlayerList() {
1424
+ for (const id of getPlayers()) {
1425
+ yield new Player2(id);
1426
+ }
1427
+ }
1428
+ };
1429
+
1430
+ // src/common/GlobalData.ts
1431
+ var GlobalData = class _GlobalData {
1432
+ static {
1433
+ __name(this, "GlobalData");
1434
+ }
1435
+ static CurrentResource = GetCurrentResourceName();
1436
+ static IS_SERVER = IsDuplicityVersion();
1437
+ static IS_CLIENT = !_GlobalData.IS_SERVER;
1438
+ static NetworkTick = null;
1439
+ static NetworkedTicks = [];
1440
+ static EnablePrettyPrint = true;
1441
+ };
1442
+
1443
+ // src/common/net/NetworkedMap.ts
1444
+ var NetworkedMapEventManager = class {
1445
+ static {
1446
+ __name(this, "NetworkedMapEventManager");
1447
+ }
1448
+ #syncedCalls = /* @__PURE__ */ new Map();
1449
+ constructor() {
1450
+ $SERVER: if (GlobalData.IS_SERVER) {
1451
+ on("playerDropped", () => {
1452
+ const src = source;
1453
+ for (const [_k, map] of this.#syncedCalls) {
1454
+ map.removeSubscriber(src);
1455
+ }
1456
+ });
1457
+ return;
1458
+ }
1459
+ }
1460
+ addNetworkedMap(map) {
1461
+ this.#syncedCalls.set(map.SyncName, map);
1462
+ }
1463
+ removeNetworkedMap(syncName) {
1464
+ this.#syncedCalls.delete(syncName);
1465
+ }
1466
+ };
1467
+ var netManager = new NetworkedMapEventManager();
1468
+
1469
+ // src/common/Convar.ts
1470
+ var Convar = class {
1471
+ static {
1472
+ __name(this, "Convar");
1473
+ }
1474
+ /**
1475
+ * @returns the current console buffer
1476
+ */
1477
+ buffer() {
1478
+ return GetConsoleBuffer();
1479
+ }
1480
+ get(variable, defaultVar) {
1481
+ return GetConvar(variable, defaultVar);
1482
+ }
1483
+ getInt(variable, defaultVar) {
1484
+ return GetConvarInt(variable, defaultVar);
1485
+ }
1486
+ getFloat(varName, defaultVar) {
1487
+ return GetConvarFloat(varName, defaultVar);
1488
+ }
1489
+ getBool(varName, defaultVar) {
1490
+ return GetConvarBool(varName, defaultVar);
1491
+ }
1492
+ set(variable, value) {
1493
+ SetConvar(variable, value);
1494
+ }
1495
+ setReplicated(variable, value) {
1496
+ SetConvarReplicated(variable, value);
1497
+ }
1498
+ setServerInfo(variable, value) {
1499
+ SetConvarServerInfo(variable, value);
1500
+ }
1501
+ };
1502
+
1503
+ // src/common/Command.ts
1504
+ var commands = [];
1505
+ $SERVER: {
1506
+ on("playerJoining", () => emitNet("chat:addSuggestions", source, commands));
1507
+ }
1508
+ function registerCommand(name, commandHandler, restricted) {
1509
+ if (Array.isArray(name)) {
1510
+ for (const command of name) {
1511
+ registerCommand(command, commandHandler, restricted);
1512
+ }
1513
+ return;
1514
+ }
1515
+ RegisterCommand(name, commandHandler, !!restricted);
1516
+ $SERVER: {
1517
+ const ace = `command.${name}`;
1518
+ if (typeof restricted === "string") {
1519
+ if (IsPrincipalAceAllowed(restricted, ace)) return;
1520
+ return ExecuteCommand(`add_ace ${restricted} ${ace} allow`);
1521
+ }
1522
+ if (Array.isArray(restricted)) {
1523
+ for (const principal of restricted) {
1524
+ if (!IsPrincipalAceAllowed(principal, ace))
1525
+ ExecuteCommand(`add_ace ${restricted} ${ace} allow`);
1526
+ }
1527
+ }
1528
+ }
1529
+ }
1530
+ __name(registerCommand, "registerCommand");
1531
+ var Command = class {
1532
+ constructor(name, help, handler, params, restricted = true) {
1533
+ this.name = name;
1534
+ this.help = help;
1535
+ this.params = params;
1536
+ this.#handler = handler;
1537
+ this.name = `/${name}`;
1538
+ registerCommand(
1539
+ name,
1540
+ (source2, args, raw) => this.call(source2, args, raw),
1541
+ restricted
1542
+ );
1543
+ if (params) {
1544
+ for (const parameter of params) {
1545
+ if (parameter.type) {
1546
+ parameter.help = parameter.help ? `${parameter.help} (type: ${parameter.type})` : `(type: ${parameter.type})`;
1547
+ }
1548
+ }
1549
+ setTimeout(() => {
1550
+ $SERVER: {
1551
+ commands.push(this);
1552
+ emitNet("chat:addSuggestions", -1, this);
1553
+ }
1554
+ }, 100);
1555
+ }
1556
+ }
1557
+ static {
1558
+ __name(this, "Command");
1559
+ }
1560
+ #handler;
1561
+ mapArguments(source2, args, raw) {
1562
+ const mapped = {
1563
+ source: source2,
1564
+ raw
1565
+ };
1566
+ if (!this.params) return mapped;
1567
+ const result = this.params.every((param, index) => {
1568
+ const arg = args[index];
1569
+ let value = arg;
1570
+ switch (param.type) {
1571
+ case "number":
1572
+ value = +arg;
1573
+ break;
1574
+ case "string":
1575
+ value = !Number(arg) ? arg : false;
1576
+ break;
1577
+ case "playerId":
1578
+ $SERVER: {
1579
+ value = arg === "me" ? source2 : +arg;
1580
+ if (!value || !DoesPlayerExist(value.toString())) value = void 0;
1581
+ }
1582
+ break;
1583
+ case "longString":
1584
+ value = raw.substring(raw.indexOf(arg));
1585
+ break;
1586
+ }
1587
+ if (value === void 0 && (!param.optional || param.optional && arg)) {
1588
+ return Citizen.trace(
1589
+ `^1command '${raw.split(" ")[0] || raw}' received an invalid ${param.type} for argument ${index + 1} (${param.name}), received '${arg}'^0`
1590
+ );
1591
+ }
1592
+ mapped[param.name] = value;
1593
+ return true;
1594
+ });
1595
+ return result ? mapped : null;
1596
+ }
1597
+ async call(source2, args, raw = args.join(" ")) {
1598
+ const parsed = this.mapArguments(source2, args, raw);
1599
+ if (!parsed) return;
1600
+ try {
1601
+ await this.#handler(parsed);
1602
+ } catch (err) {
1603
+ Citizen.trace(
1604
+ `^1command '${raw.split(" ")[0] || raw}' failed to execute!^0
1605
+ ${err.message}`
1606
+ );
1607
+ }
1608
+ }
1609
+ };
1610
+
1611
+ // src/common/Kvp.ts
1612
+ var Kvp = class {
1613
+ static {
1614
+ __name(this, "Kvp");
1615
+ }
1616
+ /**
1617
+ * Returns the value associated with a key as a number.
1618
+ */
1619
+ getNumber(key) {
1620
+ return GetResourceKvpInt(key);
1621
+ }
1622
+ /**
1623
+ * Returns the value associated with a key as a float.
1624
+ */
1625
+ getFloat(key) {
1626
+ return GetResourceKvpFloat(key);
1627
+ }
1628
+ /**
1629
+ * Returns the value associated with a key as a string.
1630
+ */
1631
+ getString(key) {
1632
+ return GetResourceKvpString(key);
1633
+ }
1634
+ /**
1635
+ * Returns the value associated with a key as a parsed JSON string.
1636
+ */
1637
+ getJson(key) {
1638
+ const str = GetResourceKvpString(key);
1639
+ return str ? JSON.parse(str) : null;
1640
+ }
1641
+ /**
1642
+ * Sets the value associated with a key as a number.
1643
+ * @param async set the value using an async operation.
1644
+ */
1645
+ setNumber(key, value, async = false) {
1646
+ return async ? SetResourceKvpIntNoSync(key, value) : SetResourceKvpInt(key, value);
1647
+ }
1648
+ /**
1649
+ * Sets the value associated with a key as a float.
1650
+ * @param async set the value using an async operation.
1651
+ */
1652
+ setFloat(key, value, async = false) {
1653
+ return async ? SetResourceKvpFloatNoSync(key, value) : SetResourceKvpFloat(key, value);
1654
+ }
1655
+ /**
1656
+ * Sets the value associated with a key as a string.
1657
+ * @param async set the value using an async operation.
1658
+ */
1659
+ setString(key, value, async = false) {
1660
+ return async ? SetResourceKvpNoSync(key, value) : SetResourceKvp(key, value);
1661
+ }
1662
+ /**
1663
+ * Sets the value associated with a key as a JSON string.
1664
+ * @param async set the value using an async operation.
1665
+ */
1666
+ setJson(key, value, async = false) {
1667
+ const str = JSON.stringify(value);
1668
+ return async ? SetResourceKvpNoSync(key, str) : SetResourceKvp(key, str);
1669
+ }
1670
+ /**
1671
+ * Sets the value associated with a key as a JSON string.
1672
+ * @param async set the value using an async operation.
1673
+ */
1674
+ set(key, value, async = false) {
1675
+ switch (typeof value) {
1676
+ case "function":
1677
+ case "symbol":
1678
+ throw new Error(`Failed to set Kvp for invalid type '${typeof value}'`);
1679
+ case "undefined":
1680
+ return this.delete(key, async);
1681
+ case "object":
1682
+ return this.setJson(key, value, async);
1683
+ case "boolean":
1684
+ value = value ? 1 : 0;
1685
+ case "number":
1686
+ return Number.isInteger(value) ? this.setNumber(key, value, async) : this.setFloat(key, value, async);
1687
+ default:
1688
+ value = String(value);
1689
+ return this.setString(key, value, async);
1690
+ }
1691
+ }
1692
+ /**
1693
+ * Deletes the specified value for key.
1694
+ * @param async remove the value using an async operation
1695
+ */
1696
+ delete(key, async = false) {
1697
+ return async ? DeleteResourceKvpNoSync(key) : DeleteResourceKvp(key);
1698
+ }
1699
+ /**
1700
+ * Commits pending asynchronous operations to disk, ensuring data consistency.
1701
+ *
1702
+ * Should be called after calling set methods using the async flag.
1703
+ */
1704
+ flush() {
1705
+ FlushResourceKvp();
1706
+ }
1707
+ getAllKeys(prefix) {
1708
+ const keys = [];
1709
+ const handle = StartFindKvp(prefix);
1710
+ if (handle === -1) return keys;
1711
+ let key;
1712
+ do {
1713
+ key = FindKvp(handle);
1714
+ if (key) keys.push(key);
1715
+ } while (key);
1716
+ EndFindKvp(handle);
1717
+ return keys;
1718
+ }
1719
+ /**
1720
+ * Returns an array of keys which match or contain the given keys.
1721
+ */
1722
+ getKeys(prefix) {
1723
+ return typeof prefix === "string" ? this.getAllKeys(prefix) : prefix.flatMap((key) => this.getAllKeys(key));
1724
+ }
1725
+ /**
1726
+ * Get all values from keys in an array as the specified type.
1727
+ */
1728
+ getValuesAsType(prefix, type) {
1729
+ const values = this.getKeys(prefix);
1730
+ return values.map((key) => {
1731
+ switch (type) {
1732
+ case "number":
1733
+ return this.getNumber(key);
1734
+ case "float":
1735
+ return this.getFloat(key);
1736
+ case "string":
1737
+ return this.getString(key);
1738
+ default:
1739
+ return this.getJson(key);
1740
+ }
1741
+ });
1742
+ }
1743
+ };
1744
+
1745
+ // src/common/Resource.ts
1746
+ var Resource = class {
1747
+ constructor(name) {
1748
+ this.name = name;
1749
+ }
1750
+ static {
1751
+ __name(this, "Resource");
1752
+ }
1753
+ getMetadata(metadataKey, index) {
1754
+ return GetResourceMetadata(this.name, metadataKey, index);
1755
+ }
1756
+ getPath() {
1757
+ return GetResourcePath(this.name);
1758
+ }
1759
+ loadFile(fileName) {
1760
+ return LoadResourceFile(this.name, fileName);
1761
+ }
1762
+ saveFile(fileName, data, length) {
1763
+ return SaveResourceFile(this.name, fileName, data, length);
1764
+ }
1765
+ scheduleTick() {
1766
+ return ScheduleResourceTick(this.name);
1767
+ }
1768
+ start() {
1769
+ StartResource(this.name);
1770
+ }
1771
+ stop() {
1772
+ StopResource(this.name);
1773
+ }
1774
+ static startResource(name) {
1775
+ StartResource(name);
1776
+ }
1777
+ static stopResource(name) {
1778
+ StopResource(name);
1779
+ }
1780
+ static resourceCount() {
1781
+ return GetNumResources();
1782
+ }
1783
+ };
1784
+ export {
1785
+ Color,
1786
+ Command,
1787
+ Convar,
1788
+ Delay,
1789
+ Entity2 as Entity,
1790
+ Events,
1791
+ Game,
1792
+ Kvp,
1793
+ Maths,
1794
+ Ped,
1795
+ Player2 as Player,
1796
+ Prop,
1797
+ Quaternion,
1798
+ Resource,
1799
+ Vector2,
1800
+ Vector3,
1801
+ Vector4,
1802
+ Vehicle,
1803
+ cleanPlayerName,
1804
+ enumValues,
1805
+ getStringFromUInt8Array,
1806
+ getUInt32FromUint8Array
1807
+ };