@nativewrappers/fivem 0.0.135 → 0.0.137
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/Pickup.d.ts +4 -0
- package/Pickup.js +6 -0
- package/World.d.ts +21 -4
- package/World.js +22 -18
- package/common/GlobalData.d.ts +9 -0
- package/common/GlobalData.js +15 -0
- package/common/collections/CircularBuffer.d.ts +18 -0
- package/common/collections/CircularBuffer.js +92 -0
- package/common/collections/Stack.d.ts +9 -0
- package/common/collections/Stack.js +0 -0
- package/common/decors/Events.js +10 -2
- package/common/decors/Exports.js +3 -1
- package/common/decors/Ticks.js +11 -2
- package/common-game/entities/CommonBaseEntityBoneCollection.d.ts +1 -0
- package/common-game/entities/CommonEntityBoneCollection.d.ts +3 -0
- package/common-game/entities/CommonEntityBoneCollection.js +6 -0
- package/common-game/entities/CommonPedBoneCollection.d.ts +4 -1
- package/common-game/entities/CommonPedBoneCollection.js +8 -2
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +1 -1
- package/world/getGamePool.d.ts +14 -0
- package/world/getGamePool.js +30 -0
package/Pickup.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ import { Vector3 } from "./common/utils/Vector";
|
|
|
2
2
|
export declare class Pickup {
|
|
3
3
|
private handle;
|
|
4
4
|
constructor(handle: number);
|
|
5
|
+
/**
|
|
6
|
+
* @returns `true` if the current entity is networked, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
get IsNetworked(): boolean;
|
|
5
9
|
get Position(): Vector3;
|
|
6
10
|
get IsCollected(): boolean;
|
|
7
11
|
delete(): void;
|
package/Pickup.js
CHANGED
|
@@ -9,6 +9,12 @@ class Pickup {
|
|
|
9
9
|
constructor(handle) {
|
|
10
10
|
this.handle = handle;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* @returns `true` if the current entity is networked, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
get IsNetworked() {
|
|
16
|
+
return NetworkGetEntityIsNetworked(this.handle);
|
|
17
|
+
}
|
|
12
18
|
get Position() {
|
|
13
19
|
return Vector3.fromArray(GetPickupCoords(this.handle));
|
|
14
20
|
}
|
package/World.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Color } from "./common/utils/Color";
|
|
2
|
-
import { Vector3 } from "./common/utils/Vector";
|
|
2
|
+
import { Vector3, Vector4 } from "./common/utils/Vector";
|
|
3
3
|
import { Blip } from "./Blip";
|
|
4
4
|
import { Camera } from "./Camera";
|
|
5
5
|
import { Model } from "./Model";
|
|
@@ -178,18 +178,35 @@ export declare abstract class World {
|
|
|
178
178
|
* Create a ped at a desired location.
|
|
179
179
|
*
|
|
180
180
|
* ```typescript
|
|
181
|
-
* const position = new Vector3(-802.
|
|
181
|
+
* const position = new Vector3(-802.31, 175.06, 72.84);
|
|
182
182
|
* const model = new Model("a_f_m_beach_01");
|
|
183
183
|
* const myPed = await World.createPed(model, position);
|
|
184
184
|
* ```
|
|
185
185
|
*
|
|
186
186
|
* @param model Ped model to be spawned.
|
|
187
187
|
* @param position World position (coordinates) of Ped spawn.
|
|
188
|
-
* @param heading Heading of Ped when spawning.
|
|
189
|
-
* @param shouldNetwork if the created ped should be networked to other clients
|
|
188
|
+
* @param [heading=0] Heading of Ped when spawning.
|
|
189
|
+
* @param [shouldNetwork=false] if the created ped should be networked to other clients
|
|
190
|
+
* @param [pinToScript=true] if the ped should be pinned to the script.
|
|
190
191
|
* @returns Ped object.
|
|
191
192
|
*/
|
|
192
193
|
static createPed(model: Model, position: Vector3, heading?: number, shouldNetwork?: boolean, pinToScript?: boolean): Promise<Ped | null>;
|
|
194
|
+
/**
|
|
195
|
+
* Create a ped at a desired location.
|
|
196
|
+
*
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const position = new Vector4(-802.31, 175.05, 72.84, 122.75);
|
|
199
|
+
* const model = new Model("a_f_m_beach_01");
|
|
200
|
+
* const myPed = await World.createPed(model, position);
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @param model Ped model to be spawned.
|
|
204
|
+
* @param position World position (coordinates) of Ped spawn, note that the `w` section of Vector4 is used for heading.
|
|
205
|
+
* @param [shouldNetwork=false] if the created ped should be networked to other clients
|
|
206
|
+
* @param [pinToScript=true] if the ped should be pinned to the script.
|
|
207
|
+
* @returns Ped object.
|
|
208
|
+
*/
|
|
209
|
+
static createPed(model: Model, position: Vector4, shouldNetwork?: boolean, pinToScript?: boolean): Promise<Ped | null>;
|
|
193
210
|
/**
|
|
194
211
|
* Created a ped in the specified vehicle
|
|
195
212
|
*
|
package/World.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 { Delay } from "./common/utils/Delay";
|
|
4
|
-
import { Vector3 } from "./common/utils/Vector";
|
|
4
|
+
import { Vector3, Vector4 } from "./common/utils/Vector";
|
|
5
5
|
import { Blip } from "./Blip";
|
|
6
6
|
import { Camera } from "./Camera";
|
|
7
7
|
import { GameplayCamera } from "./GameplayCamera";
|
|
@@ -322,26 +322,30 @@ class World {
|
|
|
322
322
|
)
|
|
323
323
|
);
|
|
324
324
|
}
|
|
325
|
-
|
|
326
|
-
* Create a ped at a desired location.
|
|
327
|
-
*
|
|
328
|
-
* ```typescript
|
|
329
|
-
* const position = new Vector3(-802.311, 175.056, 72.8446);
|
|
330
|
-
* const model = new Model("a_f_m_beach_01");
|
|
331
|
-
* const myPed = await World.createPed(model, position);
|
|
332
|
-
* ```
|
|
333
|
-
*
|
|
334
|
-
* @param model Ped model to be spawned.
|
|
335
|
-
* @param position World position (coordinates) of Ped spawn.
|
|
336
|
-
* @param heading Heading of Ped when spawning.
|
|
337
|
-
* @param shouldNetwork if the created ped should be networked to other clients
|
|
338
|
-
* @returns Ped object.
|
|
339
|
-
*/
|
|
340
|
-
static async createPed(model, position, heading = 0, shouldNetwork = true, pinToScript = true) {
|
|
325
|
+
static async createPed(model, position, headingOrNetwork, shouldNetworkOrPin, pinToScript) {
|
|
341
326
|
if (!model.IsPed || !await model.request(1e3)) {
|
|
342
327
|
return null;
|
|
343
328
|
}
|
|
344
|
-
|
|
329
|
+
if (position instanceof Vector4) {
|
|
330
|
+
const shouldNetwork2 = headingOrNetwork ?? false;
|
|
331
|
+
const pinToScriptValue2 = shouldNetworkOrPin ?? true;
|
|
332
|
+
const ped2 = CreatePed(
|
|
333
|
+
-1,
|
|
334
|
+
model.Hash,
|
|
335
|
+
position.x,
|
|
336
|
+
position.y,
|
|
337
|
+
position.z,
|
|
338
|
+
position.w,
|
|
339
|
+
shouldNetwork2,
|
|
340
|
+
pinToScriptValue2
|
|
341
|
+
);
|
|
342
|
+
model.markAsNoLongerNeeded();
|
|
343
|
+
return Ped.fromHandle(ped2);
|
|
344
|
+
}
|
|
345
|
+
const heading = headingOrNetwork ?? 0;
|
|
346
|
+
const shouldNetwork = shouldNetworkOrPin ?? false;
|
|
347
|
+
const pinToScriptValue = pinToScript ?? true;
|
|
348
|
+
const ped = CreatePed(-1, model.Hash, position.x, position.y, position.z, heading, shouldNetwork, pinToScriptValue);
|
|
345
349
|
model.markAsNoLongerNeeded();
|
|
346
350
|
return Ped.fromHandle(ped);
|
|
347
351
|
}
|
package/common/GlobalData.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export declare enum ErrorType {
|
|
2
|
+
Event = 0,
|
|
3
|
+
NetEvent = 1,
|
|
4
|
+
Export = 2,
|
|
5
|
+
Nui = 3,
|
|
6
|
+
Tick = 4,
|
|
7
|
+
Immediate = 5
|
|
8
|
+
}
|
|
1
9
|
export declare class GlobalData {
|
|
2
10
|
static CurrentResource: string;
|
|
3
11
|
static GameName: string;
|
|
@@ -9,4 +17,5 @@ export declare class GlobalData {
|
|
|
9
17
|
static NetworkTick: number | null;
|
|
10
18
|
static NetworkedTicks: any[];
|
|
11
19
|
static EnablePrettyPrint: boolean;
|
|
20
|
+
static OnError: (type: ErrorType, err: Error) => void;
|
|
12
21
|
}
|
package/common/GlobalData.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
|
|
4
|
+
ErrorType2[ErrorType2["Event"] = 0] = "Event";
|
|
5
|
+
ErrorType2[ErrorType2["NetEvent"] = 1] = "NetEvent";
|
|
6
|
+
ErrorType2[ErrorType2["Export"] = 2] = "Export";
|
|
7
|
+
ErrorType2[ErrorType2["Nui"] = 3] = "Nui";
|
|
8
|
+
ErrorType2[ErrorType2["Tick"] = 4] = "Tick";
|
|
9
|
+
ErrorType2[ErrorType2["Immediate"] = 5] = "Immediate";
|
|
10
|
+
return ErrorType2;
|
|
11
|
+
})(ErrorType || {});
|
|
3
12
|
class GlobalData {
|
|
4
13
|
static {
|
|
5
14
|
__name(this, "GlobalData");
|
|
@@ -14,7 +23,13 @@ class GlobalData {
|
|
|
14
23
|
static NetworkTick = null;
|
|
15
24
|
static NetworkedTicks = [];
|
|
16
25
|
static EnablePrettyPrint = true;
|
|
26
|
+
/*
|
|
27
|
+
* Called when one of the decors errors
|
|
28
|
+
*/
|
|
29
|
+
static OnError = /* @__PURE__ */ __name((type, err) => {
|
|
30
|
+
}, "OnError");
|
|
17
31
|
}
|
|
18
32
|
export {
|
|
33
|
+
ErrorType,
|
|
19
34
|
GlobalData
|
|
20
35
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class CircularBuffer<T> {
|
|
2
|
+
private buffer;
|
|
3
|
+
private tail;
|
|
4
|
+
private count;
|
|
5
|
+
private max_size;
|
|
6
|
+
constructor(max_size: number);
|
|
7
|
+
push(item: T): void;
|
|
8
|
+
pop(): T | undefined;
|
|
9
|
+
peek(): T | undefined;
|
|
10
|
+
[Symbol.iterator](): Iterator<T>;
|
|
11
|
+
for_each(callback: (item: T, index: number) => void): void;
|
|
12
|
+
average(this: CircularBuffer<number>): number;
|
|
13
|
+
is_empty(): boolean;
|
|
14
|
+
is_full(): boolean;
|
|
15
|
+
size(): number;
|
|
16
|
+
capacity(): number;
|
|
17
|
+
clear(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
class CircularBuffer {
|
|
4
|
+
static {
|
|
5
|
+
__name(this, "CircularBuffer");
|
|
6
|
+
}
|
|
7
|
+
buffer;
|
|
8
|
+
tail = 0;
|
|
9
|
+
count = 0;
|
|
10
|
+
max_size;
|
|
11
|
+
constructor(max_size) {
|
|
12
|
+
if (max_size <= 0) {
|
|
13
|
+
throw new Error("Buffer size must be greater than 0");
|
|
14
|
+
}
|
|
15
|
+
this.max_size = max_size;
|
|
16
|
+
this.buffer = new Array(max_size);
|
|
17
|
+
}
|
|
18
|
+
push(item) {
|
|
19
|
+
this.buffer[this.tail] = item;
|
|
20
|
+
this.tail++;
|
|
21
|
+
if (this.tail >= this.max_size) {
|
|
22
|
+
this.tail = 0;
|
|
23
|
+
}
|
|
24
|
+
if (this.count < this.max_size) {
|
|
25
|
+
this.count++;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
pop() {
|
|
29
|
+
if (this.is_empty()) {
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
this.tail--;
|
|
33
|
+
if (this.tail < 0) {
|
|
34
|
+
this.tail = this.max_size - 1;
|
|
35
|
+
}
|
|
36
|
+
const item = this.buffer[this.tail];
|
|
37
|
+
this.buffer[this.tail] = void 0;
|
|
38
|
+
this.count--;
|
|
39
|
+
return item;
|
|
40
|
+
}
|
|
41
|
+
peek() {
|
|
42
|
+
if (this.is_empty()) {
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
let peek_index = this.tail - 1;
|
|
46
|
+
if (peek_index < 0) {
|
|
47
|
+
peek_index = this.max_size - 1;
|
|
48
|
+
}
|
|
49
|
+
return this.buffer[peek_index];
|
|
50
|
+
}
|
|
51
|
+
*[Symbol.iterator]() {
|
|
52
|
+
for (let i = 0; i < this.count; i++) {
|
|
53
|
+
yield this.buffer[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for_each(callback) {
|
|
57
|
+
let i = 0;
|
|
58
|
+
for (const item of this) {
|
|
59
|
+
callback(item, i++);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
average() {
|
|
63
|
+
if (this.is_empty()) {
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
let sum = 0;
|
|
67
|
+
for (const item of this) {
|
|
68
|
+
sum += item;
|
|
69
|
+
}
|
|
70
|
+
return sum / this.count;
|
|
71
|
+
}
|
|
72
|
+
is_empty() {
|
|
73
|
+
return this.count === 0;
|
|
74
|
+
}
|
|
75
|
+
is_full() {
|
|
76
|
+
return this.count === this.max_size;
|
|
77
|
+
}
|
|
78
|
+
size() {
|
|
79
|
+
return this.count;
|
|
80
|
+
}
|
|
81
|
+
capacity() {
|
|
82
|
+
return this.max_size;
|
|
83
|
+
}
|
|
84
|
+
clear() {
|
|
85
|
+
this.buffer = new Array(this.max_size);
|
|
86
|
+
this.tail = 0;
|
|
87
|
+
this.count = 0;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
CircularBuffer
|
|
92
|
+
};
|
|
File without changes
|
package/common/decors/Events.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { GlobalData } from "../GlobalData";
|
|
3
|
+
import { ErrorType, GlobalData } from "../GlobalData";
|
|
4
4
|
const DisablePrettyPrint = /* @__PURE__ */ __name(() => GlobalData.EnablePrettyPrint = false, "DisablePrettyPrint");
|
|
5
5
|
const AsyncFunction = (async () => {
|
|
6
6
|
}).constructor;
|
|
@@ -14,6 +14,7 @@ function OnEvent(eventName) {
|
|
|
14
14
|
try {
|
|
15
15
|
return await originalMethod.call(this, ...args);
|
|
16
16
|
} catch (e) {
|
|
17
|
+
GlobalData.OnError(ErrorType.Event, e);
|
|
17
18
|
REMOVE_EVENT_LOG: {
|
|
18
19
|
if (!GlobalData.EnablePrettyPrint) return;
|
|
19
20
|
console.error("------- EVENT ERROR --------");
|
|
@@ -62,6 +63,7 @@ function OnNetEvent(eventName, remoteOnly = true) {
|
|
|
62
63
|
}
|
|
63
64
|
return await originalMethod.call(this, ...args);
|
|
64
65
|
} catch (e) {
|
|
66
|
+
GlobalData.OnError(ErrorType.NetEvent, e);
|
|
65
67
|
REMOVE_NET_EVENT_LOG: {
|
|
66
68
|
if (!GlobalData.EnablePrettyPrint) return;
|
|
67
69
|
console.error("------- NET EVENT ERROR --------");
|
|
@@ -90,7 +92,13 @@ function OnNuiEvent(eventName, dontErrorWhenCbIsntInvoked = false) {
|
|
|
90
92
|
wasInvoked = true;
|
|
91
93
|
cb(args);
|
|
92
94
|
}, "cbWrapper");
|
|
93
|
-
|
|
95
|
+
let retData;
|
|
96
|
+
try {
|
|
97
|
+
retData = await originalMethod.call(this, data, cbWrapper);
|
|
98
|
+
} catch (e) {
|
|
99
|
+
GlobalData.OnError(ErrorType.Nui, e);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
94
102
|
if (!wasInvoked && !retData) {
|
|
95
103
|
if (dontErrorWhenCbIsntInvoked) return;
|
|
96
104
|
throw new Error(
|
package/common/decors/Exports.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { GlobalData } from "../GlobalData";
|
|
3
|
+
import { ErrorType, GlobalData } from "../GlobalData";
|
|
4
4
|
const AsyncFunction = (async () => {
|
|
5
5
|
}).constructor;
|
|
6
6
|
function Exports(exportName) {
|
|
@@ -15,6 +15,7 @@ function Exports(exportName) {
|
|
|
15
15
|
try {
|
|
16
16
|
return await originalMethod.call(this, ...args);
|
|
17
17
|
} catch (err) {
|
|
18
|
+
GlobalData.OnError(ErrorType.Export, err);
|
|
18
19
|
REMOVE_EVENT_LOG: {
|
|
19
20
|
if (!GlobalData.EnablePrettyPrint) return;
|
|
20
21
|
console.error("------- EXPORT ERROR --------");
|
|
@@ -31,6 +32,7 @@ function Exports(exportName) {
|
|
|
31
32
|
try {
|
|
32
33
|
return originalMethod.call(this, ...args);
|
|
33
34
|
} catch (err) {
|
|
35
|
+
GlobalData.OnError(ErrorType.Export, err);
|
|
34
36
|
REMOVE_EVENT_LOG: {
|
|
35
37
|
if (!GlobalData.EnablePrettyPrint) return;
|
|
36
38
|
console.error("------- EXPORT ERROR --------");
|
package/common/decors/Ticks.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 { ErrorType, GlobalData } from "../GlobalData";
|
|
3
4
|
function SetTick() {
|
|
4
5
|
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
5
6
|
if (context.private) {
|
|
@@ -7,7 +8,11 @@ function SetTick() {
|
|
|
7
8
|
}
|
|
8
9
|
context.addInitializer(function() {
|
|
9
10
|
setTick(async () => {
|
|
10
|
-
|
|
11
|
+
try {
|
|
12
|
+
await originalMethod.call(this);
|
|
13
|
+
} catch (e) {
|
|
14
|
+
GlobalData.OnError(ErrorType.Tick, e);
|
|
15
|
+
}
|
|
11
16
|
});
|
|
12
17
|
});
|
|
13
18
|
}, "actualDecorator");
|
|
@@ -20,7 +25,11 @@ function SetImmediate() {
|
|
|
20
25
|
}
|
|
21
26
|
context.addInitializer(function() {
|
|
22
27
|
setImmediate(async () => {
|
|
23
|
-
|
|
28
|
+
try {
|
|
29
|
+
await originalMethod.call(this);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
GlobalData.OnError(ErrorType.Immediate, e);
|
|
32
|
+
}
|
|
24
33
|
});
|
|
25
34
|
});
|
|
26
35
|
}, "actualDecorator");
|
|
@@ -5,5 +5,6 @@ export declare abstract class CommonBaseEntityBoneCollection {
|
|
|
5
5
|
constructor(owner: IHandle);
|
|
6
6
|
hasBone(name: string): boolean;
|
|
7
7
|
abstract getBone(boneIndex?: number, boneName?: string): CommonBaseEntityBone;
|
|
8
|
+
abstract getBoneFromName(boneName: string): CommonBaseEntityBone;
|
|
8
9
|
abstract get Core(): CommonBaseEntityBone;
|
|
9
10
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { CommonBaseEntityBone } from "./CommonBaseEntityBone";
|
|
1
2
|
import { CommonBaseEntityBoneCollection } from "./CommonBaseEntityBoneCollection";
|
|
2
3
|
import { CommonEntityBone } from "./CommonEntityBone";
|
|
3
4
|
import type { IHandle } from "./IHandle";
|
|
4
5
|
export declare class CommonEntityBoneCollection extends CommonBaseEntityBoneCollection {
|
|
5
6
|
constructor(owner: IHandle);
|
|
7
|
+
getBoneFromName(boneName: string): CommonBaseEntityBone;
|
|
8
|
+
getBoneFromIndex(boneIndex: number): CommonBaseEntityBone;
|
|
6
9
|
getBone(boneIndex: number): CommonEntityBone;
|
|
7
10
|
getBone(boneName: string): CommonEntityBone;
|
|
8
11
|
get Core(): CommonEntityBone;
|
|
@@ -9,6 +9,12 @@ class CommonEntityBoneCollection extends CommonBaseEntityBoneCollection {
|
|
|
9
9
|
constructor(owner) {
|
|
10
10
|
super(owner);
|
|
11
11
|
}
|
|
12
|
+
getBoneFromName(boneName) {
|
|
13
|
+
return new CommonEntityBone(this.owner, GetEntityBoneIndexByName(this.owner.Handle, boneName));
|
|
14
|
+
}
|
|
15
|
+
getBoneFromIndex(boneIndex) {
|
|
16
|
+
return new CommonEntityBone(this.owner, boneIndex);
|
|
17
|
+
}
|
|
12
18
|
getBone(bone) {
|
|
13
19
|
return new CommonEntityBone(
|
|
14
20
|
this.owner,
|
|
@@ -6,5 +6,8 @@ export declare class CommonPedBoneCollection extends CommonBaseEntityBoneCollect
|
|
|
6
6
|
get Core(): CommonPedBone;
|
|
7
7
|
get LastDamaged(): CommonPedBone;
|
|
8
8
|
clearLastDamaged(): void;
|
|
9
|
-
|
|
9
|
+
getBoneFromId(boneId: number): CommonPedBone;
|
|
10
|
+
getBoneFromName(boneName: string): CommonPedBone;
|
|
11
|
+
getBone(boneIndex: number): CommonPedBone;
|
|
12
|
+
getBone(boneName: string): CommonPedBone;
|
|
10
13
|
}
|
|
@@ -19,10 +19,16 @@ class CommonPedBoneCollection extends CommonBaseEntityBoneCollection {
|
|
|
19
19
|
clearLastDamaged() {
|
|
20
20
|
ClearPedLastDamageBone(this.owner.Handle);
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
getBoneFromId(boneId) {
|
|
23
|
+
return new CommonPedBone(this.owner, GetPedBoneIndex(this.owner.Handle, boneId));
|
|
24
|
+
}
|
|
25
|
+
getBoneFromName(boneName) {
|
|
26
|
+
return new CommonPedBone(this.owner, GetEntityBoneIndexByName(this.owner.Handle, boneName));
|
|
27
|
+
}
|
|
28
|
+
getBone(bone) {
|
|
23
29
|
return new CommonPedBone(
|
|
24
30
|
this.owner,
|
|
25
|
-
|
|
31
|
+
typeof bone === "number" ? bone : GetEntityBoneIndexByName(this.owner.Handle, bone ?? "")
|
|
26
32
|
);
|
|
27
33
|
}
|
|
28
34
|
}
|
package/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./Rope";
|
|
|
16
16
|
export * from "./TaskSequence";
|
|
17
17
|
export * from "./Tasks";
|
|
18
18
|
export * from "./World";
|
|
19
|
+
export * from "./world/getGamePool";
|
|
19
20
|
export * from "./weaponComponent/ComponentAttachmentPoint";
|
|
20
21
|
export * from "./weaponComponent/ComponentAttachmentPointByHash";
|
|
21
22
|
export * from "./weaponComponent/ComponentDisplayNameByHash";
|
|
@@ -197,5 +198,7 @@ export * from "./common/decors/Exports";
|
|
|
197
198
|
export * from "./common/decors/Permissions";
|
|
198
199
|
export * from "./common/decors/Resources";
|
|
199
200
|
export * from "./common/decors/Ticks";
|
|
201
|
+
export * from "./common/collections/CircularBuffer";
|
|
202
|
+
export * from "./common/collections/Stack";
|
|
200
203
|
export * from "./cfx/StateBagChangeHandler";
|
|
201
204
|
export * from "./cfx/index";
|
package/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./Rope";
|
|
|
16
16
|
export * from "./TaskSequence";
|
|
17
17
|
export * from "./Tasks";
|
|
18
18
|
export * from "./World";
|
|
19
|
+
export * from "./world/getGamePool";
|
|
19
20
|
export * from "./weaponComponent/ComponentAttachmentPoint";
|
|
20
21
|
export * from "./weaponComponent/ComponentAttachmentPointByHash";
|
|
21
22
|
export * from "./weaponComponent/ComponentDisplayNameByHash";
|
|
@@ -197,5 +198,7 @@ export * from "./common/decors/Exports";
|
|
|
197
198
|
export * from "./common/decors/Permissions";
|
|
198
199
|
export * from "./common/decors/Resources";
|
|
199
200
|
export * from "./common/decors/Ticks";
|
|
201
|
+
export * from "./common/collections/CircularBuffer";
|
|
202
|
+
export * from "./common/collections/Stack";
|
|
200
203
|
export * from "./cfx/StateBagChangeHandler";
|
|
201
204
|
export * from "./cfx/index";
|
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Pickup } from "../Pickup";
|
|
2
|
+
import { Ped, Prop, Vehicle } from "../models";
|
|
3
|
+
declare const constructorMap: {
|
|
4
|
+
CObject: typeof Prop;
|
|
5
|
+
CPed: typeof Ped;
|
|
6
|
+
CVehicle: typeof Vehicle;
|
|
7
|
+
CPickup: typeof Pickup;
|
|
8
|
+
CNetObject: typeof Prop;
|
|
9
|
+
};
|
|
10
|
+
type PoolTypeMap = {
|
|
11
|
+
[K in keyof typeof constructorMap]: InstanceType<(typeof constructorMap)[K]>;
|
|
12
|
+
};
|
|
13
|
+
export declare function getGamePool<T extends keyof typeof constructorMap>(type: T, networkOnly?: boolean): PoolTypeMap[T][];
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { Pickup } from "../Pickup";
|
|
4
|
+
import { BaseEntity, Ped, Prop, Vehicle } from "../models";
|
|
5
|
+
const constructorMap = {
|
|
6
|
+
CObject: Prop,
|
|
7
|
+
CPed: Ped,
|
|
8
|
+
CVehicle: Vehicle,
|
|
9
|
+
CPickup: Pickup,
|
|
10
|
+
CNetObject: Prop
|
|
11
|
+
};
|
|
12
|
+
function getGamePool(type, networkOnly = false) {
|
|
13
|
+
const pool = GetGamePool(type);
|
|
14
|
+
const entityConstructor = constructorMap[type];
|
|
15
|
+
let poolMap = pool.map((v) => {
|
|
16
|
+
const p = new entityConstructor(v);
|
|
17
|
+
if (networkOnly && !p.IsNetworked) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return p;
|
|
21
|
+
});
|
|
22
|
+
if (networkOnly) {
|
|
23
|
+
poolMap = poolMap.filter((v) => v !== null);
|
|
24
|
+
}
|
|
25
|
+
return poolMap;
|
|
26
|
+
}
|
|
27
|
+
__name(getGamePool, "getGamePool");
|
|
28
|
+
export {
|
|
29
|
+
getGamePool
|
|
30
|
+
};
|