@nativewrappers/fivem 0.0.89 → 0.0.92
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/World.d.ts +14 -2
- package/World.js +28 -25
- package/common/decors/Events.js +4 -2
- package/package.json +1 -1
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
|
|
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,
|
|
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
|
@@ -334,14 +334,32 @@ class World {
|
|
|
334
334
|
* @param model Ped model to be spawned.
|
|
335
335
|
* @param position World position (coordinates) of Ped spawn.
|
|
336
336
|
* @param heading Heading of Ped when spawning.
|
|
337
|
-
* @param
|
|
337
|
+
* @param shouldNetwork if the created ped should be networked to other clients
|
|
338
338
|
* @returns Ped object.
|
|
339
339
|
*/
|
|
340
|
-
static async createPed(model, position, heading = 0,
|
|
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) {
|
|
341
359
|
if (!model.IsPed || !await model.request(1e3)) {
|
|
342
360
|
return null;
|
|
343
361
|
}
|
|
344
|
-
const ped =
|
|
362
|
+
const ped = CreatePedInsideVehicle(vehicle.Handle, -1, model.Hash, seat, shouldNetwork, pinToScript);
|
|
345
363
|
model.markAsNoLongerNeeded();
|
|
346
364
|
return Ped.fromHandle(ped);
|
|
347
365
|
}
|
|
@@ -379,9 +397,7 @@ class World {
|
|
|
379
397
|
return null;
|
|
380
398
|
}
|
|
381
399
|
const vehicle = CreateVehicle(model.Hash, position.x, position.y, position.z, heading, isNetwork, pinToScript);
|
|
382
|
-
|
|
383
|
-
return null;
|
|
384
|
-
}
|
|
400
|
+
model.markAsNoLongerNeeded();
|
|
385
401
|
return new Vehicle(vehicle);
|
|
386
402
|
}
|
|
387
403
|
/**
|
|
@@ -816,10 +832,7 @@ class World {
|
|
|
816
832
|
*/
|
|
817
833
|
static getClosestObject(model, coords, radius = 25, isMission = false) {
|
|
818
834
|
const prop = GetClosestObjectOfType(coords.x, coords.y, coords.z, radius, model.Hash, isMission, false, false);
|
|
819
|
-
|
|
820
|
-
return new Prop(prop);
|
|
821
|
-
}
|
|
822
|
-
return null;
|
|
835
|
+
return Prop.fromHandle(prop);
|
|
823
836
|
}
|
|
824
837
|
/**
|
|
825
838
|
* Get all [[`Prop`]] entities in your own scope.
|
|
@@ -828,9 +841,7 @@ class World {
|
|
|
828
841
|
*/
|
|
829
842
|
static getAllProps() {
|
|
830
843
|
const handles = GetGamePool("CObject");
|
|
831
|
-
|
|
832
|
-
handles.forEach((handle) => props.push(new Prop(handle)));
|
|
833
|
-
return props;
|
|
844
|
+
return handles.map((handle) => new Prop(handle));
|
|
834
845
|
}
|
|
835
846
|
/**
|
|
836
847
|
* Get all [[`Rope`]] entities in your own scope.
|
|
@@ -839,9 +850,7 @@ class World {
|
|
|
839
850
|
*/
|
|
840
851
|
static getAllRopes() {
|
|
841
852
|
const handles = GetAllRopes();
|
|
842
|
-
|
|
843
|
-
handles.forEach((handle) => props.push(new Rope(handle)));
|
|
844
|
-
return props;
|
|
853
|
+
return handles.map((handle) => new Rope(handle));
|
|
845
854
|
}
|
|
846
855
|
/**
|
|
847
856
|
* Get all [[`Ped`]] entities in your own scope.
|
|
@@ -850,9 +859,7 @@ class World {
|
|
|
850
859
|
*/
|
|
851
860
|
static getAllPeds() {
|
|
852
861
|
const handles = GetGamePool("CPed");
|
|
853
|
-
|
|
854
|
-
handles.forEach((handle) => peds.push(new Ped(handle)));
|
|
855
|
-
return peds;
|
|
862
|
+
return handles.map((handle) => new Ped(handle));
|
|
856
863
|
}
|
|
857
864
|
/**
|
|
858
865
|
* Get all [[`Vehicle`]] entities in your own scope.
|
|
@@ -861,9 +868,7 @@ class World {
|
|
|
861
868
|
*/
|
|
862
869
|
static getAllVehicles() {
|
|
863
870
|
const handles = GetGamePool("CVehicle");
|
|
864
|
-
|
|
865
|
-
handles.forEach((handle) => vehicles.push(new Vehicle(handle)));
|
|
866
|
-
return vehicles;
|
|
871
|
+
return handles.map((handle) => new Vehicle(handle));
|
|
867
872
|
}
|
|
868
873
|
/**
|
|
869
874
|
* Gets the cloest [[`Vehicle`]] to the current coords, or null if none are found
|
|
@@ -893,9 +898,7 @@ class World {
|
|
|
893
898
|
*/
|
|
894
899
|
static getAllPickups() {
|
|
895
900
|
const handles = GetGamePool("CPickup");
|
|
896
|
-
|
|
897
|
-
handles.forEach((handle) => pickups.push(new Pickup(handle)));
|
|
898
|
-
return pickups;
|
|
901
|
+
return handles.map((handle) => new Pickup(handle));
|
|
899
902
|
}
|
|
900
903
|
static currentCloudHat = CloudHat.Clear;
|
|
901
904
|
static cloudHatDict = /* @__PURE__ */ new Map([
|
package/common/decors/Events.js
CHANGED
|
@@ -123,11 +123,13 @@ function ConVar(name, is_floating_point, deserialize) {
|
|
|
123
123
|
}
|
|
124
124
|
} else if (default_type === "boolean") {
|
|
125
125
|
con_var_type = 3 /* Boolean */;
|
|
126
|
-
} else if (
|
|
126
|
+
} else if (default_type === "string") {
|
|
127
127
|
con_var_type = 0 /* String */;
|
|
128
128
|
}
|
|
129
129
|
if (!deserialize && con_var_type === null) {
|
|
130
|
-
throw new Error(
|
|
130
|
+
throw new Error(
|
|
131
|
+
`Failed to determine what to use to deserialize '${name}' was for var had type '${default_type}' which can't be deserialized without providing your own deserialize function.`
|
|
132
|
+
);
|
|
131
133
|
}
|
|
132
134
|
if (con_var_type === null) {
|
|
133
135
|
con_var_type = 0 /* String */;
|