@nativewrappers/fivem 0.0.21 → 0.0.24
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/common/utils/Vector.d.ts +15 -22
- package/common/utils/Vector.js +5 -13
- package/package.json +1 -1
- package/server/entities/BaseEntity.d.ts +7 -1
- package/server/entities/BaseEntity.js +23 -2
- package/server/entities/Entity.d.ts +1 -0
- package/server/entities/Entity.js +3 -0
- package/server/entities/Ped.d.ts +10 -6
- package/server/entities/Ped.js +24 -8
- package/server/entities/Prop.d.ts +2 -1
- package/server/entities/Prop.js +11 -2
- package/server/entities/Vehicle.d.ts +2 -2
- package/server/entities/Vehicle.js +12 -7
package/common/utils/Vector.d.ts
CHANGED
|
@@ -9,26 +9,19 @@ export interface Vec2 {
|
|
|
9
9
|
/**
|
|
10
10
|
* Represents a 3-dimensional vector.
|
|
11
11
|
*/
|
|
12
|
-
export interface Vec3 {
|
|
13
|
-
x: number;
|
|
14
|
-
y: number;
|
|
12
|
+
export interface Vec3 extends Vec2 {
|
|
15
13
|
z: number;
|
|
16
14
|
}
|
|
17
15
|
/**
|
|
18
16
|
* Represents a 4-dimensional vector.
|
|
19
17
|
*/
|
|
20
|
-
export interface Vec4 {
|
|
21
|
-
x: number;
|
|
22
|
-
y: number;
|
|
23
|
-
z: number;
|
|
18
|
+
export interface Vec4 extends Vec3 {
|
|
24
19
|
w: number;
|
|
25
20
|
}
|
|
26
21
|
/**
|
|
27
22
|
* An object with vector components.
|
|
28
23
|
*/
|
|
29
|
-
interface
|
|
30
|
-
x: number;
|
|
31
|
-
y: number;
|
|
24
|
+
export interface Vec extends Vec2 {
|
|
32
25
|
z?: number;
|
|
33
26
|
w?: number;
|
|
34
27
|
}
|
|
@@ -47,7 +40,7 @@ type VectorType = typeof Vector;
|
|
|
47
40
|
/**
|
|
48
41
|
* Represents an object or class that can be treated as a vector.
|
|
49
42
|
*/
|
|
50
|
-
type VectorLike =
|
|
43
|
+
type VectorLike = Vec | Vector;
|
|
51
44
|
/**
|
|
52
45
|
* Utility type to get the vector type of an object based on its component.
|
|
53
46
|
*/
|
|
@@ -114,21 +107,21 @@ export declare class Vector {
|
|
|
114
107
|
* @param y - The value to add to the y-component.
|
|
115
108
|
* @returns A new vector with the y-component incremented.
|
|
116
109
|
*/
|
|
117
|
-
static addY<T extends VectorType, U extends VectorLike>(this: T, obj: U, y: number): InferVector<U
|
|
110
|
+
static addY<T extends VectorType, U extends VectorLike>(this: T, obj: U, y: number): InferVector<U>;
|
|
118
111
|
/**
|
|
119
112
|
* Adds a scalar value to the z-component of a vector.
|
|
120
113
|
* @param obj - The vector.
|
|
121
114
|
* @param z - The value to add to the z-component.
|
|
122
115
|
* @returns A new vector with the z-component incremented.
|
|
123
116
|
*/
|
|
124
|
-
static addZ<T extends VectorType, U extends
|
|
117
|
+
static addZ<T extends VectorType, U extends Vec3 | Vec4>(this: T, obj: U, z: number): InferVector<U>;
|
|
125
118
|
/**
|
|
126
119
|
* Adds a scalar value to the w-component of a vector.
|
|
127
120
|
* @param obj - The vector.
|
|
128
121
|
* @param w - The value to add to the w-component.
|
|
129
122
|
* @returns A new vector with the w-component incremented.
|
|
130
123
|
*/
|
|
131
|
-
static addW<T extends VectorType, U extends
|
|
124
|
+
static addW<T extends VectorType, U extends Vec4>(this: T, obj: U, w: number): InferVector<U>;
|
|
132
125
|
/**
|
|
133
126
|
* Subtracts one vector from another or subtracts a scalar value from a vector.
|
|
134
127
|
* @param a - The vector.
|
|
@@ -163,7 +156,7 @@ export declare class Vector {
|
|
|
163
156
|
* @param b - The second vector.
|
|
164
157
|
* @returns A new vector perpendicular to both input vectors.
|
|
165
158
|
*/
|
|
166
|
-
static crossProduct<T extends VectorType, U extends
|
|
159
|
+
static crossProduct<T extends VectorType, U extends Vec3 | Vec4>(this: T, a: U, b: U): U;
|
|
167
160
|
/**
|
|
168
161
|
* Normalizes a vector, producing a new vector with the same direction but with a magnitude of 1.
|
|
169
162
|
* @param vector - The vector to be normalized.
|
|
@@ -240,7 +233,7 @@ export declare class Vector {
|
|
|
240
233
|
/**
|
|
241
234
|
* @see Vector.addY
|
|
242
235
|
*/
|
|
243
|
-
addY(x: number): InferVector<this
|
|
236
|
+
addY(x: number): InferVector<this>;
|
|
244
237
|
/**
|
|
245
238
|
* @see Vector.subtract
|
|
246
239
|
*/
|
|
@@ -256,7 +249,7 @@ export declare class Vector {
|
|
|
256
249
|
/**
|
|
257
250
|
* Converts the vector to an array of its components.
|
|
258
251
|
*/
|
|
259
|
-
toArray():
|
|
252
|
+
toArray<T extends this>(): VectorArray<T>;
|
|
260
253
|
/**
|
|
261
254
|
* Replaces the components of the vector with the components of another vector object.
|
|
262
255
|
* @param v - The object whose components will replace the current vector's components.
|
|
@@ -298,11 +291,11 @@ export declare class Vector3 extends Vector implements Vec3 {
|
|
|
298
291
|
/**
|
|
299
292
|
* @see Vector.addZ
|
|
300
293
|
*/
|
|
301
|
-
addZ(z: number): InferVector<this
|
|
294
|
+
addZ(z: number): InferVector<this>;
|
|
302
295
|
/**
|
|
303
296
|
* @see Vector.crossProduct
|
|
304
297
|
*/
|
|
305
|
-
crossProduct(v:
|
|
298
|
+
crossProduct(v: Vec3 | Vec4): Vec3 | Vec4;
|
|
306
299
|
}
|
|
307
300
|
/**
|
|
308
301
|
* Represents a 4-dimensional vector.
|
|
@@ -323,14 +316,14 @@ export declare class Vector4 extends Vector {
|
|
|
323
316
|
/**
|
|
324
317
|
* @see Vector.addZ
|
|
325
318
|
*/
|
|
326
|
-
addZ(z: number): InferVector<this
|
|
319
|
+
addZ(z: number): InferVector<this>;
|
|
327
320
|
/**
|
|
328
321
|
* @see Vector.addW
|
|
329
322
|
*/
|
|
330
|
-
addW(w: number): InferVector<this
|
|
323
|
+
addW(w: number): InferVector<this>;
|
|
331
324
|
/**
|
|
332
325
|
* @see Vector.crossProduct
|
|
333
326
|
*/
|
|
334
|
-
crossProduct(v:
|
|
327
|
+
crossProduct(v: Vec3 | Vec4): Vec3 | Vec4;
|
|
335
328
|
}
|
|
336
329
|
export {};
|
package/common/utils/Vector.js
CHANGED
|
@@ -58,8 +58,8 @@ export class Vector {
|
|
|
58
58
|
static operate(a, b, operator) {
|
|
59
59
|
let { x, y, z, w } = a;
|
|
60
60
|
const isNumber = typeof b === 'number';
|
|
61
|
-
x = operator(x, isNumber ? b : b.x);
|
|
62
|
-
y = operator(y, isNumber ? b : b.y);
|
|
61
|
+
x = operator(x, isNumber ? b : b.x ?? 0);
|
|
62
|
+
y = operator(y, isNumber ? b : b.y ?? 0);
|
|
63
63
|
if (z)
|
|
64
64
|
z = operator(z, isNumber ? b : b.z ?? 0);
|
|
65
65
|
if (w)
|
|
@@ -93,8 +93,6 @@ export class Vector {
|
|
|
93
93
|
* @returns A new vector with the y-component incremented.
|
|
94
94
|
*/
|
|
95
95
|
static addY(obj, y) {
|
|
96
|
-
if (typeof obj.y !== 'number')
|
|
97
|
-
return;
|
|
98
96
|
const vec = this.clone(obj);
|
|
99
97
|
vec.y += y;
|
|
100
98
|
return vec;
|
|
@@ -106,8 +104,6 @@ export class Vector {
|
|
|
106
104
|
* @returns A new vector with the z-component incremented.
|
|
107
105
|
*/
|
|
108
106
|
static addZ(obj, z) {
|
|
109
|
-
if (typeof obj.z !== 'number')
|
|
110
|
-
return;
|
|
111
107
|
const vec = this.clone(obj);
|
|
112
108
|
vec.z += z;
|
|
113
109
|
return vec;
|
|
@@ -119,8 +115,6 @@ export class Vector {
|
|
|
119
115
|
* @returns A new vector with the w-component incremented.
|
|
120
116
|
*/
|
|
121
117
|
static addW(obj, w) {
|
|
122
|
-
if (typeof obj.w !== 'number')
|
|
123
|
-
return;
|
|
124
118
|
const vec = this.clone(obj);
|
|
125
119
|
vec.w += w;
|
|
126
120
|
return vec;
|
|
@@ -161,11 +155,9 @@ export class Vector {
|
|
|
161
155
|
static dotProduct(a, b) {
|
|
162
156
|
let result = 0;
|
|
163
157
|
for (const key of ['x', 'y', 'z', 'w']) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
result += v1 * v2;
|
|
168
|
-
else if (v1 || v2) {
|
|
158
|
+
if (key in a && key in b)
|
|
159
|
+
result += a[key] * b[key];
|
|
160
|
+
else {
|
|
169
161
|
throw new Error('Vectors must have the same dimensions');
|
|
170
162
|
}
|
|
171
163
|
}
|
package/package.json
CHANGED
|
@@ -9,12 +9,18 @@ export declare class BaseEntity {
|
|
|
9
9
|
protected handle: number;
|
|
10
10
|
protected type: ClassTypes;
|
|
11
11
|
constructor(handle: number);
|
|
12
|
+
static fromNetworkId(networkId: number): BaseEntity | null;
|
|
13
|
+
static fromStateBagName(stateBagName: string): BaseEntity | null;
|
|
12
14
|
get State(): StateBagInterface;
|
|
13
15
|
get Handle(): number;
|
|
14
16
|
get Owner(): number;
|
|
15
17
|
get FirstOwner(): number;
|
|
16
18
|
get Exists(): boolean;
|
|
17
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @returns the entity that the calling entity is attached to, or null if
|
|
21
|
+
* there is none
|
|
22
|
+
*/
|
|
23
|
+
get AttachedTo(): BaseEntity | null;
|
|
18
24
|
get Position(): Vector3;
|
|
19
25
|
get Heading(): number;
|
|
20
26
|
get PositionAndHeading(): Vector4;
|
|
@@ -7,6 +7,18 @@ export class BaseEntity {
|
|
|
7
7
|
this.handle = handle;
|
|
8
8
|
this.type = ClassTypes.Entity;
|
|
9
9
|
}
|
|
10
|
+
static fromNetworkId(networkId) {
|
|
11
|
+
const ent = NetworkGetEntityFromNetworkId(networkId);
|
|
12
|
+
if (ent === 0)
|
|
13
|
+
return null;
|
|
14
|
+
return new BaseEntity(ent);
|
|
15
|
+
}
|
|
16
|
+
static fromStateBagName(stateBagName) {
|
|
17
|
+
const ent = GetEntityFromStateBagName(stateBagName);
|
|
18
|
+
if (ent === 0)
|
|
19
|
+
return null;
|
|
20
|
+
return new BaseEntity(ent);
|
|
21
|
+
}
|
|
10
22
|
get State() {
|
|
11
23
|
return cfx.Entity(this.handle).state;
|
|
12
24
|
}
|
|
@@ -22,8 +34,15 @@ export class BaseEntity {
|
|
|
22
34
|
get Exists() {
|
|
23
35
|
return this.handle !== 0 && DoesEntityExist(this.handle);
|
|
24
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* @returns the entity that the calling entity is attached to, or null if
|
|
39
|
+
* there is none
|
|
40
|
+
*/
|
|
25
41
|
get AttachedTo() {
|
|
26
|
-
|
|
42
|
+
const ent = GetEntityAttachedTo(this.handle);
|
|
43
|
+
if (ent === 0)
|
|
44
|
+
return null;
|
|
45
|
+
return new BaseEntity(ent);
|
|
27
46
|
}
|
|
28
47
|
get Position() {
|
|
29
48
|
return Vector3.fromArray(GetEntityCoords(this.handle));
|
|
@@ -83,6 +102,8 @@ export class BaseEntity {
|
|
|
83
102
|
return HasEntityBeenMarkedAsNoLongerNeeded(this.handle);
|
|
84
103
|
}
|
|
85
104
|
delete() {
|
|
86
|
-
|
|
105
|
+
if (this.Exists) {
|
|
106
|
+
DeleteEntity(this.handle);
|
|
107
|
+
}
|
|
87
108
|
}
|
|
88
109
|
}
|
package/server/entities/Ped.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ClassTypes } from '../enum/ClassTypes';
|
|
2
2
|
import { Hash } from '../type/Hash';
|
|
3
3
|
import { BaseEntity } from './BaseEntity';
|
|
4
|
+
import { Vehicle } from './Vehicle';
|
|
4
5
|
export declare class Ped extends BaseEntity {
|
|
5
6
|
protected type: ClassTypes;
|
|
6
7
|
constructor(handle: number);
|
|
@@ -9,9 +10,9 @@ export declare class Ped extends BaseEntity {
|
|
|
9
10
|
* @returns Iterable list of Peds.
|
|
10
11
|
*/
|
|
11
12
|
static AllPeds(): IterableIterator<Ped>;
|
|
12
|
-
static fromNetworkId(netId: number): Ped;
|
|
13
|
+
static fromNetworkId(netId: number): Ped | null;
|
|
14
|
+
static fromStateBagName(stateBagName: string): Ped | null;
|
|
13
15
|
static fromSource(source: number): Ped;
|
|
14
|
-
static fromHandle(handle: number): Ped;
|
|
15
16
|
get Armour(): number;
|
|
16
17
|
get CauseOfDeath(): Hash;
|
|
17
18
|
get DesiredHeading(): number;
|
|
@@ -19,10 +20,13 @@ export declare class Ped extends BaseEntity {
|
|
|
19
20
|
get TaskCommand(): Hash;
|
|
20
21
|
get TaskStage(): number;
|
|
21
22
|
get LastSourceOfDamage(): number;
|
|
22
|
-
get DeathCause():
|
|
23
|
+
get DeathCause(): Hash;
|
|
23
24
|
get Weapon(): Hash;
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* @returns the current vehicle the ped is in, or null if it doesn't exist
|
|
27
|
+
*/
|
|
28
|
+
get CurrentVehicle(): Vehicle | null;
|
|
29
|
+
get LastVehicle(): Vehicle | null;
|
|
26
30
|
get IsPlayer(): boolean;
|
|
27
|
-
|
|
31
|
+
getSpecificTaskType(index: number): number;
|
|
28
32
|
}
|
package/server/entities/Ped.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ClassTypes } from '../enum/ClassTypes';
|
|
2
2
|
import { BaseEntity } from './BaseEntity';
|
|
3
|
+
import { Vehicle } from './Vehicle';
|
|
3
4
|
export class Ped extends BaseEntity {
|
|
4
5
|
constructor(handle) {
|
|
5
6
|
super(handle);
|
|
@@ -15,14 +16,20 @@ export class Ped extends BaseEntity {
|
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
static fromNetworkId(netId) {
|
|
18
|
-
|
|
19
|
+
const ent = NetworkGetEntityFromNetworkId(netId);
|
|
20
|
+
if (ent === 0)
|
|
21
|
+
return null;
|
|
22
|
+
return new Ped(ent);
|
|
23
|
+
}
|
|
24
|
+
static fromStateBagName(stateBagName) {
|
|
25
|
+
const handle = GetEntityFromStateBagName(stateBagName);
|
|
26
|
+
if (handle === 0)
|
|
27
|
+
return null;
|
|
28
|
+
return new Ped(handle);
|
|
19
29
|
}
|
|
20
30
|
static fromSource(source) {
|
|
21
31
|
return new Ped(GetPlayerPed(source));
|
|
22
32
|
}
|
|
23
|
-
static fromHandle(handle) {
|
|
24
|
-
return new Ped(handle);
|
|
25
|
-
}
|
|
26
33
|
get Armour() {
|
|
27
34
|
return GetPedArmour(this.handle);
|
|
28
35
|
}
|
|
@@ -50,16 +57,25 @@ export class Ped extends BaseEntity {
|
|
|
50
57
|
get Weapon() {
|
|
51
58
|
return GetSelectedPedWeapon(this.handle);
|
|
52
59
|
}
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
/**
|
|
61
|
+
* @returns the current vehicle the ped is in, or null if it doesn't exist
|
|
62
|
+
*/
|
|
63
|
+
get CurrentVehicle() {
|
|
64
|
+
const vehicle = GetVehiclePedIsIn(this.handle, false);
|
|
65
|
+
if (vehicle === 0)
|
|
66
|
+
return null;
|
|
67
|
+
return new Vehicle(vehicle);
|
|
55
68
|
}
|
|
56
69
|
get LastVehicle() {
|
|
57
|
-
|
|
70
|
+
const vehicle = GetVehiclePedIsIn(this.handle, false);
|
|
71
|
+
if (vehicle === 0)
|
|
72
|
+
return null;
|
|
73
|
+
return new Vehicle(GetVehiclePedIsIn(this.handle, true));
|
|
58
74
|
}
|
|
59
75
|
get IsPlayer() {
|
|
60
76
|
return IsPedAPlayer(this.handle);
|
|
61
77
|
}
|
|
62
|
-
|
|
78
|
+
getSpecificTaskType(index) {
|
|
63
79
|
return GetPedSpecificTaskType(this.handle, index);
|
|
64
80
|
}
|
|
65
81
|
}
|
|
@@ -8,6 +8,7 @@ export declare class Prop extends BaseEntity {
|
|
|
8
8
|
* @returns Iterable list of Props.
|
|
9
9
|
*/
|
|
10
10
|
static AllProps(): IterableIterator<Prop>;
|
|
11
|
-
static fromNetworkId(
|
|
11
|
+
static fromNetworkId(networkId: number): Prop | null;
|
|
12
|
+
static fromStateBagName(stateBagName: string): Prop | null;
|
|
12
13
|
static fromHandle(handle: number): Prop;
|
|
13
14
|
}
|
package/server/entities/Prop.js
CHANGED
|
@@ -14,8 +14,17 @@ export class Prop extends BaseEntity {
|
|
|
14
14
|
yield new Prop(prop);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
static fromNetworkId(
|
|
18
|
-
|
|
17
|
+
static fromNetworkId(networkId) {
|
|
18
|
+
const ent = NetworkGetEntityFromNetworkId(networkId);
|
|
19
|
+
if (ent === 0)
|
|
20
|
+
return null;
|
|
21
|
+
return new Prop(ent);
|
|
22
|
+
}
|
|
23
|
+
static fromStateBagName(stateBagName) {
|
|
24
|
+
const ent = GetEntityFromStateBagName(stateBagName);
|
|
25
|
+
if (ent === 0)
|
|
26
|
+
return null;
|
|
27
|
+
return new Prop(ent);
|
|
19
28
|
}
|
|
20
29
|
static fromHandle(handle) {
|
|
21
30
|
return new Prop(handle);
|
|
@@ -12,8 +12,8 @@ export declare class Vehicle extends BaseEntity {
|
|
|
12
12
|
* @returns Iterable list of Vehicles.
|
|
13
13
|
*/
|
|
14
14
|
static AllVehicles(): IterableIterator<Vehicle>;
|
|
15
|
-
static fromNetworkId(
|
|
16
|
-
static
|
|
15
|
+
static fromNetworkId(networkId: number): Vehicle | null;
|
|
16
|
+
static fromStateBagName(stateBageName: string): Vehicle | null;
|
|
17
17
|
get IsEngineRunning(): boolean;
|
|
18
18
|
get IsPrimaryColourCustom(): boolean;
|
|
19
19
|
get IsSecondaryColourCustom(): boolean;
|
|
@@ -15,11 +15,17 @@ export class Vehicle extends BaseEntity {
|
|
|
15
15
|
yield new Vehicle(veh);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
static fromNetworkId(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return new Vehicle(
|
|
18
|
+
static fromNetworkId(networkId) {
|
|
19
|
+
const ent = NetworkGetEntityFromNetworkId(networkId);
|
|
20
|
+
if (ent === 0)
|
|
21
|
+
return null;
|
|
22
|
+
return new Vehicle(ent);
|
|
23
|
+
}
|
|
24
|
+
static fromStateBagName(stateBageName) {
|
|
25
|
+
const ent = GetEntityFromStateBagName(stateBageName);
|
|
26
|
+
if (ent === 0)
|
|
27
|
+
return null;
|
|
28
|
+
return new Vehicle(ent);
|
|
23
29
|
}
|
|
24
30
|
get IsEngineRunning() {
|
|
25
31
|
return GetIsVehicleEngineRunning(this.handle);
|
|
@@ -79,7 +85,6 @@ export class Vehicle extends BaseEntity {
|
|
|
79
85
|
return GetVehicleInteriorColour(this.handle);
|
|
80
86
|
}
|
|
81
87
|
get LightsState() {
|
|
82
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
83
88
|
const [_, lightsOn, highbeansOn] = GetVehicleLightsState(this.handle);
|
|
84
89
|
return [lightsOn, highbeansOn];
|
|
85
90
|
}
|
|
@@ -132,7 +137,7 @@ export class Vehicle extends BaseEntity {
|
|
|
132
137
|
return IsVehicleSirenOn(this.handle);
|
|
133
138
|
}
|
|
134
139
|
get MaxHealth() {
|
|
135
|
-
return
|
|
140
|
+
return GetEntityMaxHealth(this.handle);
|
|
136
141
|
}
|
|
137
142
|
get ScriptTaskCommand() {
|
|
138
143
|
return GetPedScriptTaskCommand(this.handle);
|