@nativewrappers/fivem 0.0.65 → 0.0.72

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 (241) hide show
  1. package/Audio.d.ts +2 -2
  2. package/Blip.d.ts +2 -2
  3. package/Camera.d.ts +1 -1
  4. package/Game.d.ts +1 -1
  5. package/GameplayCamera.d.ts +1 -1
  6. package/Model.d.ts +1 -1
  7. package/ParticleEffect.d.ts +2 -2
  8. package/ParticleEffectAsset.d.ts +1 -1
  9. package/README.md +45 -0
  10. package/Raycast.d.ts +2 -2
  11. package/RelationshipGroup.d.ts +1 -1
  12. package/Tasks.d.ts +3 -3
  13. package/World.d.ts +2 -2
  14. package/cfx/StateBagChangeHandler.d.ts +1 -3
  15. package/common/Command.d.ts +30 -0
  16. package/common/Convar.d.ts +13 -0
  17. package/common/GlobalData.d.ts +8 -0
  18. package/common/Kvp.d.ts +69 -0
  19. package/common/Resource.d.ts +14 -0
  20. package/common/decors/Events.d.ts +54 -0
  21. package/common/index.d.ts +8 -0
  22. package/common/net/NetworkedMap.d.ts +28 -0
  23. package/common/types.d.ts +5 -0
  24. package/common/utils/ClassTypes.d.ts +11 -0
  25. package/common/utils/Color.d.ts +14 -0
  26. package/common/utils/Maths.d.ts +4 -0
  27. package/common/utils/PointF.d.ts +12 -0
  28. package/common/utils/Quaternion.d.ts +10 -0
  29. package/common/utils/Vector.d.ts +429 -0
  30. package/common/utils/Vector2.d.ts +1 -0
  31. package/common/utils/Vector3.d.ts +1 -0
  32. package/common/utils/Vector4.d.ts +1 -0
  33. package/common/utils/cleanPlayerName.d.ts +6 -0
  34. package/common/utils/enumValues.d.ts +12 -0
  35. package/{utils/getStringFromUInt8Array.js → common/utils/getStringFromUInt8Array.d.ts} +1 -3
  36. package/{utils/getUInt32FromUint8Array.js → common/utils/getUInt32FromUint8Array.d.ts} +1 -1
  37. package/common/utils/index.d.ts +12 -0
  38. package/index.d.ts +1 -1
  39. package/index.js +20136 -26
  40. package/interfaces/Dimensions.d.ts +1 -1
  41. package/models/BaseEntity.d.ts +3 -3
  42. package/models/Ped.d.ts +2 -2
  43. package/models/PedBone.d.ts +1 -1
  44. package/models/PedBoneCollection.d.ts +1 -1
  45. package/models/Player.d.ts +1 -1
  46. package/models/Vehicle.d.ts +2 -2
  47. package/models/VehicleDoor.d.ts +2 -2
  48. package/models/VehicleDoorCollection.d.ts +1 -1
  49. package/models/VehicleMod.d.ts +2 -2
  50. package/models/VehicleModCollection.d.ts +2 -2
  51. package/models/VehicleToggleMod.d.ts +2 -2
  52. package/models/VehicleWheel.d.ts +1 -1
  53. package/models/VehicleWheelCollection.d.ts +1 -1
  54. package/models/VehicleWindow.d.ts +2 -2
  55. package/models/VehicleWindowCollection.d.ts +1 -1
  56. package/package.json +6 -4
  57. package/ui/Container.d.ts +2 -2
  58. package/ui/Effects.d.ts +1 -1
  59. package/ui/Hud.d.ts +2 -2
  60. package/ui/InstructionalButtons.d.ts +1 -1
  61. package/ui/Rectangle.d.ts +2 -2
  62. package/ui/Scaleform.d.ts +1 -1
  63. package/ui/Screen.d.ts +1 -1
  64. package/ui/Text.d.ts +1 -1
  65. package/ui/interfaces/IButton.d.ts +1 -1
  66. package/ui/interfaces/IDrawable.d.ts +1 -1
  67. package/ui/menu/items/UIMenuItem.d.ts +1 -1
  68. package/ui/menu/items/UIMenuListItem.d.ts +1 -1
  69. package/ui/menu/items/panels/AbstractUIMenuPanel.d.ts +2 -2
  70. package/ui/menu/items/panels/UIMenuStatisticsPanel.d.ts +1 -1
  71. package/utils/LiteEvent.d.ts +2 -6
  72. package/utils/index.d.ts +1 -1
  73. package/weapon/DlcWeaponData.d.ts +1 -1
  74. package/weapon/Weapon.d.ts +7 -7
  75. package/weapon/WeaponAsset.d.ts +1 -1
  76. package/weapon/WeaponCollection.d.ts +2 -2
  77. package/weaponComponent/DlcWeaponComponentData.d.ts +1 -1
  78. package/weaponComponent/InvalidWeaponComponent.d.ts +1 -1
  79. package/weaponComponent/WeaponComponent.d.ts +3 -3
  80. package/weaponComponent/WeaponComponentCollection.d.ts +3 -3
  81. package/Audio.js +0 -93
  82. package/Blip.js +0 -105
  83. package/Camera.js +0 -162
  84. package/Checkpoint.js +0 -43
  85. package/Events.js +0 -74
  86. package/Game.js +0 -474
  87. package/GameplayCamera.js +0 -141
  88. package/Model.js +0 -213
  89. package/NetworkedScene.js +0 -18
  90. package/ParticleEffect.js +0 -123
  91. package/ParticleEffectAsset.js +0 -105
  92. package/Pickup.js +0 -19
  93. package/Raycast.js +0 -123
  94. package/RelationshipGroup.js +0 -67
  95. package/Rope.js +0 -129
  96. package/TaskSequence.js +0 -48
  97. package/Tasks.js +0 -241
  98. package/World.js +0 -765
  99. package/cfx/StateBagChangeHandler.js +0 -1
  100. package/cfx/index.js +0 -1
  101. package/enums/Alignment.js +0 -6
  102. package/enums/AnimationFlags.js +0 -35
  103. package/enums/AudioFlag.js +0 -38
  104. package/enums/BadgeStyle.js +0 -183
  105. package/enums/Blip.js +0 -225
  106. package/enums/Bone.js +0 -103
  107. package/enums/CameraShake.js +0 -14
  108. package/enums/CameraTypes.js +0 -8
  109. package/enums/CheckboxStyle.js +0 -5
  110. package/enums/Checkpoint.js +0 -67
  111. package/enums/CloudHat.js +0 -27
  112. package/enums/Control.js +0 -361
  113. package/enums/CursorSprite.js +0 -15
  114. package/enums/Driving.js +0 -34
  115. package/enums/ExplosionType.js +0 -45
  116. package/enums/FiringPattern.js +0 -20
  117. package/enums/Font.js +0 -8
  118. package/enums/ForceType.js +0 -9
  119. package/enums/Gender.js +0 -5
  120. package/enums/HelmetType.js +0 -6
  121. package/enums/HudColor.js +0 -184
  122. package/enums/HudComponent.js +0 -54
  123. package/enums/InputMode.js +0 -5
  124. package/enums/InvertAxis.js +0 -7
  125. package/enums/Language.js +0 -15
  126. package/enums/LeaveVehicleFlags.js +0 -11
  127. package/enums/LoadingSpinnerType.js +0 -8
  128. package/enums/MarkerType.js +0 -50
  129. package/enums/MenuAlignment.js +0 -5
  130. package/enums/NotificationType.js +0 -11
  131. package/enums/Parachute.js +0 -15
  132. package/enums/PickupType.js +0 -74
  133. package/enums/RadioStation.js +0 -25
  134. package/enums/RagdollType.js +0 -7
  135. package/enums/RaycastEnums.js +0 -32
  136. package/enums/Relationship.js +0 -10
  137. package/enums/RopeType.js +0 -6
  138. package/enums/ScreenEffect.js +0 -84
  139. package/enums/SpeechModifier.js +0 -40
  140. package/enums/Vehicle.js +0 -376
  141. package/enums/Weather.js +0 -22
  142. package/enums/ZoneID.js +0 -95
  143. package/enums/index.js +0 -42
  144. package/hashes/MaterialHash.js +0 -217
  145. package/hashes/PedHash.js +0 -725
  146. package/hashes/VehicleHash.js +0 -523
  147. package/hashes/WeaponHash.js +0 -161
  148. package/hashes/WeatherTypeHash.js +0 -22
  149. package/hashes/index.js +0 -5
  150. package/interfaces/Dimensions.js +0 -1
  151. package/models/BaseEntity.js +0 -477
  152. package/models/Entity.js +0 -25
  153. package/models/EntityBone.js +0 -26
  154. package/models/EntityBoneCollection.js +0 -18
  155. package/models/Ped.js +0 -692
  156. package/models/PedBone.js +0 -9
  157. package/models/PedBoneCollection.js +0 -21
  158. package/models/Player.js +0 -186
  159. package/models/Prop.js +0 -26
  160. package/models/Vehicle.js +0 -576
  161. package/models/VehicleDoor.js +0 -44
  162. package/models/VehicleDoorCollection.js +0 -62
  163. package/models/VehicleMod.js +0 -35
  164. package/models/VehicleModCollection.js +0 -227
  165. package/models/VehicleToggleMod.js +0 -29
  166. package/models/VehicleWheel.js +0 -23
  167. package/models/VehicleWheelCollection.js +0 -57
  168. package/models/VehicleWindow.js +0 -35
  169. package/models/VehicleWindowCollection.js +0 -57
  170. package/models/index.js +0 -19
  171. package/ui/Container.js +0 -31
  172. package/ui/Effects.js +0 -106
  173. package/ui/Fading.js +0 -69
  174. package/ui/Hud.js +0 -39
  175. package/ui/InstructionalButtons.js +0 -54
  176. package/ui/LoadingPrompt.js +0 -45
  177. package/ui/Notification.js +0 -9
  178. package/ui/Rectangle.js +0 -40
  179. package/ui/Scaleform.js +0 -236
  180. package/ui/Screen.js +0 -72
  181. package/ui/Sprite.js +0 -60
  182. package/ui/Text.js +0 -115
  183. package/ui/Timerbar.js +0 -248
  184. package/ui/index.js +0 -15
  185. package/ui/interfaces/IButton.js +0 -1
  186. package/ui/interfaces/IDrawable.js +0 -1
  187. package/ui/interfaces/index.js +0 -1
  188. package/ui/menu/Menu.js +0 -831
  189. package/ui/menu/MenuControl.js +0 -12
  190. package/ui/menu/MenuControls.js +0 -9
  191. package/ui/menu/MenuSettings.js +0 -54
  192. package/ui/menu/index.js +0 -6
  193. package/ui/menu/items/UIMenuCheckboxItem.js +0 -59
  194. package/ui/menu/items/UIMenuItem.js +0 -1111
  195. package/ui/menu/items/UIMenuListItem.js +0 -119
  196. package/ui/menu/items/UIMenuSeparatorItem.js +0 -29
  197. package/ui/menu/items/UIMenuSliderItem.js +0 -191
  198. package/ui/menu/items/index.js +0 -6
  199. package/ui/menu/items/panels/AbstractUIMenuPanel.js +0 -44
  200. package/ui/menu/items/panels/UIMenuColorPanel.js +0 -217
  201. package/ui/menu/items/panels/UIMenuGridPanel.js +0 -261
  202. package/ui/menu/items/panels/UIMenuPercentagePanel.js +0 -124
  203. package/ui/menu/items/panels/UIMenuStatisticsPanel.js +0 -79
  204. package/ui/menu/items/panels/UIMenuStatisticsPanelItem.js +0 -35
  205. package/ui/menu/items/panels/index.js +0 -6
  206. package/ui/menu/modules/ListItem.js +0 -10
  207. package/ui/menu/modules/index.js +0 -1
  208. package/utils/Animations.js +0 -55
  209. package/utils/Crypto.js +0 -25
  210. package/utils/LiteEvent.js +0 -19
  211. package/utils/Maths.js +0 -10
  212. package/utils/Point.js +0 -30
  213. package/utils/PointF.js +0 -14
  214. package/utils/Quaternion.js +0 -27
  215. package/utils/Size.js +0 -8
  216. package/utils/String.js +0 -25
  217. package/utils/enumValues.js +0 -14
  218. package/utils/index.js +0 -9
  219. package/weapon/DlcWeaponData.js +0 -44
  220. package/weapon/Mk2WeaponHash.js +0 -25
  221. package/weapon/Weapon.js +0 -270
  222. package/weapon/WeaponAsset.js +0 -84
  223. package/weapon/WeaponCollection.js +0 -187
  224. package/weapon/WeaponDisplayNameByHash.js +0 -75
  225. package/weapon/WeaponGroup.js +0 -19
  226. package/weapon/WeaponHudStats.js +0 -38
  227. package/weapon/WeaponLivery.js +0 -14
  228. package/weapon/WeaponLiveryColor.js +0 -35
  229. package/weapon/WeaponTint.js +0 -43
  230. package/weapon/index.js +0 -8
  231. package/weaponComponent/ComponentAttachmentPoint.js +0 -19
  232. package/weaponComponent/ComponentAttachmentPointByHash.js +0 -573
  233. package/weaponComponent/ComponentDisplayNameByHash.js +0 -280
  234. package/weaponComponent/DlcWeaponComponentData.js +0 -44
  235. package/weaponComponent/InvalidWeaponComponent.js +0 -28
  236. package/weaponComponent/WeaponComponent.js +0 -123
  237. package/weaponComponent/WeaponComponentCollection.js +0 -174
  238. package/weaponComponent/WeaponComponentHash.js +0 -887
  239. package/weaponComponent/WeaponComponentHashesByWeaponHash.js +0 -829
  240. package/weaponComponent/WeaponComponentHudStats.js +0 -34
  241. package/weaponComponent/index.js +0 -5
@@ -1,27 +0,0 @@
1
- import { Vector3 } from ".";
2
- export class Quaternion {
3
- x;
4
- y;
5
- z;
6
- w;
7
- constructor(valueXOrVector, yOrW, z, w) {
8
- if (valueXOrVector instanceof Vector3) {
9
- this.x = valueXOrVector.x;
10
- this.y = valueXOrVector.y;
11
- this.z = valueXOrVector.z;
12
- this.w = yOrW ?? 0;
13
- }
14
- else if (yOrW === undefined) {
15
- this.x = valueXOrVector;
16
- this.y = valueXOrVector;
17
- this.z = valueXOrVector;
18
- this.w = valueXOrVector;
19
- }
20
- else {
21
- this.x = valueXOrVector;
22
- this.y = yOrW;
23
- this.z = z ?? 0;
24
- this.w = w ?? 0;
25
- }
26
- }
27
- }
package/utils/Size.js DELETED
@@ -1,8 +0,0 @@
1
- export class Size {
2
- width;
3
- height;
4
- constructor(w = 0, h = 0) {
5
- this.width = w;
6
- this.height = h;
7
- }
8
- }
package/utils/String.js DELETED
@@ -1,25 +0,0 @@
1
- import { Font, Screen, Text } from "..";
2
- import { Maths } from "./Maths";
3
- export class String {
4
- static stringToArray(input) {
5
- let stringsNeeded = 1;
6
- if (input.length > 99) {
7
- stringsNeeded = Math.ceil(input.length / 99);
8
- }
9
- const outputString = new Array(stringsNeeded);
10
- for (let i = 0; i < stringsNeeded; i++) {
11
- outputString[i] = input.substring(i * 99, i * 99 + Maths.clamp(input.substring(i * 99).length, 0, 99));
12
- }
13
- return outputString;
14
- }
15
- static measureStringWidthNoConvert(input, font = Font.ChaletLondon, scale = 0) {
16
- SetTextEntryForWidth("STRING");
17
- Text.addLongString(input);
18
- SetTextFont(font);
19
- SetTextScale(1, scale);
20
- return GetTextScreenWidth(false);
21
- }
22
- static measureString(str, font, scale, screenWidth = Screen.ScaledWidth) {
23
- return this.measureStringWidthNoConvert(str, font, scale) * screenWidth;
24
- }
25
- }
@@ -1,14 +0,0 @@
1
- export function* enumValues(enumObj) {
2
- let isStringEnum = true;
3
- for (const property in enumObj) {
4
- if (typeof enumObj[property] === "number") {
5
- isStringEnum = false;
6
- break;
7
- }
8
- }
9
- for (const property in enumObj) {
10
- if (isStringEnum || typeof enumObj[property] === "number") {
11
- yield enumObj[property];
12
- }
13
- }
14
- }
package/utils/index.js DELETED
@@ -1,9 +0,0 @@
1
- export { String } from "./String";
2
- export { LiteEvent } from "./LiteEvent";
3
- export { PointF } from "./PointF";
4
- export { Crypto } from "./Crypto";
5
- export { Point } from "./Point";
6
- export { Size } from "./Size";
7
- export { Vector2, Vector3, Vector4, Maths, Color, Quaternion, Delay, enumValues, getStringFromUInt8Array, getUInt32FromUint8Array, } from "../../common/utils/index";
8
- export const Wait = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
9
- export * from "./Animations";
@@ -1,44 +0,0 @@
1
- import { getUInt32FromUint8Array } from "../utils";
2
- import { getStringFromUInt8Array } from "../utils";
3
- /**
4
- * DlcWeaponData - Mapping of WeaponHash -> DlcWeaponData
5
- */
6
- export const DlcWeaponData = new Map();
7
- /**
8
- * Initialize DlcWeaponData, avoid calling expansive native repeatedly
9
- *
10
- */
11
- function initializeOnce() {
12
- let isInitialized = false;
13
- return function () {
14
- if (isInitialized || IsDuplicityVersion()) {
15
- return;
16
- }
17
- // magic number based on struct DlcWeaponData
18
- const intLength = 4;
19
- const strLength = 64;
20
- const weaponCount = GetNumDlcWeapons();
21
- for (let i = 0; i < weaponCount; i++) {
22
- const buffer = new Uint8Array(14 * intLength + 4 * strLength);
23
- // https://docs.fivem.net/natives/?_0x79923CD21BECE14E
24
- Citizen.invokeNative("0x79923CD21BECE14E", i, buffer, Citizen.returnResultAnyway());
25
- // noinspection PointlessArithmeticExpressionJS
26
- const dlcWeaponData = {
27
- validCheck: getUInt32FromUint8Array(buffer, 0 * intLength, 1 * intLength),
28
- weaponHash: getUInt32FromUint8Array(buffer, 2 * intLength, 3 * intLength),
29
- unk: getUInt32FromUint8Array(buffer, 4 * intLength, 5 * intLength),
30
- weaponCost: getUInt32FromUint8Array(buffer, 6 * intLength, 7 * intLength),
31
- ammoCost: getUInt32FromUint8Array(buffer, 8 * intLength, 9 * intLength),
32
- ammoType: getUInt32FromUint8Array(buffer, 10 * intLength, 11 * intLength),
33
- defaultClipSize: getUInt32FromUint8Array(buffer, 12 * intLength, 13 * intLength),
34
- name: getStringFromUInt8Array(buffer, 14 * intLength, 14 * intLength + strLength),
35
- desc: getStringFromUInt8Array(buffer, 14 * intLength + strLength, 14 * intLength + 2 * strLength),
36
- simpleDesc: getStringFromUInt8Array(buffer, 14 * intLength + 2 * strLength, 14 * intLength + 3 * strLength),
37
- upperCaseName: getStringFromUInt8Array(buffer, 14 * intLength + 3 * strLength, 14 * intLength + 4 * strLength),
38
- };
39
- DlcWeaponData.set(dlcWeaponData.weaponHash, dlcWeaponData);
40
- }
41
- isInitialized = true;
42
- };
43
- }
44
- initializeOnce()();
@@ -1,25 +0,0 @@
1
- /**
2
- * Mk2 weapon hash
3
- *
4
- */
5
- export var Mk2WeaponHash;
6
- (function (Mk2WeaponHash) {
7
- // handguns
8
- Mk2WeaponHash[Mk2WeaponHash["PistolMk2"] = 3219281620] = "PistolMk2";
9
- Mk2WeaponHash[Mk2WeaponHash["SNSPistolMk2"] = 2285322324] = "SNSPistolMk2";
10
- Mk2WeaponHash[Mk2WeaponHash["RevolverMk2"] = 3415619887] = "RevolverMk2";
11
- // smg
12
- Mk2WeaponHash[Mk2WeaponHash["SMGMk2"] = 2024373456] = "SMGMk2";
13
- // shotgun
14
- Mk2WeaponHash[Mk2WeaponHash["PumpShotgunMk2"] = 1432025498] = "PumpShotgunMk2";
15
- // assault_rifles
16
- Mk2WeaponHash[Mk2WeaponHash["AssaultRifleMk2"] = 961495388] = "AssaultRifleMk2";
17
- Mk2WeaponHash[Mk2WeaponHash["CarbineRifleMk2"] = 4208062921] = "CarbineRifleMk2";
18
- Mk2WeaponHash[Mk2WeaponHash["SpecialCarbineMk2"] = 2526821735] = "SpecialCarbineMk2";
19
- Mk2WeaponHash[Mk2WeaponHash["BullpupRifleMk2"] = 2228681469] = "BullpupRifleMk2";
20
- // machine_guns
21
- Mk2WeaponHash[Mk2WeaponHash["CombatMGMk2"] = 3686625920] = "CombatMGMk2";
22
- // sniper_rifles
23
- Mk2WeaponHash[Mk2WeaponHash["HeavySniperMk2"] = 177293209] = "HeavySniperMk2";
24
- Mk2WeaponHash[Mk2WeaponHash["MarksmanRifleMk2"] = 1785463520] = "MarksmanRifleMk2";
25
- })(Mk2WeaponHash || (Mk2WeaponHash = {}));
package/weapon/Weapon.js DELETED
@@ -1,270 +0,0 @@
1
- import { WeaponComponentCollection } from "../weaponComponent/WeaponComponentCollection";
2
- import { WeaponHash } from "../hashes";
3
- import { WeaponDisplayNameByHash } from "./WeaponDisplayNameByHash";
4
- import { Game } from "../Game";
5
- import { Model } from "../Model";
6
- import { WeaponHudStats } from "./WeaponHudStats";
7
- import { enumValues } from "../utils";
8
- import { Mk2WeaponHash } from "./Mk2WeaponHash";
9
- import { WeaponComponentHashesByWeaponHash } from "../weaponComponent/WeaponComponentHashesByWeaponHash";
10
- /**
11
- * ped weapon
12
- *
13
- */
14
- export class Weapon {
15
- owner;
16
- components;
17
- hash;
18
- constructor(owner, hash) {
19
- this.owner = owner;
20
- this.hash = hash;
21
- this.components = new WeaponComponentCollection(this.owner, this);
22
- }
23
- /**
24
- * weapon components
25
- *
26
- * @constructor
27
- */
28
- get Components() {
29
- return this.components;
30
- }
31
- /**
32
- * weapon hash
33
- *
34
- * @constructor
35
- */
36
- get Hash() {
37
- return this.hash;
38
- }
39
- /**
40
- * check ped is unarmed or not
41
- *
42
- * @constructor
43
- */
44
- get IsUnarmed() {
45
- return this.hash === WeaponHash.Unarmed;
46
- }
47
- /**
48
- * Check if the ped has the current weapon.
49
- *
50
- * @constructor
51
- */
52
- get IsPresent() {
53
- if (this.IsUnarmed) {
54
- return true;
55
- }
56
- return HasPedGotWeapon(this.owner.Handle, this.hash, false);
57
- }
58
- /**
59
- * get weapon display name / label
60
- *
61
- * @constructor
62
- */
63
- get DisplayName() {
64
- return Weapon.getDisplayNameFromHash(this.hash) ?? "WCT_INVALID";
65
- }
66
- /**
67
- * get weapon localized name
68
- *
69
- * @constructor
70
- */
71
- get LocalizedName() {
72
- return Game.getGXTEntry(this.DisplayName);
73
- }
74
- /**
75
- * get weapon model
76
- *
77
- * @constructor
78
- */
79
- get Model() {
80
- return new Model(GetWeapontypeModel(this.hash));
81
- }
82
- /**
83
- * get weapon tint
84
- *
85
- * @constructor
86
- */
87
- get Tint() {
88
- return GetPedWeaponTintIndex(this.owner.Handle, this.hash);
89
- }
90
- /**
91
- * set weapon tint
92
- *
93
- * @param tint
94
- * @constructor
95
- */
96
- set Tint(tint) {
97
- SetPedWeaponTintIndex(this.owner.Handle, this.hash, tint);
98
- }
99
- /**
100
- * get weapon group
101
- *
102
- * @constructor
103
- */
104
- get Group() {
105
- return GetWeapontypeGroup(this.hash);
106
- }
107
- /**
108
- * get weapon ammo type
109
- *
110
- * @constructor
111
- */
112
- get AmmoType() {
113
- return GetPedAmmoTypeFromWeapon(this.owner.Handle, this.hash);
114
- }
115
- /**
116
- * get weapon ammo count
117
- *
118
- * @constructor
119
- */
120
- get Ammo() {
121
- if (this.IsUnarmed) {
122
- return 1;
123
- }
124
- if (!this.IsPresent) {
125
- return GetPedAmmoByType(this.owner.Handle, this.AmmoType);
126
- }
127
- return GetAmmoInPedWeapon(this.owner.Handle, this.hash);
128
- }
129
- /**
130
- * set weapon ammo count
131
- *
132
- * @param count
133
- * @constructor
134
- */
135
- set Ammo(count) {
136
- if (this.IsUnarmed) {
137
- return;
138
- }
139
- if (this.IsPresent) {
140
- SetPedAmmo(this.owner.Handle, this.hash, count);
141
- }
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
- // GetMaxAmmo
156
- // https://docs.fivem.net/natives/?_0xDC16122C7A20C933
157
- // noinspection UnnecessaryLocalVariableJS
158
- const amount = Citizen.invokeNative("0xDC16122C7A20C933", this.owner.Handle, this.hash, Citizen.pointerValueInt(), Citizen.resultAsInteger());
159
- return amount;
160
- }
161
- /**
162
- * get weapon max ammo in clip
163
- *
164
- * @constructor
165
- */
166
- get MaxAmmoInClip() {
167
- if (this.IsUnarmed) {
168
- return 1;
169
- }
170
- if (!this.IsPresent) {
171
- return 0;
172
- }
173
- return GetMaxAmmoInClip(this.owner.Handle, this.hash, true);
174
- }
175
- /**
176
- * get weapon default clip size
177
- *
178
- * @constructor
179
- */
180
- get DefaultClipSize() {
181
- return GetWeaponClipSize(this.hash);
182
- }
183
- /**
184
- * toggle weapon infinite ammo
185
- *
186
- * @param toggle
187
- * @constructor
188
- */
189
- set InfiniteAmmo(toggle) {
190
- if (this.IsUnarmed) {
191
- return;
192
- }
193
- SetPedInfiniteAmmo(this.owner.Handle, toggle, this.hash);
194
- }
195
- /**
196
- * toggle ped infinite ammo clip on all weapons
197
- *
198
- * @param toggle
199
- * @constructor
200
- */
201
- set InfiniteAmmoClip(toggle) {
202
- SetPedInfiniteAmmoClip(this.owner.Handle, toggle);
203
- }
204
- /**
205
- * check weapon can use on parachute
206
- *
207
- * @constructor
208
- */
209
- get CanUseOnParachute() {
210
- return CanUseWeaponOnParachute(this.hash);
211
- }
212
- /**
213
- * Check weapon is Mk2 or not
214
- *
215
- * @constructor
216
- */
217
- get IsMk2() {
218
- return Array.from(enumValues(Mk2WeaponHash)).some((x) => x === this.hash);
219
- }
220
- /**
221
- * set weapon livery, only work for Mk2 weapon
222
- *
223
- * @param liveryId
224
- * @param colorId
225
- */
226
- setLivery(liveryId, colorId) {
227
- if (!this.IsMk2) {
228
- console.log(`[ERROR]${this.setLivery.name} failed. Reason: non-Mk2 weapon`);
229
- return;
230
- }
231
- const component = this.Components.getMk2CamoComponent(liveryId);
232
- if (component.IsInvalid) {
233
- console.log(`[ERROR]${this.setLivery.name} failed. Reason: invalid liveryId/Component`);
234
- return;
235
- }
236
- component.Active = true;
237
- SetPedWeaponLiveryColor(this.owner.Handle, this.hash, component.ComponentHash, colorId);
238
- }
239
- /**
240
- * get weapon hud stats
241
- *
242
- * @constructor
243
- */
244
- get HudStats() {
245
- return WeaponHudStats.get(this.hash);
246
- }
247
- /**
248
- * get weapon display name / label by hash
249
- *
250
- * @param hash
251
- */
252
- static getDisplayNameFromHash(hash) {
253
- if (!hash) {
254
- return "WT_INVALID";
255
- }
256
- return WeaponDisplayNameByHash.get(hash) ?? "WCT_INVALID";
257
- }
258
- /**
259
- * get component hashes belongs to weapon
260
- *
261
- * @param hash
262
- */
263
- static getWeaponComponentHashes(hash) {
264
- const hashes = WeaponComponentHashesByWeaponHash.get(hash);
265
- if (!hashes) {
266
- return [];
267
- }
268
- return [...hashes];
269
- }
270
- }
@@ -1,84 +0,0 @@
1
- import { Weapon } from "./Weapon";
2
- import { Game } from "../Game";
3
- import { Wait } from "../utils";
4
- /**
5
- * weapon asset
6
- *
7
- */
8
- export class WeaponAsset {
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
- }
@@ -1,187 +0,0 @@
1
- import { Weapon } from "./Weapon";
2
- import { Prop } from "../models";
3
- /**
4
- * ped weapons
5
- *
6
- */
7
- export class WeaponCollection {
8
- owner;
9
- weapons = new Map();
10
- constructor(owner) {
11
- this.owner = owner;
12
- }
13
- [Symbol.iterator]() {
14
- let pointer = 0;
15
- const weapons = Array.from(this.weapons.values());
16
- return {
17
- next() {
18
- if (pointer < weapons.length) {
19
- return { done: false, value: weapons[pointer++] };
20
- }
21
- else {
22
- return { done: true, value: null };
23
- }
24
- },
25
- };
26
- }
27
- /**
28
- * get weapon by hash
29
- *
30
- * @param hash
31
- */
32
- get(hash) {
33
- let weapon = this.weapons.get(hash);
34
- if (!weapon) {
35
- if (!this.hasWeapon(hash)) {
36
- return null;
37
- }
38
- weapon = this.createAndAddWeapon(hash);
39
- }
40
- return weapon;
41
- }
42
- /**
43
- * get ped current weapon
44
- *
45
- * @constructor
46
- */
47
- get Current() {
48
- const [, hash] = GetCurrentPedWeapon(this.owner.Handle, true);
49
- if (this.weapons.has(hash)) {
50
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
51
- return this.weapons.get(hash);
52
- }
53
- else {
54
- return this.createAndAddWeapon(hash);
55
- }
56
- }
57
- /**
58
- * get ped current weapon object
59
- *
60
- * @constructor
61
- */
62
- get CurrentWeaponObject() {
63
- if (this.Current.IsUnarmed) {
64
- return null;
65
- }
66
- return new Prop(GetCurrentPedWeaponEntityIndex(this.owner.Handle));
67
- }
68
- /**
69
- * get ped best weapon
70
- *
71
- * @constructor
72
- */
73
- get BestWeapon() {
74
- const hash = GetBestPedWeapon(this.owner.Handle, false);
75
- if (this.weapons.has(hash)) {
76
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
77
- return this.weapons.get(hash);
78
- }
79
- else {
80
- return this.createAndAddWeapon(hash);
81
- }
82
- }
83
- /**
84
- * check ped has weapon
85
- *
86
- * @param hash
87
- */
88
- hasWeapon(hash) {
89
- return HasPedGotWeapon(this.owner.Handle, hash, false);
90
- }
91
- /**
92
- * check weapon is valid
93
- *
94
- * @param hash
95
- */
96
- isWeaponValid(hash) {
97
- return IsWeaponValid(hash);
98
- }
99
- /**
100
- * give weapon to ped
101
- *
102
- * @param hash
103
- * @param ammoCount
104
- * @param equipNow
105
- * @param isAmmoLoaded
106
- */
107
- give(hash, ammoCount, equipNow, isAmmoLoaded) {
108
- let weapon = this.weapons.get(hash);
109
- if (!weapon) {
110
- weapon = this.createAndAddWeapon(hash);
111
- }
112
- if (weapon.IsPresent) {
113
- this.select(weapon);
114
- }
115
- else {
116
- GiveWeaponToPed(this.owner.Handle, weapon.Hash, ammoCount, equipNow, isAmmoLoaded);
117
- }
118
- return weapon;
119
- }
120
- /**
121
- * set ped current weapon on hand
122
- *
123
- * @param weapon
124
- */
125
- select(weapon) {
126
- if (weapon instanceof Weapon) {
127
- if (!weapon.IsPresent) {
128
- return false;
129
- }
130
- SetCurrentPedWeapon(this.owner.Handle, weapon.Hash, true);
131
- return true;
132
- }
133
- else {
134
- if (!this.hasWeapon(weapon)) {
135
- return false;
136
- }
137
- SetCurrentPedWeapon(this.owner.Handle, weapon, true);
138
- return true;
139
- }
140
- }
141
- /**
142
- * remove weapon from ped
143
- *
144
- * @param weapon
145
- */
146
- remove(weapon) {
147
- if (weapon instanceof Weapon) {
148
- if (this.weapons.has(weapon.Hash)) {
149
- this.weapons.delete(weapon.Hash);
150
- }
151
- this.remove(weapon.Hash);
152
- }
153
- else {
154
- RemoveWeaponFromPed(this.owner.Handle, weapon);
155
- }
156
- }
157
- /**
158
- * remove all weapons from ped
159
- *
160
- */
161
- removeAll() {
162
- RemoveAllPedWeapons(this.owner.Handle, true);
163
- this.weapons.clear();
164
- }
165
- /**
166
- * Drop ped current weapon?
167
- * todo: this native seems does not work as expected, need to investigate
168
- * refer1: https://docs.fivem.net/natives/?_0x6B7513D9966FBEC0
169
- * refer2: https://forum.cfx.re/t/release-weapondrop/49856/8
170
- *
171
- */
172
- drop() {
173
- SetPedDropsWeapon(this.owner.Handle);
174
- }
175
- /**
176
- * create weapon object and add to collection
177
- *
178
- * @param hash
179
- * @private
180
- */
181
- createAndAddWeapon(hash) {
182
- const uintHash = hash >>> 0;
183
- const weapon = new Weapon(this.owner, uintHash);
184
- this.weapons.set(uintHash, weapon);
185
- return weapon;
186
- }
187
- }