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