@nativewrappers/fivem 0.0.88 → 0.0.90

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/Model.js CHANGED
@@ -1,5 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Delay } from "./common/utils/Delay";
3
4
  import { Vector3 } from "./common/utils/Vector";
4
5
  import { VehicleHash } from "./hashes/VehicleHash";
5
6
  class Model {
@@ -192,7 +193,7 @@ class Model {
192
193
  RequestModel(this.hash);
193
194
  const timeout = GetGameTimer() + timeoutMs;
194
195
  while (!this.IsLoaded && GetGameTimer() < timeout) {
195
- await Wait(0);
196
+ await Delay(0);
196
197
  }
197
198
  this.requestedModel = true;
198
199
  return this.IsLoaded;
package/World.d.ts CHANGED
@@ -12,6 +12,7 @@ import type { MarkerType } from "./enums/MarkerType";
12
12
  import type { PickupType } from "./enums/PickupType";
13
13
  import { IntersectFlags } from "./enums/RaycastEnums";
14
14
  import type { RopeType } from "./enums/RopeType";
15
+ import type { VehicleSeat } from "./enums/Vehicle";
15
16
  import { Weather } from "./enums/Weather";
16
17
  import type { BaseEntity } from "./models/BaseEntity";
17
18
  import { Ped } from "./models/Ped";
@@ -185,10 +186,21 @@ export declare abstract class World {
185
186
  * @param model Ped model to be spawned.
186
187
  * @param position World position (coordinates) of Ped spawn.
187
188
  * @param heading Heading of Ped when spawning.
188
- * @param isNetwork
189
+ * @param shouldNetwork if the created ped should be networked to other clients
189
190
  * @returns Ped object.
190
191
  */
191
- static createPed(model: Model, position: Vector3, heading?: number, isNetwork?: boolean, pinToScript?: boolean): Promise<Ped | null>;
192
+ static createPed(model: Model, position: Vector3, heading?: number, shouldNetwork?: boolean, pinToScript?: boolean): Promise<Ped | null>;
193
+ /**
194
+ * Created a ped in the specified vehicle
195
+ *
196
+ * @param vehicle the vehicle to create the ped in
197
+ * @param model Ped model to be spawned.
198
+ * @param seat the seat to spawn the ped into
199
+ * @param heading Heading of Ped when spawning.
200
+ * @param shouldNetwork if the created ped should be networked
201
+ * @returns the ped that was created, or null if it doesn't exist.
202
+ */
203
+ static createPedInsideVehicle(vehicle: Vehicle, model: Model, seat: VehicleSeat, shouldNetwork?: boolean, pinToScript?: boolean): Promise<Ped | null>;
192
204
  /**
193
205
  * Creates a [[`Ped`]] with a random model.
194
206
  *
package/World.js CHANGED
@@ -1,5 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Delay } from "./common/utils/Delay";
3
4
  import { Vector3 } from "./common/utils/Vector";
4
5
  import { Blip } from "./Blip";
5
6
  import { Camera } from "./Camera";
@@ -333,14 +334,32 @@ class World {
333
334
  * @param model Ped model to be spawned.
334
335
  * @param position World position (coordinates) of Ped spawn.
335
336
  * @param heading Heading of Ped when spawning.
336
- * @param isNetwork
337
+ * @param shouldNetwork if the created ped should be networked to other clients
337
338
  * @returns Ped object.
338
339
  */
339
- static async createPed(model, position, heading = 0, isNetwork = true, pinToScript = true) {
340
+ static async createPed(model, position, heading = 0, shouldNetwork = true, pinToScript = true) {
341
+ if (!model.IsPed || !await model.request(1e3)) {
342
+ return null;
343
+ }
344
+ const ped = CreatePed(-1, model.Hash, position.x, position.y, position.z, heading, shouldNetwork, pinToScript);
345
+ model.markAsNoLongerNeeded();
346
+ return Ped.fromHandle(ped);
347
+ }
348
+ /**
349
+ * Created a ped in the specified vehicle
350
+ *
351
+ * @param vehicle the vehicle to create the ped in
352
+ * @param model Ped model to be spawned.
353
+ * @param seat the seat to spawn the ped into
354
+ * @param heading Heading of Ped when spawning.
355
+ * @param shouldNetwork if the created ped should be networked
356
+ * @returns the ped that was created, or null if it doesn't exist.
357
+ */
358
+ static async createPedInsideVehicle(vehicle, model, seat, shouldNetwork = true, pinToScript = true) {
340
359
  if (!model.IsPed || !await model.request(1e3)) {
341
360
  return null;
342
361
  }
343
- const ped = CreatePed(-1, model.Hash, position.x, position.y, position.z, heading, isNetwork, pinToScript);
362
+ const ped = CreatePedInsideVehicle(vehicle.Handle, -1, model.Hash, seat, shouldNetwork, pinToScript);
344
363
  model.markAsNoLongerNeeded();
345
364
  return Ped.fromHandle(ped);
346
365
  }
@@ -378,9 +397,7 @@ class World {
378
397
  return null;
379
398
  }
380
399
  const vehicle = CreateVehicle(model.Hash, position.x, position.y, position.z, heading, isNetwork, pinToScript);
381
- if (vehicle === 0) {
382
- return null;
383
- }
400
+ model.markAsNoLongerNeeded();
384
401
  return new Vehicle(vehicle);
385
402
  }
386
403
  /**
@@ -422,7 +439,7 @@ class World {
422
439
  RopeLoadTextures();
423
440
  }
424
441
  while (!RopeAreTexturesLoaded()) {
425
- await Wait(0);
442
+ await Delay(0);
426
443
  }
427
444
  }
428
445
  const [ropeHandle] = AddRope(
@@ -815,10 +832,7 @@ class World {
815
832
  */
816
833
  static getClosestObject(model, coords, radius = 25, isMission = false) {
817
834
  const prop = GetClosestObjectOfType(coords.x, coords.y, coords.z, radius, model.Hash, isMission, false, false);
818
- if (prop !== 0) {
819
- return new Prop(prop);
820
- }
821
- return null;
835
+ return Prop.fromHandle(prop);
822
836
  }
823
837
  /**
824
838
  * Get all [[`Prop`]] entities in your own scope.
@@ -827,9 +841,7 @@ class World {
827
841
  */
828
842
  static getAllProps() {
829
843
  const handles = GetGamePool("CObject");
830
- const props = [];
831
- handles.forEach((handle) => props.push(new Prop(handle)));
832
- return props;
844
+ return handles.map((handle) => new Prop(handle));
833
845
  }
834
846
  /**
835
847
  * Get all [[`Rope`]] entities in your own scope.
@@ -838,9 +850,7 @@ class World {
838
850
  */
839
851
  static getAllRopes() {
840
852
  const handles = GetAllRopes();
841
- const props = [];
842
- handles.forEach((handle) => props.push(new Rope(handle)));
843
- return props;
853
+ return handles.map((handle) => new Rope(handle));
844
854
  }
845
855
  /**
846
856
  * Get all [[`Ped`]] entities in your own scope.
@@ -849,9 +859,7 @@ class World {
849
859
  */
850
860
  static getAllPeds() {
851
861
  const handles = GetGamePool("CPed");
852
- const peds = [];
853
- handles.forEach((handle) => peds.push(new Ped(handle)));
854
- return peds;
862
+ return handles.map((handle) => new Ped(handle));
855
863
  }
856
864
  /**
857
865
  * Get all [[`Vehicle`]] entities in your own scope.
@@ -860,9 +868,7 @@ class World {
860
868
  */
861
869
  static getAllVehicles() {
862
870
  const handles = GetGamePool("CVehicle");
863
- const vehicles = [];
864
- handles.forEach((handle) => vehicles.push(new Vehicle(handle)));
865
- return vehicles;
871
+ return handles.map((handle) => new Vehicle(handle));
866
872
  }
867
873
  /**
868
874
  * Gets the cloest [[`Vehicle`]] to the current coords, or null if none are found
@@ -892,9 +898,7 @@ class World {
892
898
  */
893
899
  static getAllPickups() {
894
900
  const handles = GetGamePool("CPickup");
895
- const pickups = [];
896
- handles.forEach((handle) => pickups.push(new Pickup(handle)));
897
- return pickups;
901
+ return handles.map((handle) => new Pickup(handle));
898
902
  }
899
903
  static currentCloudHat = CloudHat.Clear;
900
904
  static cloudHatDict = /* @__PURE__ */ new Map([
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "type": "module",
11
- "version": "0.0.88",
11
+ "version": "0.0.90",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"
package/ui/menu/Menu.d.ts CHANGED
@@ -4,9 +4,9 @@ import { MenuAlignment } from "../../enums/MenuAlignment";
4
4
  import { LiteEvent } from "../../utils/LiteEvent";
5
5
  import { Point } from "../../utils/Point";
6
6
  import { Size } from "../../utils/Size";
7
- import { UIMenuItem } from "./items/UIMenuItem";
8
7
  import { MenuControls } from "./MenuControls";
9
8
  import { MenuSettings } from "./MenuSettings";
9
+ import { UIMenuItem } from "./items/UIMenuItem";
10
10
  export declare class Menu {
11
11
  static screenAspectRatio: number;
12
12
  static screenHeight: number;
package/ui/menu/Menu.js CHANGED
@@ -1,15 +1,16 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
  import { Color } from "../../common/utils/Color";
4
+ import { Delay } from "../../common/utils/Delay";
4
5
  import { Audio } from "../../Audio";
6
+ import { Game } from "../../Game";
7
+ import { GameplayCamera } from "../../GameplayCamera";
5
8
  import { Alignment } from "../../enums/Alignment";
6
9
  import { Control } from "../../enums/Control";
7
10
  import { CursorSprite } from "../../enums/CursorSprite";
8
11
  import { Font } from "../../enums/Font";
9
12
  import { InputMode } from "../../enums/InputMode";
10
13
  import { MenuAlignment } from "../../enums/MenuAlignment";
11
- import { Game } from "../../Game";
12
- import { GameplayCamera } from "../../GameplayCamera";
13
14
  import { Crypto } from "../../utils/Crypto";
14
15
  import { LiteEvent } from "../../utils/LiteEvent";
15
16
  import { Point } from "../../utils/Point";
@@ -20,13 +21,13 @@ import { Rectangle } from "../Rectangle";
20
21
  import { Screen } from "../Screen";
21
22
  import { Sprite } from "../Sprite";
22
23
  import { Text } from "../Text";
24
+ import { MenuControls } from "./MenuControls";
25
+ import { MenuSettings } from "./MenuSettings";
23
26
  import { UIMenuCheckboxItem } from "./items/UIMenuCheckboxItem";
24
27
  import { UIMenuItem } from "./items/UIMenuItem";
25
28
  import { UIMenuListItem } from "./items/UIMenuListItem";
26
29
  import { UIMenuSeparatorItem } from "./items/UIMenuSeparatorItem";
27
30
  import { UIMenuSliderItem } from "./items/UIMenuSliderItem";
28
- import { MenuControls } from "./MenuControls";
29
- import { MenuSettings } from "./MenuSettings";
30
31
  class Menu {
31
32
  static {
32
33
  __name(this, "Menu");
@@ -573,7 +574,7 @@ class Menu {
573
574
  this.CurrentSelection = hoveredItemIndex;
574
575
  this.indexChange.emit(this.CurrentSelection);
575
576
  }
576
- await Wait(this._navigationDelay);
577
+ await Delay(this._navigationDelay);
577
578
  while (Game.isDisabledControlPressed(0, Control.Attack) && hoveredItem.IsMouseInBounds) {
578
579
  if (hoveredItem.selected) {
579
580
  if (hoveredItem.enabled) {
@@ -592,7 +593,7 @@ class Menu {
592
593
  this.CurrentSelection = hoveredItemIndex;
593
594
  this.indexChange.emit(this.CurrentSelection);
594
595
  }
595
- await Wait(125);
596
+ await Delay(125);
596
597
  }
597
598
  this._mousePressed = false;
598
599
  })();
@@ -606,10 +607,10 @@ class Menu {
606
607
  (async () => {
607
608
  this._mousePressed = true;
608
609
  this.goUp();
609
- await Wait(this._navigationDelay);
610
+ await Delay(this._navigationDelay);
610
611
  while (Game.isDisabledControlPressed(0, Control.Attack)) {
611
612
  this.goUp();
612
- await Wait(125);
613
+ await Delay(125);
613
614
  }
614
615
  this._mousePressed = false;
615
616
  })();
@@ -626,10 +627,10 @@ class Menu {
626
627
  (async () => {
627
628
  this._mousePressed = true;
628
629
  this.goDown();
629
- await Wait(this._navigationDelay);
630
+ await Delay(this._navigationDelay);
630
631
  while (Game.isDisabledControlPressed(0, Control.Attack)) {
631
632
  this.goDown();
632
- await Wait(125);
633
+ await Delay(125);
633
634
  }
634
635
  this._mousePressed = false;
635
636
  })();
@@ -1,5 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Delay } from "../common/utils/Delay";
3
4
  import { Game } from "../Game";
4
5
  import { Weapon } from "./Weapon";
5
6
  class WeaponAsset {
@@ -50,7 +51,7 @@ class WeaponAsset {
50
51
  this.request();
51
52
  const start = GetGameTimer();
52
53
  while (!this.IsLoaded) {
53
- await Wait(100);
54
+ await Delay(100);
54
55
  const now = GetGameTimer();
55
56
  if (now - start >= timeout) {
56
57
  return false;