@nativewrappers/common-game 0.0.114
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/CommonGameConstants.d.ts +7 -0
- package/CommonGameConstants.js +24 -0
- package/CommonModel.d.ts +99 -0
- package/CommonModel.js +172 -0
- package/CommonTasks.d.ts +43 -0
- package/CommonTasks.js +232 -0
- package/README.md +45 -0
- package/cfx/StateBagChangeHandler.d.ts +1 -0
- package/cfx/StateBagChangeHandler.js +0 -0
- package/cfx/cfx.d.ts +6 -0
- package/cfx/cfx.js +4 -0
- package/common/Command.d.ts +77 -0
- package/common/Command.js +152 -0
- package/common/Convar.d.ts +13 -0
- package/common/Convar.js +58 -0
- package/common/GlobalData.d.ts +10 -0
- package/common/GlobalData.js +18 -0
- package/common/Kvp.d.ts +69 -0
- package/common/Kvp.js +137 -0
- package/common/Resource.d.ts +14 -0
- package/common/Resource.js +54 -0
- package/common/decors/Events.d.ts +65 -0
- package/common/decors/Events.js +208 -0
- package/common/net/NetworkedMap.d.ts +28 -0
- package/common/net/NetworkedMap.js +225 -0
- package/common/types.d.ts +5 -0
- package/common/types.js +0 -0
- package/common/utils/ClassTypes.d.ts +11 -0
- package/common/utils/ClassTypes.js +15 -0
- package/common/utils/Color.d.ts +14 -0
- package/common/utils/Color.js +33 -0
- package/common/utils/Delay.d.ts +1 -0
- package/common/utils/Delay.js +6 -0
- package/common/utils/Maths.d.ts +4 -0
- package/common/utils/Maths.js +18 -0
- package/common/utils/Point.d.ts +9 -0
- package/common/utils/Point.js +36 -0
- package/common/utils/PointF.d.ts +7 -0
- package/common/utils/PointF.js +18 -0
- package/common/utils/Quaternion.d.ts +10 -0
- package/common/utils/Quaternion.js +33 -0
- package/common/utils/Vector.d.ts +429 -0
- package/common/utils/Vector.js +589 -0
- package/common/utils/cleanPlayerName.d.ts +6 -0
- package/common/utils/cleanPlayerName.js +17 -0
- package/common/utils/enumValues.d.ts +12 -0
- package/common/utils/enumValues.js +20 -0
- package/common/utils/getStringFromUInt8Array.d.ts +8 -0
- package/common/utils/getStringFromUInt8Array.js +6 -0
- package/common/utils/getUInt32FromUint8Array.d.ts +8 -0
- package/common/utils/getUInt32FromUint8Array.js +6 -0
- package/common/utils/randomInt.d.ts +1 -0
- package/common/utils/randomInt.js +9 -0
- package/definitions/index.d.js +0 -0
- package/definitions/redm.d.js +0 -0
- package/entities/CommonBaseEntity.d.ts +66 -0
- package/entities/CommonBaseEntity.js +180 -0
- package/entities/CommonBaseEntityBone.d.ts +11 -0
- package/entities/CommonBaseEntityBone.js +32 -0
- package/entities/CommonBaseEntityBoneCollection.d.ts +9 -0
- package/entities/CommonBaseEntityBoneCollection.js +17 -0
- package/entities/CommonEntityBone.d.ts +5 -0
- package/entities/CommonEntityBone.js +14 -0
- package/entities/CommonEntityBoneCollection.d.ts +9 -0
- package/entities/CommonEntityBoneCollection.js +24 -0
- package/entities/CommonEntityType.d.ts +4 -0
- package/entities/CommonEntityType.js +3 -0
- package/entities/CommonPed.d.ts +17 -0
- package/entities/CommonPed.js +55 -0
- package/entities/CommonPedBone.d.ts +6 -0
- package/entities/CommonPedBone.js +17 -0
- package/entities/CommonPedBoneCollection.d.ts +10 -0
- package/entities/CommonPedBoneCollection.js +31 -0
- package/entities/CommonPlayer.d.ts +61 -0
- package/entities/CommonPlayer.js +156 -0
- package/entities/CommonProp.d.ts +16 -0
- package/entities/CommonProp.js +46 -0
- package/entities/CommonVehicle.d.ts +12 -0
- package/entities/CommonVehicle.js +39 -0
- package/entities/GetEntityClassIdFromHandle.d.ts +2 -0
- package/entities/GetEntityClassIdFromHandle.js +23 -0
- package/enums/VehicleSeat.d.ts +13 -0
- package/enums/VehicleSeat.js +17 -0
- package/index.d.ts +44 -0
- package/index.js +44 -0
- package/interfaces/Dimension.d.ts +5 -0
- package/interfaces/Dimension.js +0 -0
- package/package.json +36 -0
- package/utils/Animations.d.ts +19 -0
- package/utils/Animations.js +43 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { CommonPed } from "./CommonPed";
|
|
4
|
+
import { ClassTypes } from "../common/utils/ClassTypes";
|
|
5
|
+
import { GameConstants } from "common-game/CommonGameConstants";
|
|
6
|
+
import cfx from "common-game/cfx/cfx";
|
|
7
|
+
import { GetEntityClassFromHandle } from "./GetEntityClassIdFromHandle";
|
|
8
|
+
class CommonPlayer {
|
|
9
|
+
static {
|
|
10
|
+
__name(this, "CommonPlayer");
|
|
11
|
+
}
|
|
12
|
+
handle;
|
|
13
|
+
ped;
|
|
14
|
+
pvp = false;
|
|
15
|
+
stateBagCookies = [];
|
|
16
|
+
source;
|
|
17
|
+
type = ClassTypes.Player;
|
|
18
|
+
static *AllPlayers(excludeLocalPlayer = true) {
|
|
19
|
+
for (const ply of GetActivePlayers()) {
|
|
20
|
+
if (excludeLocalPlayer && ply === GameConstants.PlayerId) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
yield new CommonPlayer(ply);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @param handle the handoe of the ped to get the player of
|
|
28
|
+
* @returns the player, or null if the player doesn't exist
|
|
29
|
+
*/
|
|
30
|
+
static fromPedHandle(handle) {
|
|
31
|
+
const playerHandle = NetworkGetPlayerIndexFromPed(handle);
|
|
32
|
+
if (!handle) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return new CommonPlayer(playerHandle);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @param serverId the server id to get the player of
|
|
39
|
+
* @returns the player, or null if the player doesn't exist
|
|
40
|
+
*/
|
|
41
|
+
static fromServerId(serverId) {
|
|
42
|
+
const player = GetPlayerFromServerId(serverId);
|
|
43
|
+
if (player === -1) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return new CommonPlayer(player);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @param [minimumDistance=Number.MAX_VALUE] the minimum distance this should check
|
|
50
|
+
* @param [fromPlayer=GameConstants.Player] the player to get the distance from
|
|
51
|
+
* @returns the closest player from {@param fromPlayer} and the distance the player was
|
|
52
|
+
*/
|
|
53
|
+
static getClosestPlayerPedWithDistance(minimumDistance = Number.MAX_VALUE, fromPlayer = GameConstants.Player) {
|
|
54
|
+
const ped = fromPlayer.Ped;
|
|
55
|
+
const pos = ped.Position;
|
|
56
|
+
const data = [null, Number.MAX_VALUE];
|
|
57
|
+
for (const ply of CommonPlayer.AllPlayers(true)) {
|
|
58
|
+
const tgtPed = ply.Ped;
|
|
59
|
+
const dist = pos.distance(tgtPed.Position);
|
|
60
|
+
if (dist < data[1] && dist < minimumDistance) {
|
|
61
|
+
data[0] = tgtPed;
|
|
62
|
+
data[1] = dist;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @param [minimumDistance=Number.MAX_VALUE] the minimum distance this should check
|
|
69
|
+
* @param [fromPlayer=GameConstants.Player] the player to get the distance from
|
|
70
|
+
* @returns the closest player from {@param fromPlayer} and the distance the player was
|
|
71
|
+
*/
|
|
72
|
+
static getClosestPlayerPed(minimumDistance = Number.MAX_VALUE, fromPlayer = GameConstants.Player) {
|
|
73
|
+
const data = this.getClosestPlayerPedWithDistance(minimumDistance, fromPlayer);
|
|
74
|
+
return data[0];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @param handle the player handle, or if on the server, their source.
|
|
78
|
+
*/
|
|
79
|
+
constructor(handle = -1) {
|
|
80
|
+
this.handle = handle;
|
|
81
|
+
this.source = this.ServerId;
|
|
82
|
+
}
|
|
83
|
+
get Handle() {
|
|
84
|
+
return this.handle;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* This is here for compatibility with older versions.
|
|
88
|
+
*/
|
|
89
|
+
get Character() {
|
|
90
|
+
return this.Ped;
|
|
91
|
+
}
|
|
92
|
+
get Ped() {
|
|
93
|
+
const handle = GetPlayerPed(this.handle);
|
|
94
|
+
if (typeof this.ped === "undefined" || handle !== this.ped.Handle) {
|
|
95
|
+
this.ped = new CommonPed(handle);
|
|
96
|
+
}
|
|
97
|
+
return this.ped;
|
|
98
|
+
}
|
|
99
|
+
get ServerId() {
|
|
100
|
+
if (this.source) {
|
|
101
|
+
return this.source;
|
|
102
|
+
}
|
|
103
|
+
return GetPlayerServerId(this.handle);
|
|
104
|
+
}
|
|
105
|
+
get State() {
|
|
106
|
+
return cfx.Player(this.ServerId).state;
|
|
107
|
+
}
|
|
108
|
+
AddStateBagChangeHandler(keyFilter, handler) {
|
|
109
|
+
const cookie = AddStateBagChangeHandler(keyFilter, `player:${this.ServerId}`, handler);
|
|
110
|
+
this.stateBagCookies.push(cookie);
|
|
111
|
+
return cookie;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A short hand function for AddStateBagChangeHandler, this gets automatically cleaned up on entity deletion.
|
|
115
|
+
* @param keyFilter the key to filter for or null
|
|
116
|
+
* @param handler the function to handle the change
|
|
117
|
+
* @returns a cookie to be used in RemoveStateBagChangeHandler
|
|
118
|
+
*/
|
|
119
|
+
listenForStateChange(keyFilter, handler) {
|
|
120
|
+
return this.AddStateBagChangeHandler(keyFilter, handler);
|
|
121
|
+
}
|
|
122
|
+
removeStateListener(tgtCookie) {
|
|
123
|
+
this.stateBagCookies = this.stateBagCookies.filter((cookie) => {
|
|
124
|
+
const isCookie = cookie === tgtCookie;
|
|
125
|
+
if (isCookie) RemoveStateBagChangeHandler(cookie);
|
|
126
|
+
return isCookie;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
removeAllStateListeners() {
|
|
130
|
+
for (const cookie of this.stateBagCookies) {
|
|
131
|
+
RemoveStateBagChangeHandler(cookie);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
get Name() {
|
|
135
|
+
return GetPlayerName(this.handle);
|
|
136
|
+
}
|
|
137
|
+
get IsDead() {
|
|
138
|
+
return IsPlayerDead(this.handle);
|
|
139
|
+
}
|
|
140
|
+
set DisableFiring(value) {
|
|
141
|
+
DisablePlayerFiring(this.handle, value);
|
|
142
|
+
}
|
|
143
|
+
get EntityPlayerIsAimingAt() {
|
|
144
|
+
const [entityHit, entity] = GetEntityPlayerIsFreeAimingAt(this.handle);
|
|
145
|
+
if (entityHit) {
|
|
146
|
+
return GetEntityClassFromHandle(entity);
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
get StealthNoise() {
|
|
151
|
+
return GetPlayerCurrentStealthNoise(this.handle);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
CommonPlayer
|
|
156
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ClassTypes } from "../common/utils/ClassTypes";
|
|
2
|
+
import { CommonBaseEntity } from "./CommonBaseEntity";
|
|
3
|
+
import { CommonEntityBoneCollection } from "./CommonEntityBoneCollection";
|
|
4
|
+
import type { CommonEntity } from "./CommonEntityType";
|
|
5
|
+
export declare class CommonProp extends CommonBaseEntity {
|
|
6
|
+
static exists(prop: CommonProp): boolean;
|
|
7
|
+
static fromHandle(handle: number): CommonProp | null;
|
|
8
|
+
static fromNetworkId(networkId: number): CommonProp | null;
|
|
9
|
+
protected type: ClassTypes;
|
|
10
|
+
protected bones?: CommonEntityBoneCollection | undefined;
|
|
11
|
+
constructor(handle: number);
|
|
12
|
+
exists(): boolean;
|
|
13
|
+
placeOnGround(): void;
|
|
14
|
+
getEntityAttachedTo(): CommonEntity;
|
|
15
|
+
get Bones(): CommonEntityBoneCollection;
|
|
16
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { ClassTypes } from "../common/utils/ClassTypes";
|
|
4
|
+
import { CommonBaseEntity } from "./CommonBaseEntity";
|
|
5
|
+
import { CommonEntityBoneCollection } from "./CommonEntityBoneCollection";
|
|
6
|
+
import { GetEntityClassFromHandle } from "./GetEntityClassIdFromHandle";
|
|
7
|
+
class CommonProp extends CommonBaseEntity {
|
|
8
|
+
static {
|
|
9
|
+
__name(this, "CommonProp");
|
|
10
|
+
}
|
|
11
|
+
static exists(prop) {
|
|
12
|
+
return typeof prop !== "undefined" && prop.exists();
|
|
13
|
+
}
|
|
14
|
+
static fromHandle(handle) {
|
|
15
|
+
return new this(handle);
|
|
16
|
+
}
|
|
17
|
+
static fromNetworkId(networkId) {
|
|
18
|
+
if (!NetworkDoesEntityExistWithNetworkId(networkId)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return new this(NetworkGetEntityFromNetworkId(networkId));
|
|
22
|
+
}
|
|
23
|
+
type = ClassTypes.Prop;
|
|
24
|
+
bones;
|
|
25
|
+
constructor(handle) {
|
|
26
|
+
super(handle);
|
|
27
|
+
}
|
|
28
|
+
exists() {
|
|
29
|
+
return super.exists() && GetEntityType(this.handle) === 3;
|
|
30
|
+
}
|
|
31
|
+
placeOnGround() {
|
|
32
|
+
PlaceObjectOnGroundProperly(this.handle);
|
|
33
|
+
}
|
|
34
|
+
getEntityAttachedTo() {
|
|
35
|
+
return GetEntityClassFromHandle(this.handle);
|
|
36
|
+
}
|
|
37
|
+
get Bones() {
|
|
38
|
+
if (!this.bones) {
|
|
39
|
+
this.bones = new CommonEntityBoneCollection(this);
|
|
40
|
+
}
|
|
41
|
+
return this.bones;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
CommonProp
|
|
46
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ClassTypes } from "../common/utils/ClassTypes";
|
|
2
|
+
import { CommonBaseEntity } from "./CommonBaseEntity";
|
|
3
|
+
import { CommonEntityBoneCollection } from "./CommonEntityBoneCollection";
|
|
4
|
+
export declare class CommonVehicle extends CommonBaseEntity {
|
|
5
|
+
static exists(vehicle: CommonVehicle): boolean;
|
|
6
|
+
static fromHandle(handle: number): CommonVehicle | null;
|
|
7
|
+
static fromNetworkId(networkId: number): CommonVehicle | null;
|
|
8
|
+
protected type: ClassTypes;
|
|
9
|
+
protected bones?: CommonEntityBoneCollection;
|
|
10
|
+
constructor(handle: number);
|
|
11
|
+
get Bones(): CommonEntityBoneCollection;
|
|
12
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { ClassTypes } from "../common/utils/ClassTypes";
|
|
4
|
+
import { CommonBaseEntity } from "./CommonBaseEntity";
|
|
5
|
+
import { CommonEntityBoneCollection } from "./CommonEntityBoneCollection";
|
|
6
|
+
class CommonVehicle extends CommonBaseEntity {
|
|
7
|
+
static {
|
|
8
|
+
__name(this, "CommonVehicle");
|
|
9
|
+
}
|
|
10
|
+
static exists(vehicle) {
|
|
11
|
+
return typeof vehicle !== "undefined" && vehicle.exists();
|
|
12
|
+
}
|
|
13
|
+
static fromHandle(handle) {
|
|
14
|
+
if (handle === 0 || !DoesEntityExist(handle)) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return new this(handle);
|
|
18
|
+
}
|
|
19
|
+
static fromNetworkId(networkId) {
|
|
20
|
+
if (!NetworkDoesEntityExistWithNetworkId(networkId)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return new this(NetworkGetEntityFromNetworkId(networkId));
|
|
24
|
+
}
|
|
25
|
+
type = ClassTypes.Vehicle;
|
|
26
|
+
bones;
|
|
27
|
+
constructor(handle) {
|
|
28
|
+
super(handle);
|
|
29
|
+
}
|
|
30
|
+
get Bones() {
|
|
31
|
+
if (!this.bones) {
|
|
32
|
+
this.bones = new CommonEntityBoneCollection(this);
|
|
33
|
+
}
|
|
34
|
+
return this.bones;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
CommonVehicle
|
|
39
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { CommonPed } from "./CommonPed";
|
|
4
|
+
import { CommonProp } from "./CommonProp";
|
|
5
|
+
import { CommonVehicle } from "./CommonVehicle";
|
|
6
|
+
function GetEntityClassFromHandle(entityId) {
|
|
7
|
+
switch (GetEntityType(entityId)) {
|
|
8
|
+
case 1: {
|
|
9
|
+
return CommonPed.fromHandle(entityId);
|
|
10
|
+
}
|
|
11
|
+
case 2: {
|
|
12
|
+
return CommonVehicle.fromHandle(entityId);
|
|
13
|
+
}
|
|
14
|
+
case 3: {
|
|
15
|
+
return CommonProp.fromHandle(entityId);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
__name(GetEntityClassFromHandle, "GetEntityClassFromHandle");
|
|
21
|
+
export {
|
|
22
|
+
GetEntityClassFromHandle
|
|
23
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var VehicleSeat = /* @__PURE__ */ ((VehicleSeat2) => {
|
|
2
|
+
VehicleSeat2[VehicleSeat2["AnyPassenger"] = -2] = "AnyPassenger";
|
|
3
|
+
VehicleSeat2[VehicleSeat2["Driver"] = -1] = "Driver";
|
|
4
|
+
VehicleSeat2[VehicleSeat2["FrontRight"] = 0] = "FrontRight";
|
|
5
|
+
VehicleSeat2[VehicleSeat2["BackLeft"] = 1] = "BackLeft";
|
|
6
|
+
VehicleSeat2[VehicleSeat2["BackRight"] = 2] = "BackRight";
|
|
7
|
+
VehicleSeat2[VehicleSeat2["ExtraLeft1"] = 3] = "ExtraLeft1";
|
|
8
|
+
VehicleSeat2[VehicleSeat2["ExtraRight1"] = 4] = "ExtraRight1";
|
|
9
|
+
VehicleSeat2[VehicleSeat2["ExtraLeft2"] = 5] = "ExtraLeft2";
|
|
10
|
+
VehicleSeat2[VehicleSeat2["ExtraRight2"] = 6] = "ExtraRight2";
|
|
11
|
+
VehicleSeat2[VehicleSeat2["ExtraLeft3"] = 7] = "ExtraLeft3";
|
|
12
|
+
VehicleSeat2[VehicleSeat2["ExtraRight3"] = 8] = "ExtraRight3";
|
|
13
|
+
return VehicleSeat2;
|
|
14
|
+
})(VehicleSeat || {});
|
|
15
|
+
export {
|
|
16
|
+
VehicleSeat
|
|
17
|
+
};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export * from "./CommonGameConstants";
|
|
2
|
+
export * from "./CommonModel";
|
|
3
|
+
export * from "./CommonTasks";
|
|
4
|
+
export * from "./utils/Animations";
|
|
5
|
+
export * from "./interfaces/Dimension";
|
|
6
|
+
export * from "./enums/VehicleSeat";
|
|
7
|
+
export * from "./entities/CommonBaseEntity";
|
|
8
|
+
export * from "./entities/CommonBaseEntityBone";
|
|
9
|
+
export * from "./entities/CommonBaseEntityBoneCollection";
|
|
10
|
+
export * from "./entities/CommonEntityBone";
|
|
11
|
+
export * from "./entities/CommonEntityBoneCollection";
|
|
12
|
+
export * from "./entities/CommonEntityType";
|
|
13
|
+
export * from "./entities/CommonPed";
|
|
14
|
+
export * from "./entities/CommonPedBone";
|
|
15
|
+
export * from "./entities/CommonPedBoneCollection";
|
|
16
|
+
export * from "./entities/CommonPlayer";
|
|
17
|
+
export * from "./entities/CommonProp";
|
|
18
|
+
export * from "./entities/CommonVehicle";
|
|
19
|
+
export * from "./entities/GetEntityClassIdFromHandle";
|
|
20
|
+
export * from "./definitions/index.d";
|
|
21
|
+
export * from "./definitions/redm.d";
|
|
22
|
+
export * from "./common/Command";
|
|
23
|
+
export * from "./common/Convar";
|
|
24
|
+
export * from "./common/GlobalData";
|
|
25
|
+
export * from "./common/Kvp";
|
|
26
|
+
export * from "./common/Resource";
|
|
27
|
+
export * from "./common/types";
|
|
28
|
+
export * from "./common/utils/ClassTypes";
|
|
29
|
+
export * from "./common/utils/Color";
|
|
30
|
+
export * from "./common/utils/Delay";
|
|
31
|
+
export * from "./common/utils/Maths";
|
|
32
|
+
export * from "./common/utils/Point";
|
|
33
|
+
export * from "./common/utils/PointF";
|
|
34
|
+
export * from "./common/utils/Quaternion";
|
|
35
|
+
export * from "./common/utils/Vector";
|
|
36
|
+
export * from "./common/utils/cleanPlayerName";
|
|
37
|
+
export * from "./common/utils/enumValues";
|
|
38
|
+
export * from "./common/utils/getStringFromUInt8Array";
|
|
39
|
+
export * from "./common/utils/getUInt32FromUint8Array";
|
|
40
|
+
export * from "./common/utils/randomInt";
|
|
41
|
+
export * from "./common/net/NetworkedMap";
|
|
42
|
+
export * from "./common/decors/Events";
|
|
43
|
+
export * from "./cfx/StateBagChangeHandler";
|
|
44
|
+
export * from "./cfx/cfx";
|
package/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export * from "./CommonGameConstants";
|
|
2
|
+
export * from "./CommonModel";
|
|
3
|
+
export * from "./CommonTasks";
|
|
4
|
+
export * from "./utils/Animations";
|
|
5
|
+
export * from "./interfaces/Dimension";
|
|
6
|
+
export * from "./enums/VehicleSeat";
|
|
7
|
+
export * from "./entities/CommonBaseEntity";
|
|
8
|
+
export * from "./entities/CommonBaseEntityBone";
|
|
9
|
+
export * from "./entities/CommonBaseEntityBoneCollection";
|
|
10
|
+
export * from "./entities/CommonEntityBone";
|
|
11
|
+
export * from "./entities/CommonEntityBoneCollection";
|
|
12
|
+
export * from "./entities/CommonEntityType";
|
|
13
|
+
export * from "./entities/CommonPed";
|
|
14
|
+
export * from "./entities/CommonPedBone";
|
|
15
|
+
export * from "./entities/CommonPedBoneCollection";
|
|
16
|
+
export * from "./entities/CommonPlayer";
|
|
17
|
+
export * from "./entities/CommonProp";
|
|
18
|
+
export * from "./entities/CommonVehicle";
|
|
19
|
+
export * from "./entities/GetEntityClassIdFromHandle";
|
|
20
|
+
export * from "./definitions/index.d";
|
|
21
|
+
export * from "./definitions/redm.d";
|
|
22
|
+
export * from "./common/Command";
|
|
23
|
+
export * from "./common/Convar";
|
|
24
|
+
export * from "./common/GlobalData";
|
|
25
|
+
export * from "./common/Kvp";
|
|
26
|
+
export * from "./common/Resource";
|
|
27
|
+
export * from "./common/types";
|
|
28
|
+
export * from "./common/utils/ClassTypes";
|
|
29
|
+
export * from "./common/utils/Color";
|
|
30
|
+
export * from "./common/utils/Delay";
|
|
31
|
+
export * from "./common/utils/Maths";
|
|
32
|
+
export * from "./common/utils/Point";
|
|
33
|
+
export * from "./common/utils/PointF";
|
|
34
|
+
export * from "./common/utils/Quaternion";
|
|
35
|
+
export * from "./common/utils/Vector";
|
|
36
|
+
export * from "./common/utils/cleanPlayerName";
|
|
37
|
+
export * from "./common/utils/enumValues";
|
|
38
|
+
export * from "./common/utils/getStringFromUInt8Array";
|
|
39
|
+
export * from "./common/utils/getUInt32FromUint8Array";
|
|
40
|
+
export * from "./common/utils/randomInt";
|
|
41
|
+
export * from "./common/net/NetworkedMap";
|
|
42
|
+
export * from "./common/decors/Events";
|
|
43
|
+
export * from "./cfx/StateBagChangeHandler";
|
|
44
|
+
export * from "./cfx/cfx";
|
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nativewrappers/common-game",
|
|
3
|
+
"description": "Native wrappers and utilities for use with Common Game.",
|
|
4
|
+
"contributors": [
|
|
5
|
+
"Remco Troost <d0p3t>",
|
|
6
|
+
"Dillon Skaggs <AvarianKnight>",
|
|
7
|
+
"Linden <thelindat>"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"version": "0.0.114",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/nativewrappers/nativewrappers.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/nativewrappers/nativewrappers/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://fivemjs.avarian.dev/",
|
|
20
|
+
"keywords": [
|
|
21
|
+
"fivem",
|
|
22
|
+
"wrapper",
|
|
23
|
+
"javascript",
|
|
24
|
+
"typescript",
|
|
25
|
+
"citizenfx"
|
|
26
|
+
],
|
|
27
|
+
"files": [
|
|
28
|
+
"./**/*.js",
|
|
29
|
+
"./**/*.d.ts"
|
|
30
|
+
],
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./index.js",
|
|
34
|
+
"./*": "./*"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A utility to load an animation dictionary, anything that loads an animation should RemoveAnimDict after its finish being used.
|
|
3
|
+
* @param animDict the animation dictionary to load
|
|
4
|
+
* @param waitTime how long to wait for the dictionary to load
|
|
5
|
+
* @returns {boolean} if the animation successfully loaded
|
|
6
|
+
*/
|
|
7
|
+
export declare const LoadAnimDict: (animDict: string, waitTime?: number) => Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* A utility to load multiple animation dictionary, anything that loads an animation should RemoveAnimDict after its finish being used.
|
|
10
|
+
* @param animDict the animation dictionary to load
|
|
11
|
+
* @param waitTime how long to wait for the dictionary to load
|
|
12
|
+
* @returns if the animation successfully loaded, if the animation failed to load it will return an array of animations that failed to load
|
|
13
|
+
*/
|
|
14
|
+
export declare const LoadAnimDictArray: (animDict: string[], waitTime?: number) => Promise<[boolean, string[] | null]>;
|
|
15
|
+
/**
|
|
16
|
+
* A utility to unload multiple animation dictionary
|
|
17
|
+
* @param animDict the animation dictionaries to unload
|
|
18
|
+
*/
|
|
19
|
+
export declare const RemoveAnimDictArray: (animDict: string[]) => void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { Delay } from "../common/utils/Delay";
|
|
4
|
+
const LoadAnimDict = /* @__PURE__ */ __name(async (animDict, waitTime = 1e3) => {
|
|
5
|
+
const start = GetGameTimer();
|
|
6
|
+
if (!HasAnimDictLoaded(animDict)) {
|
|
7
|
+
RequestAnimDict(animDict);
|
|
8
|
+
}
|
|
9
|
+
while (!HasAnimDictLoaded(animDict)) {
|
|
10
|
+
if (GetGameTimer() - start >= waitTime) return false;
|
|
11
|
+
await Delay(0);
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
}, "LoadAnimDict");
|
|
15
|
+
const LoadAnimDictArray = /* @__PURE__ */ __name(async (animDict, waitTime = 1e3) => {
|
|
16
|
+
const start = GetGameTimer();
|
|
17
|
+
for (const dict of animDict) {
|
|
18
|
+
if (!HasAnimDictLoaded(dict)) {
|
|
19
|
+
RequestAnimDict(dict);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const animsLoaded = /* @__PURE__ */ new Set();
|
|
23
|
+
while (animsLoaded.size !== animDict.length) {
|
|
24
|
+
for (const dict of animDict) {
|
|
25
|
+
if (!animsLoaded.has(dict) && HasAnimDictLoaded(dict)) {
|
|
26
|
+
animsLoaded.add(dict);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (GetGameTimer() - start >= waitTime) return [false, animDict.filter((dict) => !animsLoaded.has(dict))];
|
|
30
|
+
await Delay(0);
|
|
31
|
+
}
|
|
32
|
+
return [true, null];
|
|
33
|
+
}, "LoadAnimDictArray");
|
|
34
|
+
const RemoveAnimDictArray = /* @__PURE__ */ __name((animDict) => {
|
|
35
|
+
for (const dict of animDict) {
|
|
36
|
+
RemoveAnimDict(dict);
|
|
37
|
+
}
|
|
38
|
+
}, "RemoveAnimDictArray");
|
|
39
|
+
export {
|
|
40
|
+
LoadAnimDict,
|
|
41
|
+
LoadAnimDictArray,
|
|
42
|
+
RemoveAnimDictArray
|
|
43
|
+
};
|