@nativewrappers/fivem 0.0.80 → 0.0.82

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 (265) hide show
  1. package/Audio.d.ts +2 -2
  2. package/Audio.js +99 -0
  3. package/Blip.d.ts +4 -3
  4. package/Blip.js +113 -0
  5. package/Camera.d.ts +3 -3
  6. package/Camera.js +190 -0
  7. package/Checkpoint.d.ts +2 -2
  8. package/Checkpoint.js +51 -0
  9. package/Events.js +80 -0
  10. package/Game.d.ts +10 -3
  11. package/Game.js +478 -0
  12. package/GameplayCamera.d.ts +2 -2
  13. package/GameplayCamera.js +152 -0
  14. package/Model.js +210 -0
  15. package/NetworkedScene.d.ts +2 -1
  16. package/NetworkedScene.js +50 -0
  17. package/ParticleEffect.d.ts +4 -3
  18. package/ParticleEffect.js +128 -0
  19. package/ParticleEffectAsset.d.ts +2 -2
  20. package/ParticleEffectAsset.js +133 -0
  21. package/Pickup.d.ts +1 -1
  22. package/Pickup.js +27 -0
  23. package/Raycast.d.ts +5 -3
  24. package/Raycast.js +132 -0
  25. package/RelationshipGroup.d.ts +1 -1
  26. package/RelationshipGroup.js +72 -0
  27. package/Rope.d.ts +1 -1
  28. package/Rope.js +149 -0
  29. package/TaskSequence.js +52 -0
  30. package/Tasks.d.ts +8 -3
  31. package/Tasks.js +334 -0
  32. package/World.d.ts +13 -4
  33. package/World.js +945 -0
  34. package/cfx/StateBagChangeHandler.js +0 -0
  35. package/cfx/index.d.ts +1 -1
  36. package/cfx/index.js +4 -0
  37. package/common/Command.js +111 -0
  38. package/common/Convar.js +58 -0
  39. package/common/GlobalData.js +16 -0
  40. package/common/Kvp.js +137 -0
  41. package/common/Resource.js +54 -0
  42. package/common/decors/Events.js +170 -0
  43. package/common/net/NetworkedMap.js +225 -0
  44. package/common/types.js +0 -0
  45. package/common/utils/ClassTypes.js +15 -0
  46. package/common/utils/Color.js +33 -0
  47. package/common/utils/Delay.d.ts +1 -0
  48. package/common/utils/Delay.js +6 -0
  49. package/common/utils/Maths.js +18 -0
  50. package/common/utils/Point.d.ts +9 -0
  51. package/common/utils/Point.js +36 -0
  52. package/common/utils/PointF.d.ts +1 -1
  53. package/common/utils/PointF.js +18 -0
  54. package/common/utils/Quaternion.d.ts +1 -1
  55. package/common/utils/Quaternion.js +33 -0
  56. package/common/utils/Vector.js +589 -0
  57. package/common/utils/cleanPlayerName.js +17 -0
  58. package/common/utils/enumValues.js +20 -0
  59. package/common/utils/getStringFromUInt8Array.js +6 -0
  60. package/common/utils/getUInt32FromUint8Array.js +6 -0
  61. package/enums/Alignment.js +9 -0
  62. package/enums/AnimationFlags.js +38 -0
  63. package/enums/AudioFlag.js +41 -0
  64. package/enums/BadgeStyle.js +186 -0
  65. package/enums/Blip.js +229 -0
  66. package/enums/Bone.js +105 -0
  67. package/enums/CameraShake.js +17 -0
  68. package/enums/CameraTypes.js +11 -0
  69. package/enums/CheckboxStyle.js +8 -0
  70. package/enums/Checkpoint.js +68 -0
  71. package/enums/CloudHat.js +27 -0
  72. package/enums/Control.js +364 -0
  73. package/enums/CursorSprite.js +18 -0
  74. package/enums/Driving.js +38 -0
  75. package/enums/ExplosionType.js +45 -0
  76. package/enums/FiringPattern.js +23 -0
  77. package/enums/Font.js +11 -0
  78. package/enums/ForceType.js +12 -0
  79. package/enums/Gender.js +8 -0
  80. package/enums/HelmetType.js +9 -0
  81. package/enums/HudColor.js +187 -0
  82. package/enums/HudComponent.js +57 -0
  83. package/enums/InputMode.js +8 -0
  84. package/enums/InvertAxis.js +10 -0
  85. package/enums/Language.js +18 -0
  86. package/enums/LeaveVehicleFlags.js +14 -0
  87. package/enums/LoadingSpinnerType.js +11 -0
  88. package/enums/MarkerType.js +48 -0
  89. package/enums/MenuAlignment.js +8 -0
  90. package/enums/NotificationType.js +14 -0
  91. package/enums/Parachute.js +19 -0
  92. package/enums/PickupType.js +77 -0
  93. package/enums/RadioStation.js +28 -0
  94. package/enums/RagdollType.js +10 -0
  95. package/enums/RaycastEnums.js +33 -0
  96. package/enums/Relationship.js +13 -0
  97. package/enums/RopeType.js +9 -0
  98. package/enums/ScreenEffect.js +87 -0
  99. package/enums/SpeechModifier.js +43 -0
  100. package/enums/Vehicle.js +396 -0
  101. package/enums/Weather.js +22 -0
  102. package/enums/ZoneID.js +95 -0
  103. package/hashes/MaterialHash.js +220 -0
  104. package/hashes/PedHash.js +728 -0
  105. package/hashes/VehicleHash.js +526 -0
  106. package/hashes/WeaponHash.js +155 -0
  107. package/hashes/WeatherTypeHash.js +22 -0
  108. package/index.js +166 -18794
  109. package/interfaces/Dimensions.d.ts +1 -1
  110. package/interfaces/Dimensions.js +0 -0
  111. package/models/BaseEntity.d.ts +10 -8
  112. package/models/BaseEntity.js +576 -0
  113. package/models/Entity.d.ts +0 -1
  114. package/models/Entity.js +0 -0
  115. package/models/EntityBone.d.ts +1 -1
  116. package/models/EntityBone.js +32 -0
  117. package/models/EntityBoneCollection.d.ts +1 -1
  118. package/models/EntityBoneCollection.js +27 -0
  119. package/models/Ped.d.ts +13 -5
  120. package/models/Ped.js +711 -0
  121. package/models/PedBone.d.ts +3 -2
  122. package/models/PedBone.js +18 -0
  123. package/models/PedBoneCollection.d.ts +3 -1
  124. package/models/PedBoneCollection.js +31 -0
  125. package/models/Player.d.ts +4 -2
  126. package/models/Player.js +188 -0
  127. package/models/Prop.d.ts +1 -1
  128. package/models/Prop.js +34 -0
  129. package/models/Vehicle.d.ts +9 -4
  130. package/models/Vehicle.js +582 -0
  131. package/models/VehicleDoor.d.ts +1 -1
  132. package/models/VehicleDoor.js +52 -0
  133. package/models/VehicleDoorCollection.d.ts +1 -1
  134. package/models/VehicleDoorCollection.js +66 -0
  135. package/models/VehicleMod.d.ts +1 -1
  136. package/models/VehicleMod.js +43 -0
  137. package/models/VehicleModCollection.d.ts +2 -2
  138. package/models/VehicleModCollection.js +227 -0
  139. package/models/VehicleToggleMod.d.ts +1 -1
  140. package/models/VehicleToggleMod.js +37 -0
  141. package/models/VehicleWheel.js +31 -0
  142. package/models/VehicleWheelCollection.d.ts +1 -1
  143. package/models/VehicleWheelCollection.js +61 -0
  144. package/models/VehicleWindow.d.ts +1 -1
  145. package/models/VehicleWindow.js +43 -0
  146. package/models/VehicleWindowCollection.d.ts +1 -1
  147. package/models/VehicleWindowCollection.js +62 -0
  148. package/package.json +2 -2
  149. package/ui/Container.d.ts +4 -2
  150. package/ui/Container.js +39 -0
  151. package/ui/Effects.d.ts +1 -1
  152. package/ui/Effects.js +112 -0
  153. package/ui/Fading.js +74 -0
  154. package/ui/Hud.d.ts +3 -2
  155. package/ui/Hud.js +47 -0
  156. package/ui/InstructionalButtons.js +42 -0
  157. package/ui/LoadingPrompt.d.ts +1 -1
  158. package/ui/LoadingPrompt.js +37 -0
  159. package/ui/Notification.js +17 -0
  160. package/ui/Rectangle.d.ts +4 -2
  161. package/ui/Rectangle.js +46 -0
  162. package/ui/Scaleform.d.ts +2 -1
  163. package/ui/Scaleform.js +240 -0
  164. package/ui/Screen.d.ts +6 -3
  165. package/ui/Screen.js +83 -0
  166. package/ui/Sprite.d.ts +3 -1
  167. package/ui/Sprite.js +70 -0
  168. package/ui/Text.d.ts +6 -3
  169. package/ui/Text.js +119 -0
  170. package/ui/Timerbar.js +241 -0
  171. package/ui/interfaces/IButton.d.ts +1 -1
  172. package/ui/interfaces/IButton.js +0 -0
  173. package/ui/interfaces/IDrawable.d.ts +3 -1
  174. package/ui/interfaces/IDrawable.js +0 -0
  175. package/ui/menu/Menu.d.ts +9 -4
  176. package/ui/menu/Menu.js +830 -0
  177. package/ui/menu/MenuControl.js +20 -0
  178. package/ui/menu/MenuControls.js +17 -0
  179. package/ui/menu/MenuSettings.d.ts +1 -1
  180. package/ui/menu/MenuSettings.js +57 -0
  181. package/ui/menu/items/UIMenuCheckboxItem.d.ts +3 -3
  182. package/ui/menu/items/UIMenuCheckboxItem.js +70 -0
  183. package/ui/menu/items/UIMenuItem.d.ts +10 -4
  184. package/ui/menu/items/UIMenuItem.js +1103 -0
  185. package/ui/menu/items/UIMenuListItem.d.ts +3 -3
  186. package/ui/menu/items/UIMenuListItem.js +118 -0
  187. package/ui/menu/items/UIMenuSeparatorItem.d.ts +1 -1
  188. package/ui/menu/items/UIMenuSeparatorItem.js +37 -0
  189. package/ui/menu/items/UIMenuSliderItem.d.ts +4 -3
  190. package/ui/menu/items/UIMenuSliderItem.js +180 -0
  191. package/ui/menu/items/panels/AbstractUIMenuPanel.d.ts +4 -3
  192. package/ui/menu/items/panels/AbstractUIMenuPanel.js +49 -0
  193. package/ui/menu/items/panels/UIMenuColorPanel.d.ts +3 -3
  194. package/ui/menu/items/panels/UIMenuColorPanel.js +215 -0
  195. package/ui/menu/items/panels/UIMenuGridPanel.d.ts +3 -3
  196. package/ui/menu/items/panels/UIMenuGridPanel.js +216 -0
  197. package/ui/menu/items/panels/UIMenuPercentagePanel.d.ts +2 -2
  198. package/ui/menu/items/panels/UIMenuPercentagePanel.js +138 -0
  199. package/ui/menu/items/panels/UIMenuStatisticsPanel.d.ts +3 -2
  200. package/ui/menu/items/panels/UIMenuStatisticsPanel.js +88 -0
  201. package/ui/menu/items/panels/UIMenuStatisticsPanelItem.d.ts +2 -1
  202. package/ui/menu/items/panels/UIMenuStatisticsPanelItem.js +48 -0
  203. package/ui/menu/modules/ListItem.js +18 -0
  204. package/utils/Animations.js +43 -0
  205. package/utils/Crypto.js +33 -0
  206. package/utils/LiteEvent.js +25 -0
  207. package/utils/Maths.js +18 -0
  208. package/utils/Point.js +36 -0
  209. package/utils/Size.js +16 -0
  210. package/utils/String.d.ts +1 -1
  211. package/utils/String.js +35 -0
  212. package/weapon/DlcWeaponData.d.ts +1 -1
  213. package/weapon/DlcWeaponData.js +40 -0
  214. package/weapon/Mk2WeaponHash.js +18 -0
  215. package/weapon/Weapon.d.ts +7 -7
  216. package/weapon/Weapon.js +276 -0
  217. package/weapon/WeaponAsset.d.ts +1 -1
  218. package/weapon/WeaponAsset.js +87 -0
  219. package/weapon/WeaponCollection.d.ts +3 -2
  220. package/weapon/WeaponCollection.js +179 -0
  221. package/weapon/WeaponDisplayNameByHash.d.ts +1 -1
  222. package/weapon/WeaponDisplayNameByHash.js +73 -0
  223. package/weapon/WeaponGroup.js +22 -0
  224. package/weapon/WeaponHudStats.d.ts +1 -1
  225. package/weapon/WeaponHudStats.js +33 -0
  226. package/weapon/WeaponLivery.js +17 -0
  227. package/weapon/WeaponLiveryColor.js +38 -0
  228. package/weapon/WeaponTint.js +46 -0
  229. package/weaponComponent/ComponentAttachmentPoint.js +22 -0
  230. package/weaponComponent/ComponentAttachmentPointByHash.js +307 -0
  231. package/weaponComponent/ComponentDisplayNameByHash.js +278 -0
  232. package/weaponComponent/DlcWeaponComponentData.js +40 -0
  233. package/weaponComponent/InvalidWeaponComponent.d.ts +1 -1
  234. package/weaponComponent/InvalidWeaponComponent.js +31 -0
  235. package/weaponComponent/WeaponComponent.d.ts +4 -4
  236. package/weaponComponent/WeaponComponent.js +124 -0
  237. package/weaponComponent/WeaponComponentCollection.d.ts +2 -2
  238. package/weaponComponent/WeaponComponentCollection.js +187 -0
  239. package/weaponComponent/WeaponComponentHash.js +670 -0
  240. package/weaponComponent/WeaponComponentHashesByWeaponHash.d.ts +1 -1
  241. package/weaponComponent/WeaponComponentHashesByWeaponHash.js +864 -0
  242. package/weaponComponent/WeaponComponentHudStats.js +33 -0
  243. package/common/index.d.ts +0 -8
  244. package/common/utils/Vector2.d.ts +0 -1
  245. package/common/utils/Vector3.d.ts +0 -1
  246. package/common/utils/Vector4.d.ts +0 -1
  247. package/common/utils/index.d.ts +0 -12
  248. package/enums/index.d.ts +0 -42
  249. package/hashes/index.d.ts +0 -5
  250. package/index.d.ts +0 -25
  251. package/models/index.d.ts +0 -18
  252. package/ui/index.d.ts +0 -15
  253. package/ui/interfaces/index.d.ts +0 -2
  254. package/ui/menu/index.d.ts +0 -6
  255. package/ui/menu/items/index.d.ts +0 -6
  256. package/ui/menu/items/panels/index.d.ts +0 -6
  257. package/ui/menu/modules/index.d.ts +0 -1
  258. package/utils/PointF.d.ts +0 -7
  259. package/utils/Quaternion.d.ts +0 -10
  260. package/utils/enumValues.d.ts +0 -12
  261. package/utils/getStringFromUInt8Array.d.ts +0 -8
  262. package/utils/getUInt32FromUint8Array.d.ts +0 -8
  263. package/utils/index.d.ts +0 -9
  264. package/weapon/index.d.ts +0 -8
  265. package/weaponComponent/index.d.ts +0 -5
package/utils/Point.js ADDED
@@ -0,0 +1,36 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ class Point {
4
+ static {
5
+ __name(this, "Point");
6
+ }
7
+ static parse(arg) {
8
+ let point = new Point();
9
+ if (arg) {
10
+ if (typeof arg === "object") {
11
+ if (Array.isArray(arg)) {
12
+ if (arg.length === 2) {
13
+ point = new Point(arg[0], arg[1]);
14
+ }
15
+ } else if (arg.X && arg.Y) {
16
+ point = new Point(arg.X, arg.Y);
17
+ }
18
+ } else {
19
+ if (arg.indexOf(",") !== -1) {
20
+ const arr = arg.split(",");
21
+ point = new Point(Number.parseFloat(arr[0]), Number.parseFloat(arr[1]));
22
+ }
23
+ }
24
+ }
25
+ return point;
26
+ }
27
+ X;
28
+ Y;
29
+ constructor(x = 0, y = 0) {
30
+ this.X = x;
31
+ this.Y = y;
32
+ }
33
+ }
34
+ export {
35
+ Point
36
+ };
package/utils/Size.js ADDED
@@ -0,0 +1,16 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ class Size {
4
+ static {
5
+ __name(this, "Size");
6
+ }
7
+ width;
8
+ height;
9
+ constructor(w = 0, h = 0) {
10
+ this.width = w;
11
+ this.height = h;
12
+ }
13
+ }
14
+ export {
15
+ Size
16
+ };
package/utils/String.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Font } from "..";
1
+ import { Font } from "fivem/enums/Font";
2
2
  export declare abstract class _String {
3
3
  static stringToArray(input: string): string[];
4
4
  static measureStringWidthNoConvert(input: string, font?: Font, scale?: number): number;
@@ -0,0 +1,35 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Font } from "fivem/enums/Font";
4
+ import { Screen } from "fivem/ui/Screen";
5
+ import { Text } from "fivem/ui/Text";
6
+ import { Maths } from "./Maths";
7
+ class _String {
8
+ static {
9
+ __name(this, "_String");
10
+ }
11
+ static stringToArray(input) {
12
+ let stringsNeeded = 1;
13
+ if (input.length > 99) {
14
+ stringsNeeded = Math.ceil(input.length / 99);
15
+ }
16
+ const outputString = new Array(stringsNeeded);
17
+ for (let i = 0; i < stringsNeeded; i++) {
18
+ outputString[i] = input.substring(i * 99, i * 99 + Maths.clamp(input.substring(i * 99).length, 0, 99));
19
+ }
20
+ return outputString;
21
+ }
22
+ static measureStringWidthNoConvert(input, font = Font.ChaletLondon, scale = 0) {
23
+ SetTextEntryForWidth("STRING");
24
+ Text.addLongString(input);
25
+ SetTextFont(font);
26
+ SetTextScale(1, scale);
27
+ return GetTextScreenWidth(false);
28
+ }
29
+ static measureString(str, font, scale, screenWidth = Screen.ScaledWidth) {
30
+ return this.measureStringWidthNoConvert(str, font, scale) * screenWidth;
31
+ }
32
+ }
33
+ export {
34
+ _String
35
+ };
@@ -1,4 +1,4 @@
1
- import type { WeaponHash } from "../hashes";
1
+ import type { WeaponHash } from "fivem/hashes/WeaponHash";
2
2
  /**
3
3
  * DlcWeaponData
4
4
  * refer1: https://github.com/citizenfx/fivem/blob/master/code/client/clrcore/External/DlcWeaponStructs.cs#L10
@@ -0,0 +1,40 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { getStringFromUInt8Array } from "../common/utils/getStringFromUInt8Array";
4
+ import { getUInt32FromUint8Array } from "../common/utils/getUInt32FromUint8Array";
5
+ const DlcWeaponData = /* @__PURE__ */ new Map();
6
+ function initializeOnce() {
7
+ let isInitialized = false;
8
+ return () => {
9
+ if (isInitialized || IsDuplicityVersion()) {
10
+ return;
11
+ }
12
+ const intLength = 4;
13
+ const strLength = 64;
14
+ const weaponCount = GetNumDlcWeapons();
15
+ for (let i = 0; i < weaponCount; i++) {
16
+ const buffer = new Uint8Array(14 * intLength + 4 * strLength);
17
+ Citizen.invokeNative("0x79923CD21BECE14E", i, buffer, Citizen.returnResultAnyway());
18
+ const dlcWeaponData = {
19
+ validCheck: getUInt32FromUint8Array(buffer, 0 * intLength, 1 * intLength),
20
+ weaponHash: getUInt32FromUint8Array(buffer, 2 * intLength, 3 * intLength),
21
+ unk: getUInt32FromUint8Array(buffer, 4 * intLength, 5 * intLength),
22
+ weaponCost: getUInt32FromUint8Array(buffer, 6 * intLength, 7 * intLength),
23
+ ammoCost: getUInt32FromUint8Array(buffer, 8 * intLength, 9 * intLength),
24
+ ammoType: getUInt32FromUint8Array(buffer, 10 * intLength, 11 * intLength),
25
+ defaultClipSize: getUInt32FromUint8Array(buffer, 12 * intLength, 13 * intLength),
26
+ name: getStringFromUInt8Array(buffer, 14 * intLength, 14 * intLength + strLength),
27
+ desc: getStringFromUInt8Array(buffer, 14 * intLength + strLength, 14 * intLength + 2 * strLength),
28
+ simpleDesc: getStringFromUInt8Array(buffer, 14 * intLength + 2 * strLength, 14 * intLength + 3 * strLength),
29
+ upperCaseName: getStringFromUInt8Array(buffer, 14 * intLength + 3 * strLength, 14 * intLength + 4 * strLength)
30
+ };
31
+ DlcWeaponData.set(dlcWeaponData.weaponHash, dlcWeaponData);
32
+ }
33
+ isInitialized = true;
34
+ };
35
+ }
36
+ __name(initializeOnce, "initializeOnce");
37
+ initializeOnce()();
38
+ export {
39
+ DlcWeaponData
40
+ };
@@ -0,0 +1,18 @@
1
+ var Mk2WeaponHash = /* @__PURE__ */ ((Mk2WeaponHash2) => {
2
+ Mk2WeaponHash2[Mk2WeaponHash2["PistolMk2"] = 3219281620] = "PistolMk2";
3
+ Mk2WeaponHash2[Mk2WeaponHash2["SNSPistolMk2"] = 2285322324] = "SNSPistolMk2";
4
+ Mk2WeaponHash2[Mk2WeaponHash2["RevolverMk2"] = 3415619887] = "RevolverMk2";
5
+ Mk2WeaponHash2[Mk2WeaponHash2["SMGMk2"] = 2024373456] = "SMGMk2";
6
+ Mk2WeaponHash2[Mk2WeaponHash2["PumpShotgunMk2"] = 1432025498] = "PumpShotgunMk2";
7
+ Mk2WeaponHash2[Mk2WeaponHash2["AssaultRifleMk2"] = 961495388] = "AssaultRifleMk2";
8
+ Mk2WeaponHash2[Mk2WeaponHash2["CarbineRifleMk2"] = 4208062921] = "CarbineRifleMk2";
9
+ Mk2WeaponHash2[Mk2WeaponHash2["SpecialCarbineMk2"] = 2526821735] = "SpecialCarbineMk2";
10
+ Mk2WeaponHash2[Mk2WeaponHash2["BullpupRifleMk2"] = 2228681469] = "BullpupRifleMk2";
11
+ Mk2WeaponHash2[Mk2WeaponHash2["CombatMGMk2"] = 3686625920] = "CombatMGMk2";
12
+ Mk2WeaponHash2[Mk2WeaponHash2["HeavySniperMk2"] = 177293209] = "HeavySniperMk2";
13
+ Mk2WeaponHash2[Mk2WeaponHash2["MarksmanRifleMk2"] = 1785463520] = "MarksmanRifleMk2";
14
+ return Mk2WeaponHash2;
15
+ })(Mk2WeaponHash || {});
16
+ export {
17
+ Mk2WeaponHash
18
+ };
@@ -1,13 +1,13 @@
1
- import { WeaponComponentCollection } from "../weaponComponent/WeaponComponentCollection";
2
- import type { Ped } from "../models";
3
- import { type AmmoType, WeaponHash } from "../hashes";
4
- import { Model } from "../Model";
5
- import type { WeaponTint } from "./WeaponTint";
1
+ import { WeaponHash, type AmmoType } from "fivem/hashes/WeaponHash";
2
+ import { Model } from "fivem/Model";
3
+ import type { Ped } from "fivem/models/Ped";
4
+ import { WeaponComponentCollection } from "fivem/weaponComponent/WeaponComponentCollection";
5
+ import type { WeaponComponentHash } from "fivem/weaponComponent/WeaponComponentHash";
6
6
  import type { WeaponGroup } from "./WeaponGroup";
7
+ import { WeaponHudStats } from "./WeaponHudStats";
7
8
  import type { WeaponLivery } from "./WeaponLivery";
8
9
  import type { WeaponLiveryColor } from "./WeaponLiveryColor";
9
- import { WeaponHudStats } from "./WeaponHudStats";
10
- import type { WeaponComponentHash } from "../weaponComponent";
10
+ import type { WeaponTint } from "./WeaponTint";
11
11
  /**
12
12
  * ped weapon
13
13
  *
@@ -0,0 +1,276 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { enumValues } from "../common/utils/enumValues";
4
+ import { Game } from "fivem/Game";
5
+ import { WeaponHash } from "fivem/hashes/WeaponHash";
6
+ import { Model } from "fivem/Model";
7
+ import { WeaponComponentCollection } from "fivem/weaponComponent/WeaponComponentCollection";
8
+ import { WeaponComponentHashesByWeaponHash } from "fivem/weaponComponent/WeaponComponentHashesByWeaponHash";
9
+ import { Mk2WeaponHash } from "./Mk2WeaponHash";
10
+ import { WeaponDisplayNameByHash } from "./WeaponDisplayNameByHash";
11
+ import { WeaponHudStats } from "./WeaponHudStats";
12
+ class Weapon {
13
+ static {
14
+ __name(this, "Weapon");
15
+ }
16
+ owner;
17
+ components;
18
+ hash;
19
+ constructor(owner, hash) {
20
+ this.owner = owner;
21
+ this.hash = hash;
22
+ this.components = new WeaponComponentCollection(this.owner, this);
23
+ }
24
+ /**
25
+ * weapon components
26
+ *
27
+ * @constructor
28
+ */
29
+ get Components() {
30
+ return this.components;
31
+ }
32
+ /**
33
+ * weapon hash
34
+ *
35
+ * @constructor
36
+ */
37
+ get Hash() {
38
+ return this.hash;
39
+ }
40
+ /**
41
+ * check ped is unarmed or not
42
+ *
43
+ * @constructor
44
+ */
45
+ get IsUnarmed() {
46
+ return this.hash === WeaponHash.Unarmed;
47
+ }
48
+ /**
49
+ * Check if the ped has the current weapon.
50
+ *
51
+ * @constructor
52
+ */
53
+ get IsPresent() {
54
+ if (this.IsUnarmed) {
55
+ return true;
56
+ }
57
+ return HasPedGotWeapon(this.owner.Handle, this.hash, false);
58
+ }
59
+ /**
60
+ * get weapon display name / label
61
+ *
62
+ * @constructor
63
+ */
64
+ get DisplayName() {
65
+ return Weapon.getDisplayNameFromHash(this.hash) ?? "WCT_INVALID";
66
+ }
67
+ /**
68
+ * get weapon localized name
69
+ *
70
+ * @constructor
71
+ */
72
+ get LocalizedName() {
73
+ return Game.getGXTEntry(this.DisplayName);
74
+ }
75
+ /**
76
+ * get weapon model
77
+ *
78
+ * @constructor
79
+ */
80
+ get Model() {
81
+ return new Model(GetWeapontypeModel(this.hash));
82
+ }
83
+ /**
84
+ * get weapon tint
85
+ *
86
+ * @constructor
87
+ */
88
+ get Tint() {
89
+ return GetPedWeaponTintIndex(this.owner.Handle, this.hash);
90
+ }
91
+ /**
92
+ * set weapon tint
93
+ *
94
+ * @param tint
95
+ * @constructor
96
+ */
97
+ set Tint(tint) {
98
+ SetPedWeaponTintIndex(this.owner.Handle, this.hash, tint);
99
+ }
100
+ /**
101
+ * get weapon group
102
+ *
103
+ * @constructor
104
+ */
105
+ get Group() {
106
+ return GetWeapontypeGroup(this.hash);
107
+ }
108
+ /**
109
+ * get weapon ammo type
110
+ *
111
+ * @constructor
112
+ */
113
+ get AmmoType() {
114
+ return GetPedAmmoTypeFromWeapon(this.owner.Handle, this.hash);
115
+ }
116
+ /**
117
+ * get weapon ammo count
118
+ *
119
+ * @constructor
120
+ */
121
+ get Ammo() {
122
+ if (this.IsUnarmed) {
123
+ return 1;
124
+ }
125
+ if (!this.IsPresent) {
126
+ return GetPedAmmoByType(this.owner.Handle, this.AmmoType);
127
+ }
128
+ return GetAmmoInPedWeapon(this.owner.Handle, this.hash);
129
+ }
130
+ /**
131
+ * set weapon ammo count
132
+ *
133
+ * @param count
134
+ * @constructor
135
+ */
136
+ set Ammo(count) {
137
+ if (this.IsUnarmed) {
138
+ return;
139
+ }
140
+ if (this.IsPresent) {
141
+ SetPedAmmo(this.owner.Handle, this.hash, count);
142
+ } else {
143
+ GiveWeaponToPed(this.owner.Handle, this.hash, count, false, true);
144
+ }
145
+ }
146
+ /**
147
+ * get weapon max ammo
148
+ *
149
+ * @constructor
150
+ */
151
+ get MaxAmmo() {
152
+ if (this.IsUnarmed) {
153
+ return 1;
154
+ }
155
+ const amount = Citizen.invokeNative(
156
+ "0xDC16122C7A20C933",
157
+ this.owner.Handle,
158
+ this.hash,
159
+ Citizen.pointerValueInt(),
160
+ Citizen.resultAsInteger()
161
+ );
162
+ return amount;
163
+ }
164
+ /**
165
+ * get weapon max ammo in clip
166
+ *
167
+ * @constructor
168
+ */
169
+ get MaxAmmoInClip() {
170
+ if (this.IsUnarmed) {
171
+ return 1;
172
+ }
173
+ if (!this.IsPresent) {
174
+ return 0;
175
+ }
176
+ return GetMaxAmmoInClip(this.owner.Handle, this.hash, true);
177
+ }
178
+ /**
179
+ * get weapon default clip size
180
+ *
181
+ * @constructor
182
+ */
183
+ get DefaultClipSize() {
184
+ return GetWeaponClipSize(this.hash);
185
+ }
186
+ /**
187
+ * toggle weapon infinite ammo
188
+ *
189
+ * @param toggle
190
+ * @constructor
191
+ */
192
+ set InfiniteAmmo(toggle) {
193
+ if (this.IsUnarmed) {
194
+ return;
195
+ }
196
+ SetPedInfiniteAmmo(this.owner.Handle, toggle, this.hash);
197
+ }
198
+ /**
199
+ * toggle ped infinite ammo clip on all weapons
200
+ *
201
+ * @param toggle
202
+ * @constructor
203
+ */
204
+ set InfiniteAmmoClip(toggle) {
205
+ SetPedInfiniteAmmoClip(this.owner.Handle, toggle);
206
+ }
207
+ /**
208
+ * check weapon can use on parachute
209
+ *
210
+ * @constructor
211
+ */
212
+ get CanUseOnParachute() {
213
+ return CanUseWeaponOnParachute(this.hash);
214
+ }
215
+ /**
216
+ * Check weapon is Mk2 or not
217
+ *
218
+ * @constructor
219
+ */
220
+ get IsMk2() {
221
+ return Array.from(enumValues(Mk2WeaponHash)).some((x) => x === this.hash);
222
+ }
223
+ /**
224
+ * set weapon livery, only work for Mk2 weapon
225
+ *
226
+ * @param liveryId
227
+ * @param colorId
228
+ */
229
+ setLivery(liveryId, colorId) {
230
+ if (!this.IsMk2) {
231
+ console.log(`[ERROR]${this.setLivery.name} failed. Reason: non-Mk2 weapon`);
232
+ return;
233
+ }
234
+ const component = this.Components.getMk2CamoComponent(liveryId);
235
+ if (component.IsInvalid) {
236
+ console.log(`[ERROR]${this.setLivery.name} failed. Reason: invalid liveryId/Component`);
237
+ return;
238
+ }
239
+ component.Active = true;
240
+ SetPedWeaponLiveryColor(this.owner.Handle, this.hash, component.ComponentHash, colorId);
241
+ }
242
+ /**
243
+ * get weapon hud stats
244
+ *
245
+ * @constructor
246
+ */
247
+ get HudStats() {
248
+ return WeaponHudStats.get(this.hash);
249
+ }
250
+ /**
251
+ * get weapon display name / label by hash
252
+ *
253
+ * @param hash
254
+ */
255
+ static getDisplayNameFromHash(hash) {
256
+ if (!hash) {
257
+ return "WT_INVALID";
258
+ }
259
+ return WeaponDisplayNameByHash.get(hash) ?? "WCT_INVALID";
260
+ }
261
+ /**
262
+ * get component hashes belongs to weapon
263
+ *
264
+ * @param hash
265
+ */
266
+ static getWeaponComponentHashes(hash) {
267
+ const hashes = WeaponComponentHashesByWeaponHash.get(hash);
268
+ if (!hashes) {
269
+ return [];
270
+ }
271
+ return [...hashes];
272
+ }
273
+ }
274
+ export {
275
+ Weapon
276
+ };
@@ -1,4 +1,4 @@
1
- import type { WeaponHash } from "../hashes";
1
+ import type { WeaponHash } from "fivem/hashes/WeaponHash";
2
2
  /**
3
3
  * weapon asset
4
4
  *
@@ -0,0 +1,87 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Game } from "fivem/Game";
4
+ import { Weapon } from "./Weapon";
5
+ class WeaponAsset {
6
+ static {
7
+ __name(this, "WeaponAsset");
8
+ }
9
+ hash;
10
+ constructor(hash) {
11
+ this.hash = hash;
12
+ }
13
+ /**
14
+ * get weapon hash
15
+ *
16
+ * @constructor
17
+ */
18
+ get Hash() {
19
+ return this.hash;
20
+ }
21
+ /**
22
+ * check weapon is valid
23
+ *
24
+ * @constructor
25
+ */
26
+ get IsValid() {
27
+ return IsWeaponValid(this.hash);
28
+ }
29
+ /**
30
+ * check weapon assets is loaded
31
+ *
32
+ * @constructor
33
+ */
34
+ get IsLoaded() {
35
+ return HasWeaponAssetLoaded(this.hash);
36
+ }
37
+ /**
38
+ * request weapon asset
39
+ *
40
+ */
41
+ request() {
42
+ RequestWeaponAsset(this.hash, 31, 0);
43
+ }
44
+ /**
45
+ * request weapon asset async
46
+ *
47
+ * @param timeout
48
+ */
49
+ async requestAsync(timeout) {
50
+ this.request();
51
+ const start = GetGameTimer();
52
+ while (!this.IsLoaded) {
53
+ await Wait(100);
54
+ const now = GetGameTimer();
55
+ if (now - start >= timeout) {
56
+ return false;
57
+ }
58
+ }
59
+ return true;
60
+ }
61
+ /**
62
+ * unload weapon asset
63
+ *
64
+ */
65
+ dismiss() {
66
+ RemoveWeaponAsset(this.hash);
67
+ }
68
+ /**
69
+ * get weapon display name / label
70
+ *
71
+ * @constructor
72
+ */
73
+ get DisplayName() {
74
+ return Weapon.getDisplayNameFromHash(this.hash);
75
+ }
76
+ /**
77
+ * get weapon localized name
78
+ *
79
+ * @constructor
80
+ */
81
+ get LocalizedName() {
82
+ return Game.getGXTEntry(this.DisplayName);
83
+ }
84
+ }
85
+ export {
86
+ WeaponAsset
87
+ };
@@ -1,6 +1,7 @@
1
+ import type { WeaponHash } from "fivem/hashes/WeaponHash";
2
+ import type { Ped } from "fivem/models/Ped";
3
+ import { Prop } from "fivem/models/Prop";
1
4
  import { Weapon } from "./Weapon";
2
- import { type Ped, Prop } from "../models";
3
- import type { WeaponHash } from "../hashes";
4
5
  /**
5
6
  * ped weapons
6
7
  *