@nativewrappers/fivem 0.0.24 → 0.0.27

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 CHANGED
@@ -1,5 +1,4 @@
1
- /* eslint-disable */
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.d.ts CHANGED
@@ -9,6 +9,10 @@ export declare abstract class Game {
9
9
  * @param input The input string to calculate the hash
10
10
  */
11
11
  static generateHash(input: string): number;
12
+ static setLocalPlayerGhosted(isGhosted: boolean, inverseGhost: boolean): void;
13
+ static setGhostAlpha(alpha: number): void;
14
+ static resetGhostAlpha(): void;
15
+ static setGhostingInverted(isInverted: boolean): void;
12
16
  /**
13
17
  * Gets the game language
14
18
  */
package/client/Game.js CHANGED
@@ -19,6 +19,20 @@ export class Game {
19
19
  this.hashCache.set(input, hash);
20
20
  return hash;
21
21
  }
22
+ static setLocalPlayerGhosted(isGhosted, inverseGhost) {
23
+ // @ts-ignore
24
+ SetLocalPlayerAsGhost(isGhosted, inverseGhost);
25
+ }
26
+ static setGhostAlpha(alpha) {
27
+ SetGhostedEntityAlpha(alpha);
28
+ }
29
+ static resetGhostAlpha() {
30
+ ResetGhostedEntityAlpha();
31
+ }
32
+ static setGhostingInverted(isInverted) {
33
+ // actual name is SET_INVERT_GHOSTING
34
+ N_0xd7b6c73cad419bcf(isInverted);
35
+ }
22
36
  /**
23
37
  * Gets the game language
24
38
  */
@@ -416,7 +430,10 @@ export class Game {
416
430
  ExtendWorldBoundaryForPlayer(vec.x, vec.y, vec.z);
417
431
  }
418
432
  get LastVehicle() {
419
- return new Vehicle(GetPlayersLastVehicle());
433
+ const vehicle = GetPlayersLastVehicle();
434
+ if (vehicle === 0)
435
+ return null;
436
+ return new Vehicle(vehicle);
420
437
  }
421
438
  static getWaypointBlip() {
422
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 '../enums/ClassTypes';
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 '../enums/ClassTypes';
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 !== 0) {
15
- return new BaseEntity(entity);
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 = [];
@@ -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 '../enums/ClassTypes';
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;
@@ -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 '../enums/ClassTypes';
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) {
@@ -37,6 +37,8 @@ export declare class Player {
37
37
  get PvPEnabled(): boolean;
38
38
  set PvPEnabled(value: boolean);
39
39
  get IsDead(): boolean;
40
+ set DisableFiring(value: boolean);
41
+ set Ghosted(isGhosted: boolean);
40
42
  get EntityPlayerIsAimingAt(): BaseEntity | null;
41
43
  get StealthNoise(): number;
42
44
  get FakeWantedLevel(): number;
@@ -1,6 +1,6 @@
1
1
  import { Model, Color } from '..';
2
2
  import cfx from '../cfx';
3
- import { ClassTypes } from '../enums/ClassTypes';
3
+ import { ClassTypes } from '../../common/utils/ClassTypes';
4
4
  import { BaseEntity, Ped } from './';
5
5
  export class Player {
6
6
  static fromPedHandle(handle) {
@@ -90,10 +90,19 @@ export class Player {
90
90
  get IsDead() {
91
91
  return IsPlayerDead(this.handle);
92
92
  }
93
- // Should this even be here?
94
- // public set DisableFiring(value: boolean) {
95
- // DisablePlayerFiring(this.handle, value);
96
- // }
93
+ set DisableFiring(value) {
94
+ DisablePlayerFiring(this.handle, value);
95
+ }
96
+ set Ghosted(isGhosted) {
97
+ // if we're the local player then use the local version of the native
98
+ if (this.Handle === 128) {
99
+ SetLocalPlayerAsGhost(isGhosted);
100
+ }
101
+ else {
102
+ // actual name is SET_REMOTE_PLAYER_AS_GHOST
103
+ SetRelationshipToPlayer(this.handle, isGhosted);
104
+ }
105
+ }
97
106
  get EntityPlayerIsAimingAt() {
98
107
  const [entityHit, entity] = GetEntityPlayerIsFreeAimingAt(this.handle);
99
108
  if (entityHit) {
@@ -1,4 +1,4 @@
1
- import { ClassTypes } from '../enums/ClassTypes';
1
+ import { ClassTypes } from '../../common/utils/ClassTypes';
2
2
  import { BaseEntity } from './BaseEntity';
3
3
  export declare class Prop extends BaseEntity {
4
4
  static exists(prop: Prop): boolean;
@@ -1,4 +1,4 @@
1
- import { ClassTypes } from '../enums/ClassTypes';
1
+ import { ClassTypes } from '../../common/utils/ClassTypes';
2
2
  import { BaseEntity } from './BaseEntity';
3
3
  export class Prop extends BaseEntity {
4
4
  static exists(prop) {
@@ -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 '../enums/ClassTypes';
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;
@@ -124,6 +124,12 @@ export declare class Vehicle extends BaseEntity {
124
124
  set IsBurnoutForced(value: boolean);
125
125
  get IsInBurnout(): boolean;
126
126
  get Driver(): Ped;
127
+ get Ghosted(): boolean;
128
+ set GhostedForGhostPlayers(isGhostedForGhostPlayers: boolean);
129
+ set Ghosted(isGhosted: boolean);
130
+ static set GhostAlpha(alpha: number);
131
+ get IsInGhostCollision(): boolean;
132
+ static resetGhostAlpha(): void;
127
133
  get Occupants(): Ped[];
128
134
  get Passengers(): Ped[];
129
135
  get Doors(): VehicleDoorCollection;
@@ -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 '../enums/ClassTypes';
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) {
@@ -382,6 +382,29 @@ export class Vehicle extends BaseEntity {
382
382
  get Driver() {
383
383
  return this.getPedOnSeat(VehicleSeat.Driver);
384
384
  }
385
+ // while ghosted use entity index, it doesn't look like you can ghost
386
+ // anything but players and vehicles
387
+ get Ghosted() {
388
+ // actual name is IS_ENTITY_A_GHOST
389
+ return IsEntityGhostedToLocalPlayer(this.handle);
390
+ }
391
+ set GhostedForGhostPlayers(isGhostedForGhostPlayers) {
392
+ // actual name is SET_ENTITY_GHOSTED_FOR_GHOST_PLAYERS
393
+ NetworkSetEntityGhostedWithOwner(this.handle, isGhostedForGhostPlayers);
394
+ }
395
+ set Ghosted(isGhosted) {
396
+ SetNetworkVehicleAsGhost(this.Handle, isGhosted);
397
+ }
398
+ static set GhostAlpha(alpha) {
399
+ SetGhostedEntityAlpha(alpha);
400
+ }
401
+ get IsInGhostCollision() {
402
+ // actual name is IS_ENTITY_IN_GHOST_COLLISION
403
+ return N_0x7ef7649b64d7ff10(this.handle);
404
+ }
405
+ static resetGhostAlpha() {
406
+ ResetGhostedEntityAlpha();
407
+ }
385
408
  get Occupants() {
386
409
  const driver = this.Driver;
387
410
  if (!Ped.exists(driver)) {
@@ -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: string;
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;
@@ -265,7 +266,7 @@ export declare class Vector {
265
266
  * Represents a 2-dimensional vector.
266
267
  */
267
268
  export declare class Vector2 extends Vector {
268
- type: string;
269
+ type: ClassTypes;
269
270
  static readonly Zero: Vector2;
270
271
  /**
271
272
  * Constructs a new 2D vector.
@@ -278,7 +279,7 @@ export declare class Vector2 extends Vector {
278
279
  * Represents a 3-dimensional vector.
279
280
  */
280
281
  export declare class Vector3 extends Vector implements Vec3 {
281
- type: string;
282
+ type: ClassTypes;
282
283
  z: number;
283
284
  static readonly Zero: Vector3;
284
285
  /**
@@ -301,7 +302,7 @@ export declare class Vector3 extends Vector implements Vec3 {
301
302
  * Represents a 4-dimensional vector.
302
303
  */
303
304
  export declare class Vector4 extends Vector {
304
- type: string;
305
+ type: ClassTypes;
305
306
  z: number;
306
307
  w: number;
307
308
  static readonly Zero: Vector4;
@@ -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
  */
@@ -21,11 +22,11 @@ export class Vector {
21
22
  : `vec${[x, y, z, w].filter(arg => arg !== undefined).length}`;
22
23
  switch (type) {
23
24
  default:
24
- case 'vec':
25
+ case ClassTypes.Vector2:
25
26
  return new Vector2(x, y);
26
- case 'vec3':
27
+ case ClassTypes.Vector3:
27
28
  return new Vector3(x, y, z);
28
- case 'vec4':
29
+ case ClassTypes.Vector4:
29
30
  return new Vector4(x, y, z, w);
30
31
  }
31
32
  }
@@ -247,7 +248,7 @@ export class Vector {
247
248
  /**
248
249
  * The type identifier for vectors.
249
250
  */
250
- this.type = 'vec';
251
+ this.type = ClassTypes.Vector2;
251
252
  }
252
253
  *[Symbol.iterator]() {
253
254
  yield this.x;
@@ -375,7 +376,7 @@ export class Vector2 extends Vector {
375
376
  */
376
377
  constructor(x, y = x) {
377
378
  super(2, x, y);
378
- this.type = 'vec2';
379
+ this.type = ClassTypes.Vector2;
379
380
  }
380
381
  }
381
382
  Vector2.Zero = new Vector2(0, 0);
@@ -391,7 +392,7 @@ export class Vector3 extends Vector {
391
392
  */
392
393
  constructor(x, y = x, z = y) {
393
394
  super(3, x, y, z);
394
- this.type = 'vec3';
395
+ this.type = ClassTypes.Vector3;
395
396
  this.z = z;
396
397
  }
397
398
  /**
@@ -421,7 +422,7 @@ export class Vector4 extends Vector {
421
422
  */
422
423
  constructor(x, y = x, z = y, w = z) {
423
424
  super(4, x, y, z, w);
424
- this.type = 'vec4';
425
+ this.type = ClassTypes.Vector4;
425
426
  this.z = z;
426
427
  this.w = w;
427
428
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Remco Troost <d0p3t>",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "version": "0.0.24",
7
+ "version": "0.0.27",
8
8
  "publishConfig": {
9
9
  "directory": "lib"
10
10
  },
@@ -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: NetEvent) => void;
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 './enum/ClassTypes';
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
- const ply = new Player(source);
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 '../enum/ClassTypes';
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';
@@ -1,5 +1,5 @@
1
1
  import cfx from '../cfx';
2
- import { ClassTypes } from '../enum/ClassTypes';
2
+ import { ClassTypes } from '../../common/utils/ClassTypes';
3
3
  import { Vector4 } from '../utils';
4
4
  import { Vector3 } from '../utils';
5
5
  export class BaseEntity {
@@ -1,4 +1,4 @@
1
- import { ClassTypes } from '../enum/ClassTypes';
1
+ import { ClassTypes } from '../../common/utils/ClassTypes';
2
2
  import { Hash } from '../type/Hash';
3
3
  import { BaseEntity } from './BaseEntity';
4
4
  import { Vehicle } from './Vehicle';
@@ -1,4 +1,4 @@
1
- import { ClassTypes } from '../enum/ClassTypes';
1
+ import { ClassTypes } from '../../common/utils/ClassTypes';
2
2
  import { BaseEntity } from './BaseEntity';
3
3
  import { Vehicle } from './Vehicle';
4
4
  export class Ped extends BaseEntity {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="@citizenfx/server" />
2
- import { ClassTypes } from '../enum/ClassTypes';
2
+ import { ClassTypes } from '../../common/utils/ClassTypes';
3
3
  import { Vector3 } from '../utils';
4
4
  import { Ped } from './Ped';
5
5
  export declare class Player {
@@ -1,5 +1,5 @@
1
1
  import cfx from '../cfx';
2
- import { ClassTypes } from '../enum/ClassTypes';
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
  }
@@ -1,4 +1,4 @@
1
- import { ClassTypes } from '../enum/ClassTypes';
1
+ import { ClassTypes } from '../../common/utils/ClassTypes';
2
2
  import { BaseEntity } from './BaseEntity';
3
3
  export declare class Prop extends BaseEntity {
4
4
  protected type: ClassTypes;
@@ -1,4 +1,4 @@
1
- import { ClassTypes } from '../enum/ClassTypes';
1
+ import { ClassTypes } from '../../common/utils/ClassTypes';
2
2
  import { BaseEntity } from './BaseEntity';
3
3
  export class Prop extends BaseEntity {
4
4
  constructor(handle) {
@@ -1,4 +1,4 @@
1
- import { ClassTypes } from '../enum/ClassTypes';
1
+ import { ClassTypes } from '../../common/utils/ClassTypes';
2
2
  import { VehicleLockStatus } from '../enum/VehicleLockStatus';
3
3
  import { VehicleType } from '../enum/VehicleType';
4
4
  import { Hash } from '../type/Hash';
@@ -1,4 +1,4 @@
1
- import { ClassTypes } from '../enum/ClassTypes';
1
+ import { ClassTypes } from '../../common/utils/ClassTypes';
2
2
  import { Color } from '../utils';
3
3
  import { BaseEntity } from './BaseEntity';
4
4
  export class Vehicle extends BaseEntity {
@@ -1,4 +1,3 @@
1
- export { ClassTypes } from './ClassTypes';
2
1
  export { eEntityType } from './eEntityType';
3
2
  export { PopulationType } from './PopulationType';
4
3
  export { VehicleLockStatus } from './VehicleLockStatus';
@@ -1,4 +1,3 @@
1
- export { ClassTypes } from './ClassTypes';
2
1
  export { eEntityType } from './eEntityType';
3
2
  export { PopulationType } from './PopulationType';
4
3
  export { VehicleLockStatus } from './VehicleLockStatus';
@@ -1,11 +0,0 @@
1
- export declare enum ClassTypes {
2
- Ped = 0,
3
- Prop = 1,
4
- Vehicle = 2,
5
- Entity = 3,
6
- Player = 4,
7
- Vector2 = 5,
8
- Vector3 = 6,
9
- Vector4 = 7,
10
- Quanterion = 8
11
- }
@@ -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