@nativewrappers/common 0.0.125 → 0.0.127
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/common-game/CommonGameConstants.d.ts +7 -0
- package/common-game/CommonGameConstants.js +24 -0
- package/common-game/CommonModel.d.ts +99 -0
- package/common-game/CommonModel.js +172 -0
- package/common-game/CommonTasks.d.ts +44 -0
- package/common-game/CommonTasks.js +233 -0
- package/common-game/cfx/StateBagChangeHandler.d.ts +1 -0
- package/common-game/cfx/StateBagChangeHandler.js +0 -0
- package/common-game/cfx/cfx.d.ts +6 -0
- package/common-game/cfx/cfx.js +4 -0
- package/common-game/common/Command.d.ts +77 -0
- package/common-game/common/Command.js +152 -0
- package/common-game/common/Convar.d.ts +13 -0
- package/common-game/common/Convar.js +58 -0
- package/common-game/common/GlobalData.d.ts +12 -0
- package/common-game/common/GlobalData.js +20 -0
- package/common-game/common/Kvp.d.ts +69 -0
- package/common-game/common/Kvp.js +137 -0
- package/common-game/common/Resource.d.ts +14 -0
- package/common-game/common/Resource.js +54 -0
- package/common-game/common/decors/ConVar.d.ts +14 -0
- package/common-game/common/decors/ConVar.js +70 -0
- package/common-game/common/decors/Events.d.ts +66 -0
- package/common-game/common/decors/Events.js +163 -0
- package/common-game/common/decors/Exports.d.ts +1 -0
- package/common-game/common/decors/Exports.js +53 -0
- package/common-game/common/decors/Permissions.d.ts +3 -0
- package/common-game/common/decors/Permissions.js +49 -0
- package/common-game/common/decors/Resources.d.ts +8 -0
- package/common-game/common/decors/Resources.js +94 -0
- package/common-game/common/decors/Ticks.d.ts +9 -0
- package/common-game/common/decors/Ticks.js +32 -0
- package/common-game/common/net/NetworkedMap.d.ts +28 -0
- package/common-game/common/net/NetworkedMap.js +225 -0
- package/common-game/common/types.d.ts +5 -0
- package/common-game/common/types.js +0 -0
- package/common-game/common/utils/ClassTypes.d.ts +11 -0
- package/common-game/common/utils/ClassTypes.js +15 -0
- package/common-game/common/utils/Color.d.ts +14 -0
- package/common-game/common/utils/Color.js +33 -0
- package/common-game/common/utils/Delay.d.ts +1 -0
- package/common-game/common/utils/Delay.js +6 -0
- package/common-game/common/utils/Maths.d.ts +4 -0
- package/common-game/common/utils/Maths.js +18 -0
- package/common-game/common/utils/Point.d.ts +9 -0
- package/common-game/common/utils/Point.js +36 -0
- package/common-game/common/utils/PointF.d.ts +7 -0
- package/common-game/common/utils/PointF.js +18 -0
- package/common-game/common/utils/Quaternion.d.ts +10 -0
- package/common-game/common/utils/Quaternion.js +33 -0
- package/common-game/common/utils/Vector.d.ts +429 -0
- package/common-game/common/utils/Vector.js +589 -0
- package/common-game/common/utils/cleanPlayerName.d.ts +6 -0
- package/common-game/common/utils/cleanPlayerName.js +17 -0
- package/common-game/common/utils/enumValues.d.ts +12 -0
- package/common-game/common/utils/enumValues.js +20 -0
- package/common-game/common/utils/getStringFromUInt8Array.d.ts +8 -0
- package/common-game/common/utils/getStringFromUInt8Array.js +6 -0
- package/common-game/common/utils/getUInt32FromUint8Array.d.ts +8 -0
- package/common-game/common/utils/getUInt32FromUint8Array.js +6 -0
- package/common-game/common/utils/randomInt.d.ts +1 -0
- package/common-game/common/utils/randomInt.js +9 -0
- package/common-game/definitions/index.d.js +0 -0
- package/common-game/definitions/redm.d.js +0 -0
- package/common-game/entities/CommonBaseEntity.d.ts +116 -0
- package/common-game/entities/CommonBaseEntity.js +266 -0
- package/common-game/entities/CommonBaseEntityBone.d.ts +11 -0
- package/common-game/entities/CommonBaseEntityBone.js +32 -0
- package/common-game/entities/CommonBaseEntityBoneCollection.d.ts +9 -0
- package/common-game/entities/CommonBaseEntityBoneCollection.js +17 -0
- package/common-game/entities/CommonEntityBone.d.ts +5 -0
- package/common-game/entities/CommonEntityBone.js +14 -0
- package/common-game/entities/CommonEntityBoneCollection.d.ts +9 -0
- package/common-game/entities/CommonEntityBoneCollection.js +24 -0
- package/common-game/entities/CommonEntityType.d.ts +4 -0
- package/common-game/entities/CommonEntityType.js +0 -0
- package/common-game/entities/CommonPed.d.ts +16 -0
- package/common-game/entities/CommonPed.js +52 -0
- package/common-game/entities/CommonPedBone.d.ts +6 -0
- package/common-game/entities/CommonPedBone.js +17 -0
- package/common-game/entities/CommonPedBoneCollection.d.ts +10 -0
- package/common-game/entities/CommonPedBoneCollection.js +31 -0
- package/common-game/entities/CommonPlayer.d.ts +61 -0
- package/common-game/entities/CommonPlayer.js +156 -0
- package/common-game/entities/CommonProp.d.ts +15 -0
- package/common-game/entities/CommonProp.js +43 -0
- package/common-game/entities/CommonVehicle.d.ts +11 -0
- package/common-game/entities/CommonVehicle.js +36 -0
- package/common-game/entities/GetEntityClassIdFromHandle.d.ts +2 -0
- package/common-game/entities/GetEntityClassIdFromHandle.js +23 -0
- package/common-game/entities/IHandle.d.ts +6 -0
- package/common-game/entities/IHandle.js +20 -0
- package/common-game/enums/VehicleSeat.d.ts +13 -0
- package/common-game/enums/VehicleSeat.js +17 -0
- package/common-game/index.d.ts +50 -0
- package/common-game/index.js +50 -0
- package/common-game/interfaces/Dimension.d.ts +5 -0
- package/common-game/interfaces/Dimension.js +0 -0
- package/common-game/utils/Animations.d.ts +19 -0
- package/common-game/utils/Animations.js +43 -0
- package/index.d.ts +52 -1
- package/index.js +52 -1
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { CommonPlayer } from "./entities/CommonPlayer";
|
|
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 CommonPlayer(GameConstants.PlayerId);
|
|
18
|
+
}
|
|
19
|
+
return GameConstants.player;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
GameConstants
|
|
24
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Dimensions } from "./interfaces/Dimension";
|
|
2
|
+
export declare class CommonModel implements Disposable {
|
|
3
|
+
/**
|
|
4
|
+
* Hash of this model.
|
|
5
|
+
*/
|
|
6
|
+
protected hash: number;
|
|
7
|
+
protected requestCount: number;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the amount of times this model has been requested from the client, useful for finding situations where the client fails to release the ref
|
|
10
|
+
*/
|
|
11
|
+
get RequestCount(): number;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a model object based on the hash key or model string.
|
|
14
|
+
*
|
|
15
|
+
* @param hash A number or string of the model's hash. Example: "mp_m_freemode_01"
|
|
16
|
+
*/
|
|
17
|
+
constructor(hash: number | string);
|
|
18
|
+
[Symbol.dispose](): void;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the hash of the model.
|
|
21
|
+
*
|
|
22
|
+
* @returns The hash key.
|
|
23
|
+
*/
|
|
24
|
+
get Hash(): number;
|
|
25
|
+
/**
|
|
26
|
+
* Gets if the model is valid or not.
|
|
27
|
+
*
|
|
28
|
+
* @returns Whether this model is valid.
|
|
29
|
+
*/
|
|
30
|
+
get IsValid(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Gets if the model is in cd image or not.
|
|
33
|
+
*
|
|
34
|
+
* @returns Whether this model is in cd image.
|
|
35
|
+
*/
|
|
36
|
+
get IsInCdImage(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Gets if the model is loaded or not.
|
|
39
|
+
*
|
|
40
|
+
* @returns Whether this model is loaded.
|
|
41
|
+
*/
|
|
42
|
+
get IsLoaded(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Gets if the model collision is loaded or not.
|
|
45
|
+
*
|
|
46
|
+
* @returns Whether this model collision is loaded.
|
|
47
|
+
*/
|
|
48
|
+
get IsCollisionLoaded(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Gets if the model is a boat or not.
|
|
51
|
+
*
|
|
52
|
+
* @returns Whether this model is a boat.
|
|
53
|
+
*/
|
|
54
|
+
get IsBoat(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Gets if the model is a Ped or not.
|
|
57
|
+
*
|
|
58
|
+
* @returns Whether this model is a Ped.
|
|
59
|
+
*/
|
|
60
|
+
get IsPed(): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Gets if the model is a prop or not.
|
|
63
|
+
*
|
|
64
|
+
* @returns Whether this model is a prop.
|
|
65
|
+
*/
|
|
66
|
+
get IsProp(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Gets if the model is a train or not.
|
|
69
|
+
*
|
|
70
|
+
* @returns Whether this model is a train.
|
|
71
|
+
*/
|
|
72
|
+
get IsTrain(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Gets if the model is a Vehicle or not.
|
|
75
|
+
*
|
|
76
|
+
* @returns Whether this model is a Vehicle.
|
|
77
|
+
*/
|
|
78
|
+
get IsVehicle(): boolean;
|
|
79
|
+
get IsWeapon(): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Gets the model dimensions.
|
|
82
|
+
*
|
|
83
|
+
* @returns This model min & max dimensions.
|
|
84
|
+
*/
|
|
85
|
+
get Dimensions(): Dimensions;
|
|
86
|
+
requestModel(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Request and load the model with a specified timeout. Default timeout is 1000 (recommended).
|
|
89
|
+
* This function will not automatically set the model as no longer needed when
|
|
90
|
+
* done.
|
|
91
|
+
*
|
|
92
|
+
* @param timeoutMs Maximum allowed time for model to load.
|
|
93
|
+
*/
|
|
94
|
+
request(timeoutMs?: number): Promise<boolean>;
|
|
95
|
+
/**
|
|
96
|
+
* Sets the model as no longer needed allowing the game engine to free memory.
|
|
97
|
+
*/
|
|
98
|
+
markAsNoLongerNeeded(): void;
|
|
99
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { Delay } from "./common/utils/Delay";
|
|
4
|
+
import { Vector3 } from "./common/utils/Vector";
|
|
5
|
+
class CommonModel {
|
|
6
|
+
static {
|
|
7
|
+
__name(this, "CommonModel");
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Hash of this model.
|
|
11
|
+
*/
|
|
12
|
+
hash;
|
|
13
|
+
requestCount = 0;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the amount of times this model has been requested from the client, useful for finding situations where the client fails to release the ref
|
|
16
|
+
*/
|
|
17
|
+
get RequestCount() {
|
|
18
|
+
return this.requestCount;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a model object based on the hash key or model string.
|
|
22
|
+
*
|
|
23
|
+
* @param hash A number or string of the model's hash. Example: "mp_m_freemode_01"
|
|
24
|
+
*/
|
|
25
|
+
constructor(hash) {
|
|
26
|
+
if (typeof hash === "string") {
|
|
27
|
+
this.hash = GetHashKey(hash);
|
|
28
|
+
} else {
|
|
29
|
+
this.hash = hash;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
[Symbol.dispose]() {
|
|
33
|
+
if (this.requestCount > 0) {
|
|
34
|
+
this.markAsNoLongerNeeded();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Gets the hash of the model.
|
|
39
|
+
*
|
|
40
|
+
* @returns The hash key.
|
|
41
|
+
*/
|
|
42
|
+
get Hash() {
|
|
43
|
+
return this.hash;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets if the model is valid or not.
|
|
47
|
+
*
|
|
48
|
+
* @returns Whether this model is valid.
|
|
49
|
+
*/
|
|
50
|
+
get IsValid() {
|
|
51
|
+
return IsModelValid(this.hash);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Gets if the model is in cd image or not.
|
|
55
|
+
*
|
|
56
|
+
* @returns Whether this model is in cd image.
|
|
57
|
+
*/
|
|
58
|
+
get IsInCdImage() {
|
|
59
|
+
return IsModelInCdimage(this.hash);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Gets if the model is loaded or not.
|
|
63
|
+
*
|
|
64
|
+
* @returns Whether this model is loaded.
|
|
65
|
+
*/
|
|
66
|
+
get IsLoaded() {
|
|
67
|
+
if (this.IsWeapon) {
|
|
68
|
+
return Citizen.invokeNative("0xFF07CF465F48B830", this.hash);
|
|
69
|
+
}
|
|
70
|
+
return HasModelLoaded(this.hash);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Gets if the model collision is loaded or not.
|
|
74
|
+
*
|
|
75
|
+
* @returns Whether this model collision is loaded.
|
|
76
|
+
*/
|
|
77
|
+
get IsCollisionLoaded() {
|
|
78
|
+
return HasCollisionForModelLoaded(this.hash);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Gets if the model is a boat or not.
|
|
82
|
+
*
|
|
83
|
+
* @returns Whether this model is a boat.
|
|
84
|
+
*/
|
|
85
|
+
get IsBoat() {
|
|
86
|
+
return IsThisModelABoat(this.hash);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Gets if the model is a Ped or not.
|
|
90
|
+
*
|
|
91
|
+
* @returns Whether this model is a Ped.
|
|
92
|
+
*/
|
|
93
|
+
get IsPed() {
|
|
94
|
+
return IsModelAPed(this.hash);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets if the model is a prop or not.
|
|
98
|
+
*
|
|
99
|
+
* @returns Whether this model is a prop.
|
|
100
|
+
*/
|
|
101
|
+
get IsProp() {
|
|
102
|
+
return this.IsValid && !this.IsPed && !this.IsVehicle && !this.IsWeapon;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Gets if the model is a train or not.
|
|
106
|
+
*
|
|
107
|
+
* @returns Whether this model is a train.
|
|
108
|
+
*/
|
|
109
|
+
get IsTrain() {
|
|
110
|
+
return IsThisModelATrain(this.hash);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Gets if the model is a Vehicle or not.
|
|
114
|
+
*
|
|
115
|
+
* @returns Whether this model is a Vehicle.
|
|
116
|
+
*/
|
|
117
|
+
get IsVehicle() {
|
|
118
|
+
return IsModelAVehicle(this.hash);
|
|
119
|
+
}
|
|
120
|
+
get IsWeapon() {
|
|
121
|
+
return IsWeaponValid(this.hash);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Gets the model dimensions.
|
|
125
|
+
*
|
|
126
|
+
* @returns This model min & max dimensions.
|
|
127
|
+
*/
|
|
128
|
+
get Dimensions() {
|
|
129
|
+
const [minArray, maxArray] = GetModelDimensions(this.hash);
|
|
130
|
+
const min = Vector3.fromArray(minArray);
|
|
131
|
+
const max = Vector3.fromArray(maxArray);
|
|
132
|
+
return { min, max };
|
|
133
|
+
}
|
|
134
|
+
// TODO: Metaped stuff too at some point
|
|
135
|
+
requestModel() {
|
|
136
|
+
RequestModel(this.hash, false);
|
|
137
|
+
this.requestCount++;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Request and load the model with a specified timeout. Default timeout is 1000 (recommended).
|
|
141
|
+
* This function will not automatically set the model as no longer needed when
|
|
142
|
+
* done.
|
|
143
|
+
*
|
|
144
|
+
* @param timeoutMs Maximum allowed time for model to load.
|
|
145
|
+
*/
|
|
146
|
+
async request(timeoutMs = 1e3) {
|
|
147
|
+
if (!this.IsInCdImage && !this.IsValid && !this.IsWeapon) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if (this.IsLoaded) {
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
this.requestModel();
|
|
154
|
+
const timeout = GetGameTimer() + timeoutMs;
|
|
155
|
+
while (!this.IsLoaded && GetGameTimer() < timeout) {
|
|
156
|
+
await Delay(0);
|
|
157
|
+
}
|
|
158
|
+
if (!this.IsLoaded) {
|
|
159
|
+
this.markAsNoLongerNeeded();
|
|
160
|
+
}
|
|
161
|
+
return this.IsLoaded;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Sets the model as no longer needed allowing the game engine to free memory.
|
|
165
|
+
*/
|
|
166
|
+
markAsNoLongerNeeded() {
|
|
167
|
+
SetModelAsNoLongerNeeded(this.hash);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export {
|
|
171
|
+
CommonModel
|
|
172
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Vector3 } from "./common/utils/Vector";
|
|
2
|
+
import { CommonBaseEntity } from "./entities/CommonBaseEntity";
|
|
3
|
+
import { CommonPed } from "./entities/CommonPed";
|
|
4
|
+
import type { CommonVehicle } from "./entities/CommonVehicle";
|
|
5
|
+
import { VehicleSeat } from "./enums/VehicleSeat";
|
|
6
|
+
import { IHandle } from "./entities/IHandle";
|
|
7
|
+
export declare class CommonTasks {
|
|
8
|
+
protected ped: IHandle;
|
|
9
|
+
constructor(ped: IHandle | null);
|
|
10
|
+
achieveHeading(heading: number, timeout?: number): void;
|
|
11
|
+
blockTemporaryEvents(block?: boolean): void;
|
|
12
|
+
aimAt(target: CommonBaseEntity | Vector3, duration: number): void;
|
|
13
|
+
arrest(ped: CommonPed): void;
|
|
14
|
+
jump(): void;
|
|
15
|
+
climb(): void;
|
|
16
|
+
cruiseWithVehicle(vehicle: CommonVehicle, speed: number, drivingStyle?: number): void;
|
|
17
|
+
enterAnyVehicle(seat?: VehicleSeat, timeout?: number, speed?: number, flag?: number): void;
|
|
18
|
+
static everyoneLeaveVehicle(vehicle: CommonVehicle): void;
|
|
19
|
+
fightAgainst(target: CommonPed, duration?: number): void;
|
|
20
|
+
fightAgainstHatedTargets(radius: number, duration?: number): void;
|
|
21
|
+
fleeFrom(pedOrPosition: CommonPed | Vector3, distance?: number, duration?: number, fleeType?: number, fleeSpeed?: number, fleeFrom?: IHandle): void;
|
|
22
|
+
goTo(position: Vector3, ignorePaths?: boolean, timeout?: number, speed?: number, targetHeading?: number, distanceToSlide?: number, flags?: number): void;
|
|
23
|
+
goToEntity(target: CommonBaseEntity, offset?: Vector3, timeout?: number): void;
|
|
24
|
+
guardCurrentPosition(): void;
|
|
25
|
+
handsUp(duration: number): void;
|
|
26
|
+
lookAt(targetOrPosition: CommonBaseEntity | Vector3, duration?: number): void;
|
|
27
|
+
playAnimation(animDict: string, animName: string, blendInSpeed: number, blendOutSpeed: number, duration: number, playbackRate: number, animFlags: number, ikFlags?: number): Promise<void>;
|
|
28
|
+
reloadWeapon(): void;
|
|
29
|
+
shootAt(targetOrPosition: IHandle | Vector3, duration?: number, pattern?: number, affectCockedState?: boolean): void;
|
|
30
|
+
shuffleToNextVehicleSeat(vehicle: CommonVehicle): void;
|
|
31
|
+
slideTo(position: Vector3, heading: number, duration?: number): void;
|
|
32
|
+
standStill(duration: number): void;
|
|
33
|
+
vehicleShootAtPed(target: CommonPed): void;
|
|
34
|
+
wait(duration: number): void;
|
|
35
|
+
wanderAround(position?: Vector3, radius?: number): void;
|
|
36
|
+
warpIntoVehicle(vehicle: CommonVehicle, seat: VehicleSeat): void;
|
|
37
|
+
warpOutOfVehicle(vehicle: CommonVehicle, flags: number): void;
|
|
38
|
+
isPlayingAnim(dict: string, anim: string, taskFlag?: number): boolean;
|
|
39
|
+
clearAll(): void;
|
|
40
|
+
clearAllImmediately(): void;
|
|
41
|
+
clearLookAt(): void;
|
|
42
|
+
clearSecondary(): void;
|
|
43
|
+
clearAnimation(animDict: string, animName: string): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { Vector3 } from "./common/utils/Vector";
|
|
4
|
+
import { CommonBaseEntity } from "./entities/CommonBaseEntity";
|
|
5
|
+
import { CommonPed } from "./entities/CommonPed";
|
|
6
|
+
import { VehicleSeat } from "./enums/VehicleSeat";
|
|
7
|
+
import { LoadAnimDict } from "./utils/Animations";
|
|
8
|
+
import { GlobalData } from "./common/GlobalData";
|
|
9
|
+
import { IHandle } from "./entities/IHandle";
|
|
10
|
+
class CommonTasks {
|
|
11
|
+
static {
|
|
12
|
+
__name(this, "CommonTasks");
|
|
13
|
+
}
|
|
14
|
+
ped;
|
|
15
|
+
// we take null because sequences have a null ped, if you pass null to this
|
|
16
|
+
// you better now what you're doing.
|
|
17
|
+
constructor(ped) {
|
|
18
|
+
const actualPed = ped ?? { handle: null };
|
|
19
|
+
this.ped = actualPed;
|
|
20
|
+
}
|
|
21
|
+
achieveHeading(heading, timeout = 0) {
|
|
22
|
+
TaskAchieveHeading(this.ped.Handle, heading, timeout);
|
|
23
|
+
}
|
|
24
|
+
blockTemporaryEvents(block = true) {
|
|
25
|
+
TaskSetBlockingOfNonTemporaryEvents(this.ped.Handle, block);
|
|
26
|
+
}
|
|
27
|
+
aimAt(target, duration) {
|
|
28
|
+
if (target instanceof CommonBaseEntity)
|
|
29
|
+
TaskAimGunAtEntity(this.ped.Handle, target.Handle, duration, false, false);
|
|
30
|
+
else TaskAimGunAtCoord(this.ped.Handle, target.x, target.y, target.z, duration, false, false);
|
|
31
|
+
}
|
|
32
|
+
arrest(ped) {
|
|
33
|
+
TaskArrestPed(this.ped.Handle, ped.Handle);
|
|
34
|
+
}
|
|
35
|
+
jump() {
|
|
36
|
+
TaskJump(this.ped.Handle, true);
|
|
37
|
+
}
|
|
38
|
+
climb() {
|
|
39
|
+
TaskClimb(this.ped.Handle, true);
|
|
40
|
+
}
|
|
41
|
+
cruiseWithVehicle(vehicle, speed, drivingStyle = 0) {
|
|
42
|
+
TaskVehicleDriveWander(this.ped.Handle, vehicle.Handle, speed, drivingStyle);
|
|
43
|
+
}
|
|
44
|
+
enterAnyVehicle(seat = VehicleSeat.AnyPassenger, timeout = -1, speed = 0, flag = 0) {
|
|
45
|
+
TaskEnterVehicle(this.ped.Handle, 0, timeout, seat, speed, flag, 0);
|
|
46
|
+
}
|
|
47
|
+
static everyoneLeaveVehicle(vehicle) {
|
|
48
|
+
TaskEveryoneLeaveVehicle(vehicle.Handle, 0);
|
|
49
|
+
}
|
|
50
|
+
fightAgainst(target, duration) {
|
|
51
|
+
if (duration) {
|
|
52
|
+
TaskCombatPedTimed(this.ped.Handle, target.Handle, duration, 0);
|
|
53
|
+
} else {
|
|
54
|
+
TaskCombatPed(this.ped.Handle, target.Handle, 0, 16);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
fightAgainstHatedTargets(radius, duration) {
|
|
58
|
+
if (duration) {
|
|
59
|
+
TaskCombatHatedTargetsAroundPedTimed(this.ped.Handle, radius, duration, 0);
|
|
60
|
+
} else {
|
|
61
|
+
TaskCombatHatedTargetsAroundPed(this.ped.Handle, radius, 0, 0);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
fleeFrom(pedOrPosition, distance = 100, duration = -1, fleeType = 0, fleeSpeed = 3, fleeFrom) {
|
|
65
|
+
if (pedOrPosition instanceof CommonPed) {
|
|
66
|
+
TaskSmartFleePed(
|
|
67
|
+
this.ped.Handle,
|
|
68
|
+
pedOrPosition.Handle,
|
|
69
|
+
distance,
|
|
70
|
+
duration,
|
|
71
|
+
fleeType,
|
|
72
|
+
fleeSpeed,
|
|
73
|
+
fleeFrom ? fleeFrom.Handle : 0
|
|
74
|
+
);
|
|
75
|
+
} else {
|
|
76
|
+
TaskSmartFleeCoord(
|
|
77
|
+
this.ped.Handle,
|
|
78
|
+
pedOrPosition.x,
|
|
79
|
+
pedOrPosition.y,
|
|
80
|
+
pedOrPosition.z,
|
|
81
|
+
distance,
|
|
82
|
+
duration,
|
|
83
|
+
fleeType,
|
|
84
|
+
fleeSpeed
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
goTo(position, ignorePaths = false, timeout = -1, speed = 1, targetHeading = 0, distanceToSlide = 0, flags = 0) {
|
|
89
|
+
if (ignorePaths) {
|
|
90
|
+
TaskGoStraightToCoord(
|
|
91
|
+
this.ped.Handle,
|
|
92
|
+
position.x,
|
|
93
|
+
position.y,
|
|
94
|
+
position.z,
|
|
95
|
+
speed,
|
|
96
|
+
timeout,
|
|
97
|
+
targetHeading,
|
|
98
|
+
distanceToSlide,
|
|
99
|
+
0
|
|
100
|
+
);
|
|
101
|
+
} else {
|
|
102
|
+
TaskFollowNavMeshToCoord(
|
|
103
|
+
this.ped.Handle,
|
|
104
|
+
position.x,
|
|
105
|
+
position.y,
|
|
106
|
+
position.z,
|
|
107
|
+
speed,
|
|
108
|
+
timeout,
|
|
109
|
+
0,
|
|
110
|
+
flags,
|
|
111
|
+
targetHeading
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
goToEntity(target, offset = new Vector3(0), timeout = -1) {
|
|
116
|
+
TaskGotoEntityOffsetXy(this.ped.Handle, target.Handle, timeout, offset.x, offset.y, offset.z, 1, true);
|
|
117
|
+
}
|
|
118
|
+
guardCurrentPosition() {
|
|
119
|
+
TaskGuardCurrentPosition(this.ped.Handle, 15, 10, true);
|
|
120
|
+
}
|
|
121
|
+
handsUp(duration) {
|
|
122
|
+
TaskHandsUp(this.ped.Handle, duration, 0, -1, false);
|
|
123
|
+
}
|
|
124
|
+
lookAt(targetOrPosition, duration = -1) {
|
|
125
|
+
if (targetOrPosition instanceof CommonBaseEntity) {
|
|
126
|
+
TaskLookAtEntity(this.ped.Handle, targetOrPosition.Handle, duration, 2048, 31, 0);
|
|
127
|
+
} else {
|
|
128
|
+
TaskLookAtCoord(this.ped.Handle, targetOrPosition.x, targetOrPosition.y, targetOrPosition.z, duration, 0, 51, 0);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async playAnimation(animDict, animName, blendInSpeed, blendOutSpeed, duration, playbackRate, animFlags, ikFlags) {
|
|
132
|
+
await LoadAnimDict(animDict);
|
|
133
|
+
if (GlobalData.GameName === "redm") {
|
|
134
|
+
TaskPlayAnim(
|
|
135
|
+
this.ped.Handle,
|
|
136
|
+
animDict,
|
|
137
|
+
animName,
|
|
138
|
+
blendInSpeed,
|
|
139
|
+
blendOutSpeed,
|
|
140
|
+
duration,
|
|
141
|
+
animFlags,
|
|
142
|
+
playbackRate,
|
|
143
|
+
false,
|
|
144
|
+
ikFlags,
|
|
145
|
+
false,
|
|
146
|
+
0,
|
|
147
|
+
false
|
|
148
|
+
);
|
|
149
|
+
} else {
|
|
150
|
+
TaskPlayAnim(
|
|
151
|
+
this.ped.Handle,
|
|
152
|
+
animDict,
|
|
153
|
+
animName,
|
|
154
|
+
blendInSpeed,
|
|
155
|
+
blendOutSpeed,
|
|
156
|
+
duration,
|
|
157
|
+
animFlags,
|
|
158
|
+
playbackRate,
|
|
159
|
+
false,
|
|
160
|
+
false,
|
|
161
|
+
false
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
RemoveAnimDict(animDict);
|
|
165
|
+
}
|
|
166
|
+
reloadWeapon() {
|
|
167
|
+
TaskReloadWeapon(this.ped.Handle, true);
|
|
168
|
+
}
|
|
169
|
+
shootAt(targetOrPosition, duration = -1, pattern = 0, affectCockedState = false) {
|
|
170
|
+
if (targetOrPosition instanceof IHandle) {
|
|
171
|
+
TaskShootAtEntity(this.ped.Handle, targetOrPosition.Handle, duration, pattern, affectCockedState);
|
|
172
|
+
} else {
|
|
173
|
+
TaskShootAtCoord(
|
|
174
|
+
this.ped.Handle,
|
|
175
|
+
targetOrPosition.x,
|
|
176
|
+
targetOrPosition.y,
|
|
177
|
+
targetOrPosition.z,
|
|
178
|
+
duration,
|
|
179
|
+
pattern,
|
|
180
|
+
0
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
shuffleToNextVehicleSeat(vehicle) {
|
|
185
|
+
TaskShuffleToNextVehicleSeat(this.ped.Handle, vehicle.Handle);
|
|
186
|
+
}
|
|
187
|
+
slideTo(position, heading, duration = 0.7) {
|
|
188
|
+
TaskPedSlideToCoord(this.ped.Handle, position.x, position.y, position.z, heading, duration);
|
|
189
|
+
}
|
|
190
|
+
standStill(duration) {
|
|
191
|
+
TaskStandStill(this.ped.Handle, duration);
|
|
192
|
+
}
|
|
193
|
+
vehicleShootAtPed(target) {
|
|
194
|
+
TaskVehicleShootAtPed(this.ped.Handle, target.Handle, 20);
|
|
195
|
+
}
|
|
196
|
+
wait(duration) {
|
|
197
|
+
TaskPause(this.ped.Handle, duration);
|
|
198
|
+
}
|
|
199
|
+
wanderAround(position, radius) {
|
|
200
|
+
if (position && radius) {
|
|
201
|
+
TaskWanderInArea(this.ped.Handle, position.x, position.y, position.z, radius, 0, 0, 0);
|
|
202
|
+
} else {
|
|
203
|
+
TaskWanderStandard(this.ped.Handle, 0, 0);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
warpIntoVehicle(vehicle, seat) {
|
|
207
|
+
TaskWarpPedIntoVehicle(this.ped.Handle, vehicle.Handle, seat);
|
|
208
|
+
}
|
|
209
|
+
warpOutOfVehicle(vehicle, flags) {
|
|
210
|
+
TaskLeaveVehicle(this.ped.Handle, vehicle.Handle, flags, 0);
|
|
211
|
+
}
|
|
212
|
+
isPlayingAnim(dict, anim, taskFlag = 3) {
|
|
213
|
+
return IsEntityPlayingAnim(this.ped.Handle, dict, anim, taskFlag);
|
|
214
|
+
}
|
|
215
|
+
clearAll() {
|
|
216
|
+
ClearPedTasks(this.ped.Handle, true, false);
|
|
217
|
+
}
|
|
218
|
+
clearAllImmediately() {
|
|
219
|
+
ClearPedTasksImmediately(this.ped.Handle, true, false);
|
|
220
|
+
}
|
|
221
|
+
clearLookAt() {
|
|
222
|
+
TaskClearLookAt(this.ped.Handle);
|
|
223
|
+
}
|
|
224
|
+
clearSecondary() {
|
|
225
|
+
ClearPedSecondaryTask(this.ped.Handle);
|
|
226
|
+
}
|
|
227
|
+
clearAnimation(animDict, animName) {
|
|
228
|
+
StopAnimTask(this.ped.Handle, animDict, animName, -4);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
export {
|
|
232
|
+
CommonTasks
|
|
233
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type StateBagChangeHandler<T> = (bagName: string, key: string, value: T, reserved: number, replicated: boolean) => void;
|
|
File without changes
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
type Restricted = boolean | string | string[];
|
|
2
|
+
interface ParameterTypes {
|
|
3
|
+
number: number;
|
|
4
|
+
playerId: number;
|
|
5
|
+
string: string;
|
|
6
|
+
longString: string;
|
|
7
|
+
}
|
|
8
|
+
interface Parameter {
|
|
9
|
+
name: string;
|
|
10
|
+
type: keyof ParameterTypes;
|
|
11
|
+
defaultValue?: any;
|
|
12
|
+
help?: string;
|
|
13
|
+
optional?: boolean;
|
|
14
|
+
}
|
|
15
|
+
type MappedParameters<T extends Parameter[]> = {
|
|
16
|
+
[K in T[number] as K["name"]]: ParameterTypes[K["type"]];
|
|
17
|
+
} & {
|
|
18
|
+
source: number;
|
|
19
|
+
raw: string;
|
|
20
|
+
};
|
|
21
|
+
type CommandHandler<T extends Parameter[]> = (args: MappedParameters<T>) => void | Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* ```typescript
|
|
24
|
+
* new Command(["do", "deleteobjects"], async ({source, radius}) => {
|
|
25
|
+
* const entities = Prop.AllProps();
|
|
26
|
+
* const ply = new Player(source);
|
|
27
|
+
* const pos = ply.Ped.Position
|
|
28
|
+
* for (const ent of entities) {
|
|
29
|
+
* // if they're outside of the range of our specified radius just continue to next
|
|
30
|
+
* if (ent.Position.distance(pos) > radius) continue;
|
|
31
|
+
* ent.delete();
|
|
32
|
+
* }
|
|
33
|
+
* }, "Deletes all objects in the specified range", [
|
|
34
|
+
* {
|
|
35
|
+
* name: "radius",
|
|
36
|
+
* type: "number",
|
|
37
|
+
* help: "The radius to delete the entities in",
|
|
38
|
+
* defaultValue: 5.0
|
|
39
|
+
* }
|
|
40
|
+
* ] as const, "group.moderator")
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare class Command<T extends Parameter[] = Parameter[]> {
|
|
44
|
+
#private;
|
|
45
|
+
readonly name: string | string[];
|
|
46
|
+
readonly help?: string | undefined;
|
|
47
|
+
readonly params?: T | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Registers a new executable command with optional parameter validation and permission restrictions.
|
|
50
|
+
* @param name The unique identifier(s) for the command, either as a single string or an array of strings.
|
|
51
|
+
* @param handler The function to execute when the command is executed.
|
|
52
|
+
* @param help A description of the command, displayed as a chat suggestion.
|
|
53
|
+
* @param params An optional array of parameter definitions specifying the command's expected arguments,
|
|
54
|
+
* including their names, types, and descriptive help text for chat suggestions.
|
|
55
|
+
* @param restricted Determines the command's access permissions:
|
|
56
|
+
* - Defaults to `true`, restricting usage to users with the "command.commandName" ACE permission.
|
|
57
|
+
* - A string such as `"group.admin"` grants the command permission to the specified principal.
|
|
58
|
+
* - An array of strings grants permission to multiple principals.
|
|
59
|
+
*/
|
|
60
|
+
constructor(name: string | string[], handler: CommandHandler<T>, help?: string | undefined, params?: T | undefined, restricted?: Restricted);
|
|
61
|
+
/**
|
|
62
|
+
* Maps the arguments received from a command call to the defined parameters while validating the argument types.
|
|
63
|
+
* @param source The client that executed the command, or -1 if executed by the server.
|
|
64
|
+
* @param args The arguments passed to the command.
|
|
65
|
+
* @param raw The raw input string passed to the command.
|
|
66
|
+
* @returns A mapped object containing parsed parameters.
|
|
67
|
+
*/
|
|
68
|
+
private mapArguments;
|
|
69
|
+
/**
|
|
70
|
+
* Executes the command with the given arguments and source, validating and mapping the arguments before calling the handler.
|
|
71
|
+
* @param source The client that executed the command.
|
|
72
|
+
* @param args The arguments passed to the command.
|
|
73
|
+
* @param raw The raw input string passed to the command.
|
|
74
|
+
*/
|
|
75
|
+
call(source: number, args: string[], raw?: string): Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
export {};
|