@nativewrappers/fivem 0.0.86 → 0.0.88

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.
Files changed (45) hide show
  1. package/Blip.d.ts +2 -2
  2. package/Blip.js +2 -2
  3. package/Camera.d.ts +1 -1
  4. package/Camera.js +6 -7
  5. package/GameConstants.d.ts +7 -0
  6. package/GameConstants.js +24 -0
  7. package/Model.js +1 -2
  8. package/Tasks.d.ts +4 -4
  9. package/Tasks.js +21 -14
  10. package/World.d.ts +5 -5
  11. package/World.js +7 -10
  12. package/common/Command.d.ts +25 -0
  13. package/common/Command.js +28 -2
  14. package/index.d.ts +5 -1
  15. package/index.js +5 -1
  16. package/models/BaseEntity.d.ts +12 -14
  17. package/models/BaseEntity.js +3 -24
  18. package/models/BaseEntityBone.d.ts +12 -0
  19. package/models/BaseEntityBone.js +32 -0
  20. package/models/BaseEntityBoneCollection.d.ts +9 -0
  21. package/models/BaseEntityBoneCollection.js +19 -0
  22. package/models/Entity.d.ts +4 -0
  23. package/models/EntityBone.d.ts +2 -9
  24. package/models/EntityBone.js +3 -21
  25. package/models/EntityBoneCollection.d.ts +2 -3
  26. package/models/EntityBoneCollection.js +3 -6
  27. package/models/Ped.d.ts +8 -6
  28. package/models/Ped.js +23 -16
  29. package/models/PedBone.d.ts +3 -3
  30. package/models/PedBone.js +3 -4
  31. package/models/PedBoneCollection.d.ts +2 -2
  32. package/models/PedBoneCollection.js +2 -2
  33. package/models/Player.d.ts +4 -4
  34. package/models/Player.js +4 -4
  35. package/models/Prop.d.ts +5 -0
  36. package/models/Prop.js +12 -0
  37. package/models/Vehicle.d.ts +12 -7
  38. package/models/Vehicle.js +21 -7
  39. package/models/index.d.ts +5 -0
  40. package/models/index.js +5 -0
  41. package/package.json +1 -1
  42. package/utils/GetEntityFromEntityIds.d.ts +2 -0
  43. package/utils/GetEntityFromEntityIds.js +23 -0
  44. package/Events.d.ts +0 -11
  45. package/Events.js +0 -80
package/Blip.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Vector3 } from "./common/utils/Vector";
2
2
  import type { BlipColor, BlipSprite } from "./enums/Blip";
3
- import { BaseEntity } from "./models/BaseEntity";
3
+ import type { Entity } from "./models/Entity";
4
4
  import type { Player } from "./models/Player";
5
5
  export declare class Blip {
6
6
  protected handle: number;
@@ -22,7 +22,7 @@ export declare class Blip {
22
22
  set Display(display: number);
23
23
  set Name(name: string);
24
24
  setNameToPlayerName(player: Player): void;
25
- get Entity(): BaseEntity | null;
25
+ get Entity(): Entity | null;
26
26
  set ShowHeadingIndicator(show: boolean);
27
27
  set ShowRoute(show: boolean);
28
28
  set IsFriendly(friendly: boolean);
package/Blip.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
  import { Vector3 } from "./common/utils/Vector";
4
- import { BaseEntity } from "./models/BaseEntity";
4
+ import { GetEntityClassFromId } from "./utils/GetEntityFromEntityIds";
5
5
  class Blip {
6
6
  static {
7
7
  __name(this, "Blip");
@@ -64,7 +64,7 @@ class Blip {
64
64
  SetBlipNameToPlayerName(this.handle, player.Handle);
65
65
  }
66
66
  get Entity() {
67
- return new BaseEntity(GetBlipInfoIdEntityIndex(this.handle));
67
+ return GetEntityClassFromId(GetBlipInfoIdEntityIndex(this.handle));
68
68
  }
69
69
  set ShowHeadingIndicator(show) {
70
70
  ShowHeadingIndicatorOnBlip(this.handle, show);
package/Camera.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Vector3 } from "./common/utils/Vector";
2
2
  import type { CameraShake } from "./enums/CameraShake";
3
- import { BaseEntity } from "./models/BaseEntity";
3
+ import type { BaseEntity } from "./models/BaseEntity";
4
4
  import { PedBone } from "./models/PedBone";
5
5
  export declare class Camera {
6
6
  static readonly shakeNames: string[];
package/Camera.js CHANGED
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
  import { Vector3 } from "./common/utils/Vector";
4
4
  import { GameplayCamera } from "./GameplayCamera";
5
- import { BaseEntity } from "./models/BaseEntity";
6
5
  import { PedBone } from "./models/PedBone";
7
6
  import { LoadAnimDict } from "./utils/Animations";
8
7
  class Camera {
@@ -151,12 +150,12 @@ class Camera {
151
150
  RemoveAnimDict(animDict);
152
151
  }
153
152
  pointAt(target, offset = new Vector3(0, 0, 0)) {
154
- if (target instanceof BaseEntity) {
155
- PointCamAtEntity(this.handle, target.Handle, offset.x, offset.y, offset.z, true);
153
+ if (target instanceof Vector3) {
154
+ PointCamAtCoord(this.handle, target.x, target.y, target.z);
156
155
  } else if (target instanceof PedBone) {
157
156
  PointCamAtPedBone(this.handle, target.Owner.Handle, target.Index, offset.x, offset.y, offset.z, true);
158
157
  } else {
159
- PointCamAtCoord(this.handle, target.x, target.y, target.z);
158
+ PointCamAtEntity(this.handle, target.Handle, offset.x, offset.y, offset.z, true);
160
159
  }
161
160
  }
162
161
  stopPointing() {
@@ -169,10 +168,10 @@ class Camera {
169
168
  return IsCamInterpolating(this.handle);
170
169
  }
171
170
  attachTo(object, offset) {
172
- if (object instanceof BaseEntity) {
173
- AttachCamToEntity(this.handle, object.Handle, offset.x, offset.y, offset.z, true);
174
- } else if (object instanceof PedBone) {
171
+ if (object instanceof PedBone) {
175
172
  AttachCamToPedBone(this.handle, object.Owner.Handle, object.Index, offset.x, offset.y, offset.z, true);
173
+ } else {
174
+ AttachCamToEntity(this.handle, object.Handle, offset.x, offset.y, offset.z, true);
176
175
  }
177
176
  }
178
177
  detach() {
@@ -0,0 +1,7 @@
1
+ import { Player } from "./models/Player";
2
+ export declare class GameConstants {
3
+ private static player;
4
+ static readonly PlayerId: number;
5
+ static readonly ServerId: number;
6
+ static get Player(): Player;
7
+ }
@@ -0,0 +1,24 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Player } from "./models/Player";
4
+ class GameConstants {
5
+ static {
6
+ __name(this, "GameConstants");
7
+ }
8
+ // the actual player object that will get initialized on the first call to the `get Player()`
9
+ static player = null;
10
+ // The player id of the local client
11
+ static PlayerId = PlayerId();
12
+ // The server id of the local client.
13
+ static ServerId = GetPlayerServerId(GameConstants.PlayerId);
14
+ // The player class of the local object
15
+ static get Player() {
16
+ if (GameConstants.player === null) {
17
+ GameConstants.player = new Player(GameConstants.PlayerId);
18
+ }
19
+ return GameConstants.player;
20
+ }
21
+ }
22
+ export {
23
+ GameConstants
24
+ };
package/Model.js CHANGED
@@ -1,7 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
  import { Vector3 } from "./common/utils/Vector";
4
- import { Game } from "./Game";
5
4
  import { VehicleHash } from "./hashes/VehicleHash";
6
5
  class Model {
7
6
  static {
@@ -19,7 +18,7 @@ class Model {
19
18
  */
20
19
  constructor(hash) {
21
20
  if (typeof hash === "string") {
22
- this.hash = Game.generateHash(hash);
21
+ this.hash = GetHashKey(hash);
23
22
  } else {
24
23
  this.hash = hash;
25
24
  }
package/Tasks.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { Vector3 } from "./common/utils/Vector";
2
+ import type { TaskSequence } from "./TaskSequence";
2
3
  import type { AnimationFlags } from "./enums/AnimationFlags";
3
4
  import { DrivingStyle } from "./enums/Driving";
4
5
  import { FiringPattern } from "./enums/FiringPattern";
5
- import { VehicleSeat } from "./enums/Vehicle";
6
6
  import type { LeaveVehicleFlags } from "./enums/LeaveVehicleFlags";
7
- import { BaseEntity } from "./models/BaseEntity";
8
- import { Ped } from "./models/Ped";
7
+ import { VehicleSeat } from "./enums/Vehicle";
8
+ import type { BaseEntity } from "./models/BaseEntity";
9
+ import type { Ped } from "./models/Ped";
9
10
  import type { Vehicle } from "./models/Vehicle";
10
- import type { TaskSequence } from "./TaskSequence";
11
11
  export declare class Tasks {
12
12
  private ped;
13
13
  constructor(ped: Ped | null);
package/Tasks.js CHANGED
@@ -4,8 +4,6 @@ import { Vector3 } from "./common/utils/Vector";
4
4
  import { DrivingStyle } from "./enums/Driving";
5
5
  import { FiringPattern } from "./enums/FiringPattern";
6
6
  import { VehicleSeat } from "./enums/Vehicle";
7
- import { BaseEntity } from "./models/BaseEntity";
8
- import { Ped } from "./models/Ped";
9
7
  import { LoadAnimDict } from "./utils/Animations";
10
8
  class Tasks {
11
9
  static {
@@ -13,7 +11,7 @@ class Tasks {
13
11
  }
14
12
  ped;
15
13
  // we take null because sequences have a null ped, if you pass null to this
16
- // you betterk now what you're doing.
14
+ // you better now what you're doing.
17
15
  constructor(ped) {
18
16
  const actualPed = ped ?? { handle: null };
19
17
  this.ped = actualPed;
@@ -25,8 +23,11 @@ class Tasks {
25
23
  TaskSetBlockingOfNonTemporaryEvents(this.ped.Handle, block);
26
24
  }
27
25
  aimAt(target, duration) {
28
- if (target instanceof BaseEntity) TaskAimGunAtEntity(this.ped.Handle, target.Handle, duration, false);
29
- else TaskAimGunAtCoord(this.ped.Handle, target.x, target.y, target.z, duration, false, false);
26
+ if (target instanceof Vector3) {
27
+ TaskAimGunAtCoord(this.ped.Handle, target.x, target.y, target.z, duration, false, false);
28
+ } else {
29
+ TaskAimGunAtEntity(this.ped.Handle, target.Handle, duration, false);
30
+ }
30
31
  }
31
32
  arrest(ped) {
32
33
  TaskArrestPed(this.ped.Handle, ped.Handle);
@@ -91,9 +92,7 @@ class Tasks {
91
92
  }
92
93
  }
93
94
  fleeFrom(pedOrPosition, duration = -1) {
94
- if (pedOrPosition instanceof Ped) {
95
- TaskSmartFleePed(this.ped.Handle, pedOrPosition.Handle, 100, duration, false, false);
96
- } else {
95
+ if (pedOrPosition instanceof Vector3) {
97
96
  TaskSmartFleeCoord(
98
97
  this.ped.Handle,
99
98
  pedOrPosition.x,
@@ -104,6 +103,8 @@ class Tasks {
104
103
  false,
105
104
  false
106
105
  );
106
+ } else {
107
+ TaskSmartFleePed(this.ped.Handle, pedOrPosition.Handle, 100, duration, false, false);
107
108
  }
108
109
  }
109
110
  followPointRoute(points) {
@@ -191,9 +192,11 @@ class Tasks {
191
192
  }
192
193
  }
193
194
  lookAt(targetOrPosition, duration = -1) {
194
- if (targetOrPosition instanceof BaseEntity)
195
+ if (targetOrPosition instanceof Vector3) {
196
+ TaskLookAtCoord(this.ped.Handle, targetOrPosition.x, targetOrPosition.y, targetOrPosition.z, duration, 0, 2);
197
+ } else {
195
198
  TaskLookAtEntity(this.ped.Handle, targetOrPosition.Handle, duration, 0, 2);
196
- else TaskLookAtCoord(this.ped.Handle, targetOrPosition.x, targetOrPosition.y, targetOrPosition.z, duration, 0, 2);
199
+ }
197
200
  }
198
201
  parachuteTo(position) {
199
202
  TaskParachuteToTarget(this.ped.Handle, position.x, position.y, position.z);
@@ -242,9 +245,11 @@ class Tasks {
242
245
  TaskReloadWeapon(this.ped.Handle, true);
243
246
  }
244
247
  shootAt(targetOrPosition, duration = -1, pattern = FiringPattern.Default) {
245
- if (targetOrPosition instanceof Ped) TaskShootAtEntity(this.ped.Handle, targetOrPosition.Handle, duration, pattern);
246
- else
248
+ if (targetOrPosition instanceof Vector3) {
247
249
  TaskShootAtCoord(this.ped.Handle, targetOrPosition.x, targetOrPosition.y, targetOrPosition.z, duration, pattern);
250
+ } else {
251
+ TaskShootAtEntity(this.ped.Handle, targetOrPosition.Handle, duration, pattern);
252
+ }
248
253
  }
249
254
  shuffleToNextVehicleSeat(vehicle) {
250
255
  TaskShuffleToNextVehicleSeat(this.ped.Handle, vehicle.Handle);
@@ -275,9 +280,11 @@ class Tasks {
275
280
  TaskSwapWeapon(this.ped.Handle, false);
276
281
  }
277
282
  turnTo(targetOrPosition, duration = -1) {
278
- if (targetOrPosition instanceof BaseEntity)
283
+ if (targetOrPosition instanceof Vector3) {
284
+ TaskTurnPedToFaceCoord(this.ped.Handle, targetOrPosition.x, targetOrPosition.y, targetOrPosition.z, duration);
285
+ } else {
279
286
  TaskTurnPedToFaceEntity(this.ped.Handle, targetOrPosition.Handle, duration);
280
- else TaskTurnPedToFaceCoord(this.ped.Handle, targetOrPosition.x, targetOrPosition.y, targetOrPosition.z, duration);
287
+ }
281
288
  }
282
289
  useParachute() {
283
290
  TaskParachute(this.ped.Handle, true);
package/World.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import type { Color } from "./common/utils/Color";
2
+ import { Vector3 } from "./common/utils/Vector";
2
3
  import { Blip } from "./Blip";
3
4
  import { Camera } from "./Camera";
5
+ import { Model } from "./Model";
6
+ import { Pickup } from "./Pickup";
7
+ import { AsynchronousRaycastResult, SynchronousRaycastResult } from "./Raycast";
8
+ import { Rope } from "./Rope";
4
9
  import { CameraTypes } from "./enums/CameraTypes";
5
10
  import { CloudHat } from "./enums/CloudHat";
6
11
  import type { MarkerType } from "./enums/MarkerType";
@@ -8,15 +13,10 @@ import type { PickupType } from "./enums/PickupType";
8
13
  import { IntersectFlags } from "./enums/RaycastEnums";
9
14
  import type { RopeType } from "./enums/RopeType";
10
15
  import { Weather } from "./enums/Weather";
11
- import { Model } from "./Model";
12
16
  import type { BaseEntity } from "./models/BaseEntity";
13
17
  import { Ped } from "./models/Ped";
14
18
  import { Prop } from "./models/Prop";
15
19
  import { Vehicle } from "./models/Vehicle";
16
- import { Pickup } from "./Pickup";
17
- import { AsynchronousRaycastResult, SynchronousRaycastResult } from "./Raycast";
18
- import { Rope } from "./Rope";
19
- import { Vector3 } from "./common/utils/Vector";
20
20
  /**
21
21
  * Class with common world manipulations.
22
22
  *
package/World.js CHANGED
@@ -1,22 +1,22 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Vector3 } from "./common/utils/Vector";
3
4
  import { Blip } from "./Blip";
4
5
  import { Camera } from "./Camera";
6
+ import { GameplayCamera } from "./GameplayCamera";
7
+ import { Model } from "./Model";
8
+ import { Pickup } from "./Pickup";
9
+ import { AsynchronousRaycastResult, SynchronousRaycastResult } from "./Raycast";
10
+ import { Rope } from "./Rope";
5
11
  import { CameraTypes } from "./enums/CameraTypes";
6
12
  import { CloudHat } from "./enums/CloudHat";
7
13
  import { IntersectFlags, SHAPE_TEST_DEFAULT } from "./enums/RaycastEnums";
8
14
  import { Weather } from "./enums/Weather";
9
- import { GameplayCamera } from "./GameplayCamera";
10
15
  import { VehicleHash } from "./hashes/VehicleHash";
11
- import { Model } from "./Model";
12
16
  import { Ped } from "./models/Ped";
13
17
  import { Prop } from "./models/Prop";
14
18
  import { Vehicle } from "./models/Vehicle";
15
- import { Pickup } from "./Pickup";
16
- import { AsynchronousRaycastResult, SynchronousRaycastResult } from "./Raycast";
17
- import { Rope } from "./Rope";
18
19
  import { Maths } from "./utils/Maths";
19
- import { Vector3 } from "./common/utils/Vector";
20
20
  class World {
21
21
  static {
22
22
  __name(this, "World");
@@ -342,10 +342,7 @@ class World {
342
342
  }
343
343
  const ped = CreatePed(-1, model.Hash, position.x, position.y, position.z, heading, isNetwork, pinToScript);
344
344
  model.markAsNoLongerNeeded();
345
- if (ped === 0) {
346
- return null;
347
- }
348
- return new Ped(ped);
345
+ return Ped.fromHandle(ped);
349
346
  }
350
347
  /**
351
348
  * Creates a [[`Ped`]] with a random model.
@@ -23,8 +23,33 @@ export declare class Command<T extends Parameter[] = Parameter[]> {
23
23
  readonly name: string | string[];
24
24
  readonly help: string;
25
25
  readonly params?: T | undefined;
26
+ /**
27
+ * Registers a new executable command with optional parameter validation and permission restrictions.
28
+ * @param name The unique identifier(s) for the command, either as a single string or an array of strings.
29
+ * @param help A description of the command, displayed as a chat suggestion.
30
+ * @param handler The function to execute when the command is executed.
31
+ * @param params An optional array of parameter definitions specifying the command's expected arguments,
32
+ * including their names, types, and descriptive help text for chat suggestions.
33
+ * @param restricted Determines the command's access permissions:
34
+ * - Defaults to `true`, restricting usage to users with the "command.commandName" ACE permission.
35
+ * - A string such as `"group.admin"` grants the command permission to the specified principal.
36
+ * - An array of strings grants permission to multiple principals.
37
+ */
26
38
  constructor(name: string | string[], help: string, handler: CommandHandler<T>, params?: T | undefined, restricted?: Restricted);
39
+ /**
40
+ * Maps the arguments received from a command call to the defined parameters while validating the argument types.
41
+ * @param source The client that executed the command, or -1 if executed by the server.
42
+ * @param args The arguments passed to the command.
43
+ * @param raw The raw input string passed to the command.
44
+ * @returns A mapped object containing parsed parameters.
45
+ */
27
46
  private mapArguments;
47
+ /**
48
+ * Executes the command with the given arguments and source, validating and mapping the arguments before calling the handler.
49
+ * @param source The client that executed the command.
50
+ * @param args The arguments passed to the command.
51
+ * @param raw The raw input string passed to the command.
52
+ */
28
53
  call(source: number, args: string[], raw?: string): Promise<void>;
29
54
  }
30
55
  export {};
package/common/Command.js CHANGED
@@ -1,17 +1,18 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { GlobalData } from "./GlobalData";
3
4
  const commands = [];
4
5
  $SERVER: {
5
6
  on("playerJoining", () => emitNet("chat:addSuggestions", source, commands));
6
7
  }
7
- function registerCommand(name, commandHandler, restricted) {
8
+ function registerCommand(name, commandHandler, restricted = true) {
8
9
  if (Array.isArray(name)) {
9
10
  for (const command of name) {
10
11
  registerCommand(command, commandHandler, restricted);
11
12
  }
12
13
  return;
13
14
  }
14
- RegisterCommand(name, commandHandler, !!restricted);
15
+ RegisterCommand(name, commandHandler, GlobalData.IS_CLIENT ? false : !!restricted);
15
16
  $SERVER: {
16
17
  const ace = `command.${name}`;
17
18
  if (typeof restricted === "string") {
@@ -27,6 +28,18 @@ function registerCommand(name, commandHandler, restricted) {
27
28
  }
28
29
  __name(registerCommand, "registerCommand");
29
30
  class Command {
31
+ /**
32
+ * Registers a new executable command with optional parameter validation and permission restrictions.
33
+ * @param name The unique identifier(s) for the command, either as a single string or an array of strings.
34
+ * @param help A description of the command, displayed as a chat suggestion.
35
+ * @param handler The function to execute when the command is executed.
36
+ * @param params An optional array of parameter definitions specifying the command's expected arguments,
37
+ * including their names, types, and descriptive help text for chat suggestions.
38
+ * @param restricted Determines the command's access permissions:
39
+ * - Defaults to `true`, restricting usage to users with the "command.commandName" ACE permission.
40
+ * - A string such as `"group.admin"` grants the command permission to the specified principal.
41
+ * - An array of strings grants permission to multiple principals.
42
+ */
30
43
  constructor(name, help, handler, params, restricted = true) {
31
44
  this.name = name;
32
45
  this.help = help;
@@ -55,6 +68,13 @@ class Command {
55
68
  __name(this, "Command");
56
69
  }
57
70
  #handler;
71
+ /**
72
+ * Maps the arguments received from a command call to the defined parameters while validating the argument types.
73
+ * @param source The client that executed the command, or -1 if executed by the server.
74
+ * @param args The arguments passed to the command.
75
+ * @param raw The raw input string passed to the command.
76
+ * @returns A mapped object containing parsed parameters.
77
+ */
58
78
  mapArguments(source2, args, raw) {
59
79
  const mapped = {
60
80
  source: source2,
@@ -95,6 +115,12 @@ class Command {
95
115
  });
96
116
  return result ? mapped : null;
97
117
  }
118
+ /**
119
+ * Executes the command with the given arguments and source, validating and mapping the arguments before calling the handler.
120
+ * @param source The client that executed the command.
121
+ * @param args The arguments passed to the command.
122
+ * @param raw The raw input string passed to the command.
123
+ */
98
124
  async call(source2, args, raw = args.join(" ")) {
99
125
  const parsed = this.mapArguments(source2, args, raw);
100
126
  if (!parsed) return;
package/index.d.ts CHANGED
@@ -2,8 +2,8 @@ export * from "./Audio";
2
2
  export * from "./Blip";
3
3
  export * from "./Camera";
4
4
  export * from "./Checkpoint";
5
- export * from "./Events";
6
5
  export * from "./Game";
6
+ export * from "./GameConstants";
7
7
  export * from "./GameplayCamera";
8
8
  export * from "./Model";
9
9
  export * from "./NetworkedScene";
@@ -39,6 +39,7 @@ export * from "./weapon/WeaponLiveryColor";
39
39
  export * from "./weapon/WeaponTint";
40
40
  export * from "./utils/Animations";
41
41
  export * from "./utils/Crypto";
42
+ export * from "./utils/GetEntityFromEntityIds";
42
43
  export * from "./utils/LiteEvent";
43
44
  export * from "./utils/Maths";
44
45
  export * from "./utils/Point";
@@ -76,6 +77,8 @@ export * from "./ui/menu/items/panels/UIMenuStatisticsPanelItem";
76
77
  export * from "./ui/interfaces/IButton";
77
78
  export * from "./ui/interfaces/IDrawable";
78
79
  export * from "./models/BaseEntity";
80
+ export * from "./models/BaseEntityBone";
81
+ export * from "./models/BaseEntityBoneCollection";
79
82
  export * from "./models/Entity";
80
83
  export * from "./models/EntityBone";
81
84
  export * from "./models/EntityBoneCollection";
@@ -94,6 +97,7 @@ export * from "./models/VehicleWheel";
94
97
  export * from "./models/VehicleWheelCollection";
95
98
  export * from "./models/VehicleWindow";
96
99
  export * from "./models/VehicleWindowCollection";
100
+ export * from "./models/index";
97
101
  export * from "./interfaces/Dimensions";
98
102
  export * from "./hashes/MaterialHash";
99
103
  export * from "./hashes/PedHash";
package/index.js CHANGED
@@ -2,8 +2,8 @@ export * from "./Audio";
2
2
  export * from "./Blip";
3
3
  export * from "./Camera";
4
4
  export * from "./Checkpoint";
5
- export * from "./Events";
6
5
  export * from "./Game";
6
+ export * from "./GameConstants";
7
7
  export * from "./GameplayCamera";
8
8
  export * from "./Model";
9
9
  export * from "./NetworkedScene";
@@ -39,6 +39,7 @@ export * from "./weapon/WeaponLiveryColor";
39
39
  export * from "./weapon/WeaponTint";
40
40
  export * from "./utils/Animations";
41
41
  export * from "./utils/Crypto";
42
+ export * from "./utils/GetEntityFromEntityIds";
42
43
  export * from "./utils/LiteEvent";
43
44
  export * from "./utils/Maths";
44
45
  export * from "./utils/Point";
@@ -76,6 +77,8 @@ export * from "./ui/menu/items/panels/UIMenuStatisticsPanelItem";
76
77
  export * from "./ui/interfaces/IButton";
77
78
  export * from "./ui/interfaces/IDrawable";
78
79
  export * from "./models/BaseEntity";
80
+ export * from "./models/BaseEntityBone";
81
+ export * from "./models/BaseEntityBoneCollection";
79
82
  export * from "./models/Entity";
80
83
  export * from "./models/EntityBone";
81
84
  export * from "./models/EntityBoneCollection";
@@ -94,6 +97,7 @@ export * from "./models/VehicleWheel";
94
97
  export * from "./models/VehicleWheelCollection";
95
98
  export * from "./models/VehicleWindow";
96
99
  export * from "./models/VehicleWindowCollection";
100
+ export * from "./models/index";
97
101
  export * from "./interfaces/Dimensions";
98
102
  export * from "./hashes/MaterialHash";
99
103
  export * from "./hashes/PedHash";
@@ -1,22 +1,20 @@
1
- import { ClassTypes } from "../common/utils/ClassTypes";
1
+ import type { ClassTypes } from "../common/utils/ClassTypes";
2
+ import { Quaternion } from "../common/utils/Quaternion";
2
3
  import { Vector3 } from "../common/utils/Vector";
4
+ import { Model } from "../Model";
5
+ import { type StateBagChangeHandler } from "../cfx";
3
6
  import { ForceType } from "../enums/ForceType";
4
7
  import type { MaterialHash } from "../hashes/MaterialHash";
5
8
  import type { WeaponHash } from "../hashes/WeaponHash";
6
- import { Model } from "../Model";
7
- import type { EntityBone } from "./EntityBone";
8
9
  import { Blip } from "../Blip";
9
- import { EntityBoneCollection } from "./EntityBoneCollection";
10
- import { type StateBagChangeHandler } from "../cfx";
11
- import { Quaternion } from "../common/utils/Quaternion";
12
- export declare class BaseEntity {
13
- static fromNetworkId(networkId: number): BaseEntity | null;
14
- static fromStateBagName(stateBagName: string): BaseEntity | null;
10
+ import type { BaseEntityBone } from "./BaseEntityBone";
11
+ import type { BaseEntityBoneCollection } from "./BaseEntityBoneCollection";
12
+ export declare abstract class BaseEntity {
15
13
  protected handle: number;
16
- protected bones: EntityBoneCollection | undefined;
17
14
  protected stateBagCookies: number[];
18
15
  protected netId: number | null;
19
- protected type: ClassTypes;
16
+ protected abstract type: ClassTypes;
17
+ protected abstract bones?: BaseEntityBoneCollection;
20
18
  constructor(handle: number);
21
19
  get Handle(): number;
22
20
  /**
@@ -117,7 +115,7 @@ export declare class BaseEntity {
117
115
  get IsCollisionEnabled(): boolean;
118
116
  set IsCollisionEnabled(value: boolean);
119
117
  set IsRecordingCollisions(value: boolean);
120
- get Bones(): EntityBoneCollection;
118
+ abstract get Bones(): BaseEntityBoneCollection;
121
119
  get AttachedBlip(): Blip | null;
122
120
  attachBlip(): Blip;
123
121
  setNoCollision(entity: BaseEntity, toggle: boolean): void;
@@ -165,11 +163,11 @@ export declare class BaseEntity {
165
163
  */
166
164
  getOffsetPosition(offset: Vector3): Vector3;
167
165
  attachTo(entity: BaseEntity, position: Vector3, rotation: Vector3, collisions?: boolean, unk9?: boolean, useSoftPinning?: boolean, rotationOrder?: number): void;
168
- attachToBone(entityBone: EntityBone, position: Vector3, rotation: Vector3, collisions?: boolean, unk9?: boolean, useSoftPinning?: boolean, rotationOrder?: number): void;
166
+ attachToBone(entityBone: BaseEntityBone, position: Vector3, rotation: Vector3, collisions?: boolean, unk9?: boolean, useSoftPinning?: boolean, rotationOrder?: number): void;
169
167
  detach(): void;
170
168
  isAttached(): boolean;
171
169
  isAttachedTo(entity: BaseEntity): boolean;
172
- getEntityAttachedTo(): BaseEntity;
170
+ abstract getEntityAttachedTo(): BaseEntity | null;
173
171
  applyForce(direction: Vector3, rotation: Vector3, forceType?: ForceType): void;
174
172
  applyForceRelative(direction: Vector3, rotation: Vector3, forceType?: ForceType): void;
175
173
  /**
@@ -1,30 +1,18 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { ClassTypes } from "../common/utils/ClassTypes";
3
+ import { Quaternion } from "../common/utils/Quaternion";
4
4
  import { Vector3 } from "../common/utils/Vector";
5
- import { ForceType } from "../enums/ForceType";
6
5
  import { Model } from "../Model";
7
- import { Blip } from "../Blip";
8
- import { EntityBoneCollection } from "./EntityBoneCollection";
9
6
  import cfx from "../cfx";
10
- import { Quaternion } from "../common/utils/Quaternion";
7
+ import { ForceType } from "../enums/ForceType";
8
+ import { Blip } from "../Blip";
11
9
  class BaseEntity {
12
10
  static {
13
11
  __name(this, "BaseEntity");
14
12
  }
15
- static fromNetworkId(networkId) {
16
- return new BaseEntity(NetworkGetEntityFromNetworkId(networkId));
17
- }
18
- static fromStateBagName(stateBagName) {
19
- const entity = GetEntityFromStateBagName(stateBagName);
20
- if (entity === 0) return null;
21
- return new BaseEntity(entity);
22
- }
23
13
  handle;
24
- bones;
25
14
  stateBagCookies = [];
26
15
  netId = null;
27
- type = ClassTypes.Entity;
28
16
  constructor(handle) {
29
17
  this.handle = handle;
30
18
  if (this.IsNetworked) {
@@ -314,12 +302,6 @@ class BaseEntity {
314
302
  set IsRecordingCollisions(value) {
315
303
  SetEntityRecordsCollisions(this.handle, value);
316
304
  }
317
- get Bones() {
318
- if (!this.bones) {
319
- this.bones = new EntityBoneCollection(this);
320
- }
321
- return this.bones;
322
- }
323
305
  get AttachedBlip() {
324
306
  const handle = GetBlipFromEntity(this.handle);
325
307
  if (DoesBlipExist(handle)) {
@@ -503,9 +485,6 @@ class BaseEntity {
503
485
  isAttachedTo(entity) {
504
486
  return IsEntityAttachedToEntity(this.handle, entity.Handle);
505
487
  }
506
- getEntityAttachedTo() {
507
- return new BaseEntity(GetEntityAttachedTo(this.handle));
508
- }
509
488
  applyForce(direction, rotation, forceType = ForceType.MaxForceRot2) {
510
489
  ApplyForceToEntity(
511
490
  this.handle,
@@ -0,0 +1,12 @@
1
+ import { Vector3 } from "../common/utils/Vector";
2
+ import type { BaseEntity } from "./BaseEntity";
3
+ export declare abstract class BaseEntityBone {
4
+ get Index(): number;
5
+ get Owner(): BaseEntity;
6
+ get Position(): Vector3;
7
+ get Rotation(): Vector3;
8
+ get IsValid(): boolean;
9
+ protected readonly owner: BaseEntity;
10
+ protected readonly index: number;
11
+ constructor(owner: BaseEntity, boneIndex?: number, boneName?: string);
12
+ }
@@ -0,0 +1,32 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Vector3 } from "../common/utils/Vector";
4
+ class BaseEntityBone {
5
+ static {
6
+ __name(this, "BaseEntityBone");
7
+ }
8
+ get Index() {
9
+ return this.index;
10
+ }
11
+ get Owner() {
12
+ return this.owner;
13
+ }
14
+ get Position() {
15
+ return Vector3.fromArray(GetWorldPositionOfEntityBone(this.owner.Handle, this.index));
16
+ }
17
+ get Rotation() {
18
+ return Vector3.fromArray(GetEntityBoneRotation(this.owner.Handle, this.index));
19
+ }
20
+ get IsValid() {
21
+ return this.owner.exists() && this.index !== -1;
22
+ }
23
+ owner;
24
+ index;
25
+ constructor(owner, boneIndex, boneName) {
26
+ this.owner = owner;
27
+ this.index = boneIndex ? boneIndex : GetEntityBoneIndexByName(this.owner.Handle, boneName ?? "");
28
+ }
29
+ }
30
+ export {
31
+ BaseEntityBone
32
+ };
@@ -0,0 +1,9 @@
1
+ import type { BaseEntity } from "./BaseEntity";
2
+ import type { BaseEntityBone } from "./BaseEntityBone";
3
+ export declare abstract class BaseEntityBoneCollection {
4
+ protected readonly owner: BaseEntity;
5
+ constructor(owner: BaseEntity);
6
+ hasBone(name: string): boolean;
7
+ abstract getBone(boneIndex?: number, boneName?: string): BaseEntityBone;
8
+ abstract get Core(): BaseEntityBone;
9
+ }