@nativewrappers/fivem 0.0.21 → 0.0.22
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 +7 -7
- package/common/utils/Vector.js +2 -8
- 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
|
@@ -114,21 +114,21 @@ export declare class Vector {
|
|
|
114
114
|
* @param y - The value to add to the y-component.
|
|
115
115
|
* @returns A new vector with the y-component incremented.
|
|
116
116
|
*/
|
|
117
|
-
static addY<T extends VectorType, U extends VectorLike>(this: T, obj: U, y: number): InferVector<U
|
|
117
|
+
static addY<T extends VectorType, U extends VectorLike>(this: T, obj: U, y: number): InferVector<U>;
|
|
118
118
|
/**
|
|
119
119
|
* Adds a scalar value to the z-component of a vector.
|
|
120
120
|
* @param obj - The vector.
|
|
121
121
|
* @param z - The value to add to the z-component.
|
|
122
122
|
* @returns A new vector with the z-component incremented.
|
|
123
123
|
*/
|
|
124
|
-
static addZ<T extends VectorType, U extends VectorLike>(this: T, obj: U, z: number): InferVector<U
|
|
124
|
+
static addZ<T extends VectorType, U extends VectorLike>(this: T, obj: U, z: number): InferVector<U>;
|
|
125
125
|
/**
|
|
126
126
|
* Adds a scalar value to the w-component of a vector.
|
|
127
127
|
* @param obj - The vector.
|
|
128
128
|
* @param w - The value to add to the w-component.
|
|
129
129
|
* @returns A new vector with the w-component incremented.
|
|
130
130
|
*/
|
|
131
|
-
static addW<T extends VectorType, U extends VectorLike>(this: T, obj: U, w: number): InferVector<U
|
|
131
|
+
static addW<T extends VectorType, U extends VectorLike>(this: T, obj: U, w: number): InferVector<U>;
|
|
132
132
|
/**
|
|
133
133
|
* Subtracts one vector from another or subtracts a scalar value from a vector.
|
|
134
134
|
* @param a - The vector.
|
|
@@ -240,7 +240,7 @@ export declare class Vector {
|
|
|
240
240
|
/**
|
|
241
241
|
* @see Vector.addY
|
|
242
242
|
*/
|
|
243
|
-
addY(x: number): InferVector<this
|
|
243
|
+
addY(x: number): InferVector<this>;
|
|
244
244
|
/**
|
|
245
245
|
* @see Vector.subtract
|
|
246
246
|
*/
|
|
@@ -298,7 +298,7 @@ export declare class Vector3 extends Vector implements Vec3 {
|
|
|
298
298
|
/**
|
|
299
299
|
* @see Vector.addZ
|
|
300
300
|
*/
|
|
301
|
-
addZ(z: number): InferVector<this
|
|
301
|
+
addZ(z: number): InferVector<this>;
|
|
302
302
|
/**
|
|
303
303
|
* @see Vector.crossProduct
|
|
304
304
|
*/
|
|
@@ -323,11 +323,11 @@ export declare class Vector4 extends Vector {
|
|
|
323
323
|
/**
|
|
324
324
|
* @see Vector.addZ
|
|
325
325
|
*/
|
|
326
|
-
addZ(z: number): InferVector<this
|
|
326
|
+
addZ(z: number): InferVector<this>;
|
|
327
327
|
/**
|
|
328
328
|
* @see Vector.addW
|
|
329
329
|
*/
|
|
330
|
-
addW(w: number): InferVector<this
|
|
330
|
+
addW(w: number): InferVector<this>;
|
|
331
331
|
/**
|
|
332
332
|
* @see Vector.crossProduct
|
|
333
333
|
*/
|
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;
|
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);
|