@nativewrappers/fivem 0.0.25 → 0.0.28
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/client/Events.js +5 -2
- package/client/Game.js +4 -1
- package/client/models/BaseEntity.d.ts +1 -1
- package/client/models/BaseEntity.js +4 -5
- package/client/models/Ped.d.ts +1 -1
- package/client/models/Ped.js +1 -1
- package/client/models/Player.js +1 -1
- package/client/models/Prop.d.ts +1 -1
- package/client/models/Prop.js +1 -1
- package/client/models/Vehicle.d.ts +1 -1
- package/client/models/Vehicle.js +1 -1
- package/common/utils/Vector.d.ts +5 -5
- package/common/utils/Vector.js +16 -20
- package/package.json +1 -1
- package/server/Events.d.ts +2 -1
- package/server/Events.js +6 -4
- package/server/entities/BaseEntity.d.ts +1 -1
- package/server/entities/BaseEntity.js +1 -1
- package/server/entities/Ped.d.ts +1 -1
- package/server/entities/Ped.js +1 -1
- package/server/entities/Player.d.ts +1 -1
- package/server/entities/Player.js +1 -2
- package/server/entities/Prop.d.ts +1 -1
- package/server/entities/Prop.js +1 -1
- package/server/entities/Vehicle.d.ts +1 -1
- package/server/entities/Vehicle.js +1 -1
- package/server/enum/index.d.ts +0 -1
- package/server/enum/index.js +0 -1
- package/server/enum/ClassTypes.d.ts +0 -11
- package/server/enum/ClassTypes.js +0 -12
- /package/{client/enums → common/utils}/ClassTypes.d.ts +0 -0
- /package/{client/enums → common/utils}/ClassTypes.js +0 -0
package/client/Events.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { ClassTypes } from './enums/ClassTypes';
|
|
1
|
+
import { ClassTypes } from '../common/utils/ClassTypes';
|
|
3
2
|
import { Ped } from './models/Ped';
|
|
4
3
|
import { Vector2, Vector3, Vector4 } from './utils';
|
|
5
4
|
import { Player } from './models/Player';
|
|
@@ -9,6 +8,10 @@ import { BaseEntity } from './models';
|
|
|
9
8
|
const getClassFromArguments = (...args) => {
|
|
10
9
|
const newArgs = [];
|
|
11
10
|
for (const arg of args) {
|
|
11
|
+
if (!arg.type) {
|
|
12
|
+
newArgs.push(arg);
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
12
15
|
switch (arg.type) {
|
|
13
16
|
case ClassTypes.Vector2: {
|
|
14
17
|
newArgs.push(Vector2.fromObject(arg));
|
package/client/Game.js
CHANGED
|
@@ -430,7 +430,10 @@ export class Game {
|
|
|
430
430
|
ExtendWorldBoundaryForPlayer(vec.x, vec.y, vec.z);
|
|
431
431
|
}
|
|
432
432
|
get LastVehicle() {
|
|
433
|
-
|
|
433
|
+
const vehicle = GetPlayersLastVehicle();
|
|
434
|
+
if (vehicle === 0)
|
|
435
|
+
return null;
|
|
436
|
+
return new Vehicle(vehicle);
|
|
434
437
|
}
|
|
435
438
|
static getWaypointBlip() {
|
|
436
439
|
if (!Game.IsWaypointActive)
|
|
@@ -7,7 +7,7 @@ import { Quaternion, Vector3 } from '../utils';
|
|
|
7
7
|
import { EntityBoneCollection } from './';
|
|
8
8
|
import { EntityBone } from './EntityBone';
|
|
9
9
|
import { StateBagChangeHandler } from '../cfx';
|
|
10
|
-
import { ClassTypes } from '
|
|
10
|
+
import { ClassTypes } from '../../common/utils/ClassTypes';
|
|
11
11
|
export declare class BaseEntity {
|
|
12
12
|
static fromNetworkId(networkId: number): BaseEntity | null;
|
|
13
13
|
static fromStateBagName(stateBagName: string): BaseEntity | null;
|
|
@@ -4,17 +4,16 @@ import { Model } from '../Model';
|
|
|
4
4
|
import { Quaternion, Vector3 } from '../utils';
|
|
5
5
|
import { EntityBoneCollection } from './';
|
|
6
6
|
import cfx from '../cfx';
|
|
7
|
-
import { ClassTypes } from '
|
|
7
|
+
import { ClassTypes } from '../../common/utils/ClassTypes';
|
|
8
8
|
export class BaseEntity {
|
|
9
9
|
static fromNetworkId(networkId) {
|
|
10
10
|
return new BaseEntity(NetworkGetEntityFromNetworkId(networkId));
|
|
11
11
|
}
|
|
12
12
|
static fromStateBagName(stateBagName) {
|
|
13
13
|
const entity = GetEntityFromStateBagName(stateBagName);
|
|
14
|
-
if (entity
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
return null;
|
|
14
|
+
if (entity === 0)
|
|
15
|
+
return null;
|
|
16
|
+
return new BaseEntity(entity);
|
|
18
17
|
}
|
|
19
18
|
constructor(handle) {
|
|
20
19
|
this.stateBagCookies = [];
|
package/client/models/Ped.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { WeaponHash } from '../hashes';
|
|
|
4
4
|
import { Tasks } from '../Tasks';
|
|
5
5
|
import { PedBoneCollection, Vehicle } from './';
|
|
6
6
|
import { WeaponCollection } from '../weapon/WeaponCollection';
|
|
7
|
-
import { ClassTypes } from '
|
|
7
|
+
import { ClassTypes } from '../../common/utils/ClassTypes';
|
|
8
8
|
import { BaseEntity } from './BaseEntity';
|
|
9
9
|
export declare class Ped extends BaseEntity {
|
|
10
10
|
static exists(ped: Ped): boolean;
|
package/client/models/Ped.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Gender, RagdollType, SpeechModifier, VehicleSeat, } from '../enums';
|
|
|
3
3
|
import { Tasks } from '../Tasks';
|
|
4
4
|
import { PedBoneCollection, Vehicle } from './';
|
|
5
5
|
import { WeaponCollection } from '../weapon/WeaponCollection';
|
|
6
|
-
import { ClassTypes } from '
|
|
6
|
+
import { ClassTypes } from '../../common/utils/ClassTypes';
|
|
7
7
|
import { BaseEntity } from './BaseEntity';
|
|
8
8
|
export class Ped extends BaseEntity {
|
|
9
9
|
static exists(ped) {
|
package/client/models/Player.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Model, Color } from '..';
|
|
2
2
|
import cfx from '../cfx';
|
|
3
|
-
import { ClassTypes } from '
|
|
3
|
+
import { ClassTypes } from '../../common/utils/ClassTypes';
|
|
4
4
|
import { BaseEntity, Ped } from './';
|
|
5
5
|
export class Player {
|
|
6
6
|
static fromPedHandle(handle) {
|
package/client/models/Prop.d.ts
CHANGED
package/client/models/Prop.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Ped, VehicleDoorCollection, VehicleModCollection, VehicleWheelCollectio
|
|
|
2
2
|
import { RadioStation, VehicleClass, VehicleLandingGearState, VehicleLockStatus, VehicleRoofState, VehicleSeat } from '../enums';
|
|
3
3
|
import { Model } from '../Model';
|
|
4
4
|
import { Vector3 } from '../utils';
|
|
5
|
-
import { ClassTypes } from '
|
|
5
|
+
import { ClassTypes } from '../../common/utils/ClassTypes';
|
|
6
6
|
import { BaseEntity } from './BaseEntity';
|
|
7
7
|
export declare class Vehicle extends BaseEntity {
|
|
8
8
|
static getModelDisplayName(vehicleModel: Model): string;
|
package/client/models/Vehicle.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Ped, VehicleDoorCollection, VehicleModCollection, VehicleWheelCollectio
|
|
|
2
2
|
import { VehicleRoofState, VehicleSeat, } from '../enums';
|
|
3
3
|
import { Game } from '../Game';
|
|
4
4
|
import { Vector3 } from '../utils';
|
|
5
|
-
import { ClassTypes } from '
|
|
5
|
+
import { ClassTypes } from '../../common/utils/ClassTypes';
|
|
6
6
|
import { BaseEntity } from './BaseEntity';
|
|
7
7
|
export class Vehicle extends BaseEntity {
|
|
8
8
|
static getModelDisplayName(vehicleModel) {
|
package/common/utils/Vector.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MsgpackBuffer } from '../types';
|
|
2
|
+
import { ClassTypes } from './ClassTypes';
|
|
2
3
|
/**
|
|
3
4
|
* Represents a 2-dimensional vector.
|
|
4
5
|
*/
|
|
@@ -57,7 +58,7 @@ export declare class Vector {
|
|
|
57
58
|
/**
|
|
58
59
|
* The type identifier for vectors.
|
|
59
60
|
*/
|
|
60
|
-
type:
|
|
61
|
+
type: ClassTypes;
|
|
61
62
|
protected static create(x: number, y?: number): Vector2;
|
|
62
63
|
protected static create(x: number, y?: number, z?: number): Vector3;
|
|
63
64
|
protected static create(x: number, y?: number, z?: number, w?: number): Vector4;
|
|
@@ -195,7 +196,6 @@ export declare class Vector {
|
|
|
195
196
|
constructor(size: number, x?: number, y?: number, z?: number | undefined, w?: number | undefined);
|
|
196
197
|
[Symbol.iterator](): Iterator<number>;
|
|
197
198
|
toString(): string;
|
|
198
|
-
toJSON(): string;
|
|
199
199
|
/**
|
|
200
200
|
* @see Vector.clone
|
|
201
201
|
*/
|
|
@@ -265,7 +265,7 @@ export declare class Vector {
|
|
|
265
265
|
* Represents a 2-dimensional vector.
|
|
266
266
|
*/
|
|
267
267
|
export declare class Vector2 extends Vector {
|
|
268
|
-
type:
|
|
268
|
+
type: ClassTypes;
|
|
269
269
|
static readonly Zero: Vector2;
|
|
270
270
|
/**
|
|
271
271
|
* Constructs a new 2D vector.
|
|
@@ -278,7 +278,7 @@ export declare class Vector2 extends Vector {
|
|
|
278
278
|
* Represents a 3-dimensional vector.
|
|
279
279
|
*/
|
|
280
280
|
export declare class Vector3 extends Vector implements Vec3 {
|
|
281
|
-
type:
|
|
281
|
+
type: ClassTypes;
|
|
282
282
|
z: number;
|
|
283
283
|
static readonly Zero: Vector3;
|
|
284
284
|
/**
|
|
@@ -301,7 +301,7 @@ export declare class Vector3 extends Vector implements Vec3 {
|
|
|
301
301
|
* Represents a 4-dimensional vector.
|
|
302
302
|
*/
|
|
303
303
|
export declare class Vector4 extends Vector {
|
|
304
|
-
type:
|
|
304
|
+
type: ClassTypes;
|
|
305
305
|
z: number;
|
|
306
306
|
w: number;
|
|
307
307
|
static readonly Zero: Vector4;
|
package/common/utils/Vector.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Adapted from https://raw.githubusercontent.com/you21979/typescript-vector/master/vector3.ts
|
|
2
|
+
import { ClassTypes } from './ClassTypes';
|
|
2
3
|
/**
|
|
3
4
|
* A base vector class inherited by all vector classes.
|
|
4
5
|
*/
|
|
@@ -16,16 +17,14 @@ export class Vector {
|
|
|
16
17
|
return new Vector2(x, x);
|
|
17
18
|
if (typeof x === 'object')
|
|
18
19
|
({ x, y, z, w } = x);
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
: `vec${[x, y, z, w].filter(arg => arg !== undefined).length}`;
|
|
22
|
-
switch (type) {
|
|
20
|
+
const size = this instanceof Vector ? this.size : [x, y, z, w].filter(arg => arg !== undefined).length;
|
|
21
|
+
switch (size) {
|
|
23
22
|
default:
|
|
24
|
-
case
|
|
23
|
+
case 2:
|
|
25
24
|
return new Vector2(x, y);
|
|
26
|
-
case
|
|
25
|
+
case 3:
|
|
27
26
|
return new Vector3(x, y, z);
|
|
28
|
-
case
|
|
27
|
+
case 4:
|
|
29
28
|
return new Vector4(x, y, z, w);
|
|
30
29
|
}
|
|
31
30
|
}
|
|
@@ -155,11 +154,12 @@ export class Vector {
|
|
|
155
154
|
static dotProduct(a, b) {
|
|
156
155
|
let result = 0;
|
|
157
156
|
for (const key of ['x', 'y', 'z', 'w']) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
const x = a[key];
|
|
158
|
+
const y = b[key];
|
|
159
|
+
if (!!x && !!y)
|
|
160
|
+
result += x * y;
|
|
161
|
+
else if (x || y)
|
|
161
162
|
throw new Error('Vectors must have the same dimensions');
|
|
162
|
-
}
|
|
163
163
|
}
|
|
164
164
|
return result;
|
|
165
165
|
}
|
|
@@ -247,7 +247,7 @@ export class Vector {
|
|
|
247
247
|
/**
|
|
248
248
|
* The type identifier for vectors.
|
|
249
249
|
*/
|
|
250
|
-
this.type =
|
|
250
|
+
this.type = ClassTypes.Vector2;
|
|
251
251
|
}
|
|
252
252
|
*[Symbol.iterator]() {
|
|
253
253
|
yield this.x;
|
|
@@ -258,11 +258,7 @@ export class Vector {
|
|
|
258
258
|
yield this.w;
|
|
259
259
|
}
|
|
260
260
|
toString() {
|
|
261
|
-
|
|
262
|
-
return `${this.type}(${[x, y, z, w].filter(val => val !== undefined).join(', ')})`;
|
|
263
|
-
}
|
|
264
|
-
toJSON() {
|
|
265
|
-
return this.toString();
|
|
261
|
+
return `vector${this.size}(${this.toArray().join(', ')})`;
|
|
266
262
|
}
|
|
267
263
|
/**
|
|
268
264
|
* @see Vector.clone
|
|
@@ -375,7 +371,7 @@ export class Vector2 extends Vector {
|
|
|
375
371
|
*/
|
|
376
372
|
constructor(x, y = x) {
|
|
377
373
|
super(2, x, y);
|
|
378
|
-
this.type =
|
|
374
|
+
this.type = ClassTypes.Vector2;
|
|
379
375
|
}
|
|
380
376
|
}
|
|
381
377
|
Vector2.Zero = new Vector2(0, 0);
|
|
@@ -391,7 +387,7 @@ export class Vector3 extends Vector {
|
|
|
391
387
|
*/
|
|
392
388
|
constructor(x, y = x, z = y) {
|
|
393
389
|
super(3, x, y, z);
|
|
394
|
-
this.type =
|
|
390
|
+
this.type = ClassTypes.Vector3;
|
|
395
391
|
this.z = z;
|
|
396
392
|
}
|
|
397
393
|
/**
|
|
@@ -421,7 +417,7 @@ export class Vector4 extends Vector {
|
|
|
421
417
|
*/
|
|
422
418
|
constructor(x, y = x, z = y, w = z) {
|
|
423
419
|
super(4, x, y, z, w);
|
|
424
|
-
this.type =
|
|
420
|
+
this.type = ClassTypes.Vector4;
|
|
425
421
|
this.z = z;
|
|
426
422
|
this.w = w;
|
|
427
423
|
}
|
package/package.json
CHANGED
package/server/Events.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Player } from './entities/Player';
|
|
2
2
|
export type NetEvent = (player: Player, ...args: any[]) => void;
|
|
3
|
+
export type LocalEvent = (...args: any[]) => void;
|
|
3
4
|
export declare class Events {
|
|
4
5
|
static cancel(): void;
|
|
5
6
|
static wasCanceled(): boolean;
|
|
@@ -11,5 +12,5 @@ export declare class Events {
|
|
|
11
12
|
/**
|
|
12
13
|
* An on wrapper that properly converts the classes
|
|
13
14
|
*/
|
|
14
|
-
static on: (eventName: string, event:
|
|
15
|
+
static on: (eventName: string, event: LocalEvent) => void;
|
|
15
16
|
}
|
package/server/Events.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
import { Ped, Prop, Vehicle, Entity } from './entities';
|
|
3
2
|
import { Player } from './entities/Player';
|
|
4
|
-
import { ClassTypes } from '
|
|
3
|
+
import { ClassTypes } from '../common/utils/ClassTypes';
|
|
5
4
|
import { Vector2, Vector3, Vector4 } from './utils';
|
|
6
5
|
const getClassFromArguments = (...args) => {
|
|
7
6
|
const newArgs = [];
|
|
8
7
|
for (const arg of args) {
|
|
8
|
+
if (!arg.type) {
|
|
9
|
+
newArgs.push(arg);
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
9
12
|
switch (arg.type) {
|
|
10
13
|
case ClassTypes.Vector2: {
|
|
11
14
|
newArgs.push(Vector2.fromObject(arg));
|
|
@@ -71,7 +74,6 @@ Events.onNet = (eventName, event) => {
|
|
|
71
74
|
*/
|
|
72
75
|
Events.on = (eventName, event) => {
|
|
73
76
|
on(eventName, (...args) => {
|
|
74
|
-
|
|
75
|
-
event(ply, ...getClassFromArguments(...args));
|
|
77
|
+
event(...getClassFromArguments(...args));
|
|
76
78
|
});
|
|
77
79
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="@citizenfx/server" />
|
|
2
|
-
import { ClassTypes } from '
|
|
2
|
+
import { ClassTypes } from '../../common/utils/ClassTypes';
|
|
3
3
|
import { eEntityType } from '../enum/eEntityType';
|
|
4
4
|
import { PopulationType } from '../enum/PopulationType';
|
|
5
5
|
import { Hash } from '../type/Hash';
|
package/server/entities/Ped.d.ts
CHANGED
package/server/entities/Ped.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import cfx from '../cfx';
|
|
2
|
-
import { ClassTypes } from '
|
|
2
|
+
import { ClassTypes } from '../../common/utils/ClassTypes';
|
|
3
3
|
import { cleanPlayerName } from '../utils';
|
|
4
4
|
import { Vector3 } from '../utils';
|
|
5
5
|
import { Ped } from './Ped';
|
|
@@ -129,7 +129,6 @@ export class Player {
|
|
|
129
129
|
drop(reason = 'No reason specified') {
|
|
130
130
|
DropPlayer(this.Src, reason);
|
|
131
131
|
}
|
|
132
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
132
|
emit(eventName, ...args) {
|
|
134
133
|
TriggerClientEvent(eventName, this.source, ...args);
|
|
135
134
|
}
|
package/server/entities/Prop.js
CHANGED
package/server/enum/index.d.ts
CHANGED
package/server/enum/index.js
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export var ClassTypes;
|
|
2
|
-
(function (ClassTypes) {
|
|
3
|
-
ClassTypes[ClassTypes["Ped"] = 0] = "Ped";
|
|
4
|
-
ClassTypes[ClassTypes["Prop"] = 1] = "Prop";
|
|
5
|
-
ClassTypes[ClassTypes["Vehicle"] = 2] = "Vehicle";
|
|
6
|
-
ClassTypes[ClassTypes["Entity"] = 3] = "Entity";
|
|
7
|
-
ClassTypes[ClassTypes["Player"] = 4] = "Player";
|
|
8
|
-
ClassTypes[ClassTypes["Vector2"] = 5] = "Vector2";
|
|
9
|
-
ClassTypes[ClassTypes["Vector3"] = 6] = "Vector3";
|
|
10
|
-
ClassTypes[ClassTypes["Vector4"] = 7] = "Vector4";
|
|
11
|
-
ClassTypes[ClassTypes["Quanterion"] = 8] = "Quanterion";
|
|
12
|
-
})(ClassTypes || (ClassTypes = {}));
|
|
File without changes
|
|
File without changes
|