@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.
Files changed (90) hide show
  1. package/CommonGameConstants.d.ts +7 -0
  2. package/CommonGameConstants.js +24 -0
  3. package/CommonModel.d.ts +99 -0
  4. package/CommonModel.js +172 -0
  5. package/CommonTasks.d.ts +43 -0
  6. package/CommonTasks.js +232 -0
  7. package/README.md +45 -0
  8. package/cfx/StateBagChangeHandler.d.ts +1 -0
  9. package/cfx/StateBagChangeHandler.js +0 -0
  10. package/cfx/cfx.d.ts +6 -0
  11. package/cfx/cfx.js +4 -0
  12. package/common/Command.d.ts +77 -0
  13. package/common/Command.js +152 -0
  14. package/common/Convar.d.ts +13 -0
  15. package/common/Convar.js +58 -0
  16. package/common/GlobalData.d.ts +10 -0
  17. package/common/GlobalData.js +18 -0
  18. package/common/Kvp.d.ts +69 -0
  19. package/common/Kvp.js +137 -0
  20. package/common/Resource.d.ts +14 -0
  21. package/common/Resource.js +54 -0
  22. package/common/decors/Events.d.ts +65 -0
  23. package/common/decors/Events.js +208 -0
  24. package/common/net/NetworkedMap.d.ts +28 -0
  25. package/common/net/NetworkedMap.js +225 -0
  26. package/common/types.d.ts +5 -0
  27. package/common/types.js +0 -0
  28. package/common/utils/ClassTypes.d.ts +11 -0
  29. package/common/utils/ClassTypes.js +15 -0
  30. package/common/utils/Color.d.ts +14 -0
  31. package/common/utils/Color.js +33 -0
  32. package/common/utils/Delay.d.ts +1 -0
  33. package/common/utils/Delay.js +6 -0
  34. package/common/utils/Maths.d.ts +4 -0
  35. package/common/utils/Maths.js +18 -0
  36. package/common/utils/Point.d.ts +9 -0
  37. package/common/utils/Point.js +36 -0
  38. package/common/utils/PointF.d.ts +7 -0
  39. package/common/utils/PointF.js +18 -0
  40. package/common/utils/Quaternion.d.ts +10 -0
  41. package/common/utils/Quaternion.js +33 -0
  42. package/common/utils/Vector.d.ts +429 -0
  43. package/common/utils/Vector.js +589 -0
  44. package/common/utils/cleanPlayerName.d.ts +6 -0
  45. package/common/utils/cleanPlayerName.js +17 -0
  46. package/common/utils/enumValues.d.ts +12 -0
  47. package/common/utils/enumValues.js +20 -0
  48. package/common/utils/getStringFromUInt8Array.d.ts +8 -0
  49. package/common/utils/getStringFromUInt8Array.js +6 -0
  50. package/common/utils/getUInt32FromUint8Array.d.ts +8 -0
  51. package/common/utils/getUInt32FromUint8Array.js +6 -0
  52. package/common/utils/randomInt.d.ts +1 -0
  53. package/common/utils/randomInt.js +9 -0
  54. package/definitions/index.d.js +0 -0
  55. package/definitions/redm.d.js +0 -0
  56. package/entities/CommonBaseEntity.d.ts +66 -0
  57. package/entities/CommonBaseEntity.js +180 -0
  58. package/entities/CommonBaseEntityBone.d.ts +11 -0
  59. package/entities/CommonBaseEntityBone.js +32 -0
  60. package/entities/CommonBaseEntityBoneCollection.d.ts +9 -0
  61. package/entities/CommonBaseEntityBoneCollection.js +17 -0
  62. package/entities/CommonEntityBone.d.ts +5 -0
  63. package/entities/CommonEntityBone.js +14 -0
  64. package/entities/CommonEntityBoneCollection.d.ts +9 -0
  65. package/entities/CommonEntityBoneCollection.js +24 -0
  66. package/entities/CommonEntityType.d.ts +4 -0
  67. package/entities/CommonEntityType.js +3 -0
  68. package/entities/CommonPed.d.ts +17 -0
  69. package/entities/CommonPed.js +55 -0
  70. package/entities/CommonPedBone.d.ts +6 -0
  71. package/entities/CommonPedBone.js +17 -0
  72. package/entities/CommonPedBoneCollection.d.ts +10 -0
  73. package/entities/CommonPedBoneCollection.js +31 -0
  74. package/entities/CommonPlayer.d.ts +61 -0
  75. package/entities/CommonPlayer.js +156 -0
  76. package/entities/CommonProp.d.ts +16 -0
  77. package/entities/CommonProp.js +46 -0
  78. package/entities/CommonVehicle.d.ts +12 -0
  79. package/entities/CommonVehicle.js +39 -0
  80. package/entities/GetEntityClassIdFromHandle.d.ts +2 -0
  81. package/entities/GetEntityClassIdFromHandle.js +23 -0
  82. package/enums/VehicleSeat.d.ts +13 -0
  83. package/enums/VehicleSeat.js +17 -0
  84. package/index.d.ts +44 -0
  85. package/index.js +44 -0
  86. package/interfaces/Dimension.d.ts +5 -0
  87. package/interfaces/Dimension.js +0 -0
  88. package/package.json +36 -0
  89. package/utils/Animations.d.ts +19 -0
  90. package/utils/Animations.js +43 -0
@@ -0,0 +1,7 @@
1
+ import { CommonPlayer } from "./entities/CommonPlayer";
2
+ export declare class GameConstants {
3
+ private static player;
4
+ static readonly PlayerId: number;
5
+ static readonly ServerId: number;
6
+ static get Player(): CommonPlayer;
7
+ }
@@ -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
+ }
package/CommonModel.js ADDED
@@ -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,43 @@
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
+ export declare class CommonTasks {
7
+ private ped;
8
+ constructor(ped: CommonPed | null);
9
+ achieveHeading(heading: number, timeout?: number): void;
10
+ blockTemporaryEvents(block?: boolean): void;
11
+ aimAt(target: CommonBaseEntity | Vector3, duration: number): void;
12
+ arrest(ped: CommonPed): void;
13
+ jump(): void;
14
+ climb(): void;
15
+ cruiseWithVehicle(vehicle: CommonVehicle, speed: number, drivingStyle?: number): void;
16
+ enterAnyVehicle(seat?: VehicleSeat, timeout?: number, speed?: number, flag?: number): void;
17
+ static everyoneLeaveVehicle(vehicle: CommonVehicle): void;
18
+ fightAgainst(target: CommonPed, duration?: number): void;
19
+ fightAgainstHatedTargets(radius: number, duration?: number): void;
20
+ fleeFrom(pedOrPosition: CommonPed | Vector3, distance?: number, duration?: number, fleeType?: number, fleeSpeed?: number, fleeFrom?: CommonPed): void;
21
+ goTo(position: Vector3, ignorePaths?: boolean, timeout?: number, speed?: number, targetHeading?: number, distanceToSlide?: number, flags?: number): void;
22
+ goToEntity(target: CommonBaseEntity, offset?: Vector3, timeout?: number): void;
23
+ guardCurrentPosition(): void;
24
+ handsUp(duration: number): void;
25
+ lookAt(targetOrPosition: CommonBaseEntity | Vector3, duration?: number): void;
26
+ playAnimation(animDict: string, animName: string, blendInSpeed: number, blendOutSpeed: number, duration: number, playbackRate: number, animFlags: number, ikFlags?: number): Promise<void>;
27
+ reloadWeapon(): void;
28
+ shootAt(targetOrPosition: CommonPed | Vector3, duration?: number, pattern?: number, affectCockedState?: boolean): void;
29
+ shuffleToNextVehicleSeat(vehicle: CommonVehicle): void;
30
+ slideTo(position: Vector3, heading: number, duration?: number): void;
31
+ standStill(duration: number): void;
32
+ vehicleShootAtPed(target: CommonPed): void;
33
+ wait(duration: number): void;
34
+ wanderAround(position?: Vector3, radius?: number): void;
35
+ warpIntoVehicle(vehicle: CommonVehicle, seat: VehicleSeat): void;
36
+ warpOutOfVehicle(vehicle: CommonVehicle, flags: number): void;
37
+ isPlayingAnim(dict: string, anim: string, taskFlag?: number): boolean;
38
+ clearAll(): void;
39
+ clearAllImmediately(): void;
40
+ clearLookAt(): void;
41
+ clearSecondary(): void;
42
+ clearAnimation(animDict: string, animName: string): void;
43
+ }
package/CommonTasks.js ADDED
@@ -0,0 +1,232 @@
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
+ class CommonTasks {
10
+ static {
11
+ __name(this, "CommonTasks");
12
+ }
13
+ ped;
14
+ // we take null because sequences have a null ped, if you pass null to this
15
+ // you better now what you're doing.
16
+ constructor(ped) {
17
+ const actualPed = ped ?? { handle: null };
18
+ this.ped = actualPed;
19
+ }
20
+ achieveHeading(heading, timeout = 0) {
21
+ TaskAchieveHeading(this.ped.Handle, heading, timeout);
22
+ }
23
+ blockTemporaryEvents(block = true) {
24
+ TaskSetBlockingOfNonTemporaryEvents(this.ped.Handle, block);
25
+ }
26
+ aimAt(target, duration) {
27
+ if (target instanceof CommonBaseEntity)
28
+ TaskAimGunAtEntity(this.ped.Handle, target.Handle, duration, false, false);
29
+ else TaskAimGunAtCoord(this.ped.Handle, target.x, target.y, target.z, duration, false, false);
30
+ }
31
+ arrest(ped) {
32
+ TaskArrestPed(this.ped.Handle, ped.Handle);
33
+ }
34
+ jump() {
35
+ TaskJump(this.ped.Handle, true);
36
+ }
37
+ climb() {
38
+ TaskClimb(this.ped.Handle, true);
39
+ }
40
+ cruiseWithVehicle(vehicle, speed, drivingStyle = 0) {
41
+ TaskVehicleDriveWander(this.ped.Handle, vehicle.Handle, speed, drivingStyle);
42
+ }
43
+ enterAnyVehicle(seat = VehicleSeat.AnyPassenger, timeout = -1, speed = 0, flag = 0) {
44
+ TaskEnterVehicle(this.ped.Handle, 0, timeout, seat, speed, flag, 0);
45
+ }
46
+ static everyoneLeaveVehicle(vehicle) {
47
+ TaskEveryoneLeaveVehicle(vehicle.Handle, 0);
48
+ }
49
+ fightAgainst(target, duration) {
50
+ if (duration) {
51
+ TaskCombatPedTimed(this.ped.Handle, target.Handle, duration, 0);
52
+ } else {
53
+ TaskCombatPed(this.ped.Handle, target.Handle, 0, 16);
54
+ }
55
+ }
56
+ fightAgainstHatedTargets(radius, duration) {
57
+ if (duration) {
58
+ TaskCombatHatedTargetsAroundPedTimed(this.ped.Handle, radius, duration, 0);
59
+ } else {
60
+ TaskCombatHatedTargetsAroundPed(this.ped.Handle, radius, 0, 0);
61
+ }
62
+ }
63
+ fleeFrom(pedOrPosition, distance = 100, duration = -1, fleeType = 0, fleeSpeed = 3, fleeFrom) {
64
+ if (pedOrPosition instanceof CommonPed) {
65
+ TaskSmartFleePed(
66
+ this.ped.Handle,
67
+ pedOrPosition.Handle,
68
+ distance,
69
+ duration,
70
+ fleeType,
71
+ fleeSpeed,
72
+ fleeFrom ? fleeFrom.Handle : 0
73
+ );
74
+ } else {
75
+ TaskSmartFleeCoord(
76
+ this.ped.Handle,
77
+ pedOrPosition.x,
78
+ pedOrPosition.y,
79
+ pedOrPosition.z,
80
+ distance,
81
+ duration,
82
+ fleeType,
83
+ fleeSpeed
84
+ );
85
+ }
86
+ }
87
+ goTo(position, ignorePaths = false, timeout = -1, speed = 1, targetHeading = 0, distanceToSlide = 0, flags = 0) {
88
+ if (ignorePaths) {
89
+ TaskGoStraightToCoord(
90
+ this.ped.Handle,
91
+ position.x,
92
+ position.y,
93
+ position.z,
94
+ speed,
95
+ timeout,
96
+ targetHeading,
97
+ distanceToSlide,
98
+ 0
99
+ );
100
+ } else {
101
+ TaskFollowNavMeshToCoord(
102
+ this.ped.Handle,
103
+ position.x,
104
+ position.y,
105
+ position.z,
106
+ speed,
107
+ timeout,
108
+ 0,
109
+ flags,
110
+ targetHeading
111
+ );
112
+ }
113
+ }
114
+ goToEntity(target, offset = new Vector3(0), timeout = -1) {
115
+ TaskGotoEntityOffsetXy(this.ped.Handle, target.Handle, timeout, offset.x, offset.y, offset.z, 1, true);
116
+ }
117
+ guardCurrentPosition() {
118
+ TaskGuardCurrentPosition(this.ped.Handle, 15, 10, true);
119
+ }
120
+ handsUp(duration) {
121
+ TaskHandsUp(this.ped.Handle, duration, 0, -1, false);
122
+ }
123
+ lookAt(targetOrPosition, duration = -1) {
124
+ if (targetOrPosition instanceof CommonBaseEntity) {
125
+ TaskLookAtEntity(this.ped.Handle, targetOrPosition.Handle, duration, 2048, 31, 0);
126
+ } else {
127
+ TaskLookAtCoord(this.ped.Handle, targetOrPosition.x, targetOrPosition.y, targetOrPosition.z, duration, 0, 51, 0);
128
+ }
129
+ }
130
+ async playAnimation(animDict, animName, blendInSpeed, blendOutSpeed, duration, playbackRate, animFlags, ikFlags) {
131
+ await LoadAnimDict(animDict);
132
+ if (GlobalData.GameName === "redm") {
133
+ TaskPlayAnim(
134
+ this.ped.Handle,
135
+ animDict,
136
+ animName,
137
+ blendInSpeed,
138
+ blendOutSpeed,
139
+ duration,
140
+ animFlags,
141
+ playbackRate,
142
+ false,
143
+ ikFlags,
144
+ false,
145
+ 0,
146
+ false
147
+ );
148
+ } else {
149
+ TaskPlayAnim(
150
+ this.ped.Handle,
151
+ animDict,
152
+ animName,
153
+ blendInSpeed,
154
+ blendOutSpeed,
155
+ duration,
156
+ animFlags,
157
+ playbackRate,
158
+ false,
159
+ false,
160
+ false
161
+ );
162
+ }
163
+ RemoveAnimDict(animDict);
164
+ }
165
+ reloadWeapon() {
166
+ TaskReloadWeapon(this.ped.Handle, true);
167
+ }
168
+ shootAt(targetOrPosition, duration = -1, pattern = 0, affectCockedState = false) {
169
+ if (targetOrPosition instanceof CommonPed) {
170
+ TaskShootAtEntity(this.ped.Handle, targetOrPosition.Handle, duration, pattern, affectCockedState);
171
+ } else {
172
+ TaskShootAtCoord(
173
+ this.ped.Handle,
174
+ targetOrPosition.x,
175
+ targetOrPosition.y,
176
+ targetOrPosition.z,
177
+ duration,
178
+ pattern,
179
+ 0
180
+ );
181
+ }
182
+ }
183
+ shuffleToNextVehicleSeat(vehicle) {
184
+ TaskShuffleToNextVehicleSeat(this.ped.Handle, vehicle.Handle);
185
+ }
186
+ slideTo(position, heading, duration = 0.7) {
187
+ TaskPedSlideToCoord(this.ped.Handle, position.x, position.y, position.z, heading, duration);
188
+ }
189
+ standStill(duration) {
190
+ TaskStandStill(this.ped.Handle, duration);
191
+ }
192
+ vehicleShootAtPed(target) {
193
+ TaskVehicleShootAtPed(this.ped.Handle, target.Handle, 20);
194
+ }
195
+ wait(duration) {
196
+ TaskPause(this.ped.Handle, duration);
197
+ }
198
+ wanderAround(position, radius) {
199
+ if (position && radius) {
200
+ TaskWanderInArea(this.ped.Handle, position.x, position.y, position.z, radius, 0, 0, 0);
201
+ } else {
202
+ TaskWanderStandard(this.ped.Handle, 0, 0);
203
+ }
204
+ }
205
+ warpIntoVehicle(vehicle, seat) {
206
+ TaskWarpPedIntoVehicle(this.ped.Handle, vehicle.Handle, seat);
207
+ }
208
+ warpOutOfVehicle(vehicle, flags) {
209
+ TaskLeaveVehicle(this.ped.Handle, vehicle.Handle, flags, 0);
210
+ }
211
+ isPlayingAnim(dict, anim, taskFlag = 3) {
212
+ return IsEntityPlayingAnim(this.ped.Handle, dict, anim, taskFlag);
213
+ }
214
+ clearAll() {
215
+ ClearPedTasks(this.ped.Handle, true, false);
216
+ }
217
+ clearAllImmediately() {
218
+ ClearPedTasksImmediately(this.ped.Handle, true, false);
219
+ }
220
+ clearLookAt() {
221
+ TaskClearLookAt(this.ped.Handle);
222
+ }
223
+ clearSecondary() {
224
+ ClearPedSecondaryTask(this.ped.Handle);
225
+ }
226
+ clearAnimation(animDict, animName) {
227
+ StopAnimTask(this.ped.Handle, animDict, animName, -4);
228
+ }
229
+ }
230
+ export {
231
+ CommonTasks
232
+ };
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ <h1 align="center">Monorepo for a FiveM server/client wrapper</h1>
2
+
3
+ <p align="center">
4
+ <i>🔥 A Javascript/Typescript package for FiveM resource development 🎮</i>
5
+ <br>
6
+ <small>This project is in no way affiliated with FiveM or the Cfx.re Collective.</small>
7
+ </br></br>
8
+ <a href="https://github.com/nativewrappers/nativewrappers/blob/master/LICENSE">
9
+ <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat" alt="License: MIT">
10
+ </a>
11
+ <a href="https://www.npmjs.com/package/@nativewrappers/fivem">
12
+ <img src="https://img.shields.io/npm/v/@nativewrappers/fivem?style=flat" alt="npm version">
13
+ </a>
14
+ <a href="https://www.npmjs.com/package/@nativewrappers/fivem">
15
+ <img src="https://img.shields.io/npm/dm/@nativewrappers/fivem?style=flat">
16
+ </a>
17
+ <a href="https://github.com/nativewrappers/nativewrappers/actions/workflows/config.yml">
18
+ <img src="https://github.com/nativewrappers/nativewrappers/actions/workflows/config.yml/badge.svg" alt="Workflow Status">
19
+ </a>
20
+ <a href="https://github.com/nativewrappers/nativewrappers/commits/master">
21
+ <img src="https://img.shields.io/github/last-commit/nativewrappers/fivem.svg?style=flat" alt="Last commit">
22
+ </a>
23
+ </p>
24
+
25
+ <h3 align="center">This project is currently iterating rapidly, there will be breaking changes.</h3>
26
+
27
+ <p align="center">
28
+ <h2 align="center"><a href="https://github.com/nativewrappers/nativewrappers/tree/main/docs">Documentation</a></h2>
29
+ <!-- <a href="https://forum.fivem.net/t/fivem-js-v1-3-2-javascript-typescript-wrapper-now-with-menu-class-nativeui/268640">Forum</a> -->
30
+ </p>
31
+
32
+ ## Features
33
+
34
+ - No runtime dependencies
35
+ - Entity management through class objects (i.e. `Vehicle` and `Ped` entities)
36
+ - Server and Client side variants on wrapper
37
+
38
+
39
+ ## Download & Install
40
+ ```
41
+ pnpm add @nativewrappers/redm # for redm,
42
+ pnpm add @nativewrappers/fivem # for fivem
43
+ pnpm add @nativewrappers/common # for any, should be game agnostic, provides Vector3, decors, kvps, helper functions, etc
44
+ pnpm add @nativewrappers/server # for server
45
+ ```
@@ -0,0 +1 @@
1
+ export type StateBagChangeHandler<T> = (bagName: string, key: string, value: T, reserved: number, replicated: boolean) => void;
File without changes
package/cfx/cfx.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export type { StateBagChangeHandler } from "./StateBagChangeHandler";
2
+ declare const _default: {
3
+ Entity: typeof Entity;
4
+ Player: typeof Player;
5
+ };
6
+ export default _default;
package/cfx/cfx.js ADDED
@@ -0,0 +1,4 @@
1
+ var cfx_default = { Entity, Player };
2
+ export {
3
+ cfx_default as default
4
+ };