@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.
- package/Audio.d.ts +2 -2
- package/Audio.js +99 -0
- package/Blip.d.ts +4 -3
- package/Blip.js +113 -0
- package/Camera.d.ts +3 -3
- package/Camera.js +190 -0
- package/Checkpoint.d.ts +2 -2
- package/Checkpoint.js +51 -0
- package/Events.js +80 -0
- package/Game.d.ts +10 -3
- package/Game.js +478 -0
- package/GameplayCamera.d.ts +2 -2
- package/GameplayCamera.js +152 -0
- package/Model.js +210 -0
- package/NetworkedScene.d.ts +2 -1
- package/NetworkedScene.js +50 -0
- package/ParticleEffect.d.ts +4 -3
- package/ParticleEffect.js +128 -0
- package/ParticleEffectAsset.d.ts +2 -2
- package/ParticleEffectAsset.js +133 -0
- package/Pickup.d.ts +1 -1
- package/Pickup.js +27 -0
- package/Raycast.d.ts +5 -3
- package/Raycast.js +132 -0
- package/RelationshipGroup.d.ts +1 -1
- package/RelationshipGroup.js +72 -0
- package/Rope.d.ts +1 -1
- package/Rope.js +149 -0
- package/TaskSequence.js +52 -0
- package/Tasks.d.ts +8 -3
- package/Tasks.js +334 -0
- package/World.d.ts +13 -4
- package/World.js +945 -0
- package/cfx/StateBagChangeHandler.js +0 -0
- package/cfx/index.d.ts +1 -1
- package/cfx/index.js +4 -0
- package/common/Command.js +111 -0
- package/common/Convar.js +58 -0
- package/common/GlobalData.js +16 -0
- package/common/Kvp.js +137 -0
- package/common/Resource.js +54 -0
- package/common/decors/Events.js +170 -0
- package/common/net/NetworkedMap.js +225 -0
- package/common/types.js +0 -0
- package/common/utils/ClassTypes.js +15 -0
- package/common/utils/Color.js +33 -0
- package/common/utils/Delay.d.ts +1 -0
- package/common/utils/Delay.js +6 -0
- package/common/utils/Maths.js +18 -0
- package/common/utils/Point.d.ts +9 -0
- package/common/utils/Point.js +36 -0
- package/common/utils/PointF.d.ts +1 -1
- package/common/utils/PointF.js +18 -0
- package/common/utils/Quaternion.d.ts +1 -1
- package/common/utils/Quaternion.js +33 -0
- package/common/utils/Vector.js +589 -0
- package/common/utils/cleanPlayerName.js +17 -0
- package/common/utils/enumValues.js +20 -0
- package/common/utils/getStringFromUInt8Array.js +6 -0
- package/common/utils/getUInt32FromUint8Array.js +6 -0
- package/enums/Alignment.js +9 -0
- package/enums/AnimationFlags.js +38 -0
- package/enums/AudioFlag.js +41 -0
- package/enums/BadgeStyle.js +186 -0
- package/enums/Blip.js +229 -0
- package/enums/Bone.js +105 -0
- package/enums/CameraShake.js +17 -0
- package/enums/CameraTypes.js +11 -0
- package/enums/CheckboxStyle.js +8 -0
- package/enums/Checkpoint.js +68 -0
- package/enums/CloudHat.js +27 -0
- package/enums/Control.js +364 -0
- package/enums/CursorSprite.js +18 -0
- package/enums/Driving.js +38 -0
- package/enums/ExplosionType.js +45 -0
- package/enums/FiringPattern.js +23 -0
- package/enums/Font.js +11 -0
- package/enums/ForceType.js +12 -0
- package/enums/Gender.js +8 -0
- package/enums/HelmetType.js +9 -0
- package/enums/HudColor.js +187 -0
- package/enums/HudComponent.js +57 -0
- package/enums/InputMode.js +8 -0
- package/enums/InvertAxis.js +10 -0
- package/enums/Language.js +18 -0
- package/enums/LeaveVehicleFlags.js +14 -0
- package/enums/LoadingSpinnerType.js +11 -0
- package/enums/MarkerType.js +48 -0
- package/enums/MenuAlignment.js +8 -0
- package/enums/NotificationType.js +14 -0
- package/enums/Parachute.js +19 -0
- package/enums/PickupType.js +77 -0
- package/enums/RadioStation.js +28 -0
- package/enums/RagdollType.js +10 -0
- package/enums/RaycastEnums.js +33 -0
- package/enums/Relationship.js +13 -0
- package/enums/RopeType.js +9 -0
- package/enums/ScreenEffect.js +87 -0
- package/enums/SpeechModifier.js +43 -0
- package/enums/Vehicle.js +396 -0
- package/enums/Weather.js +22 -0
- package/enums/ZoneID.js +95 -0
- package/hashes/MaterialHash.js +220 -0
- package/hashes/PedHash.js +728 -0
- package/hashes/VehicleHash.js +526 -0
- package/hashes/WeaponHash.js +155 -0
- package/hashes/WeatherTypeHash.js +22 -0
- package/index.js +166 -18794
- package/interfaces/Dimensions.d.ts +1 -1
- package/interfaces/Dimensions.js +0 -0
- package/models/BaseEntity.d.ts +10 -8
- package/models/BaseEntity.js +576 -0
- package/models/Entity.d.ts +0 -1
- package/models/Entity.js +0 -0
- package/models/EntityBone.d.ts +1 -1
- package/models/EntityBone.js +32 -0
- package/models/EntityBoneCollection.d.ts +1 -1
- package/models/EntityBoneCollection.js +27 -0
- package/models/Ped.d.ts +13 -5
- package/models/Ped.js +711 -0
- package/models/PedBone.d.ts +3 -2
- package/models/PedBone.js +18 -0
- package/models/PedBoneCollection.d.ts +3 -1
- package/models/PedBoneCollection.js +31 -0
- package/models/Player.d.ts +4 -2
- package/models/Player.js +188 -0
- package/models/Prop.d.ts +1 -1
- package/models/Prop.js +34 -0
- package/models/Vehicle.d.ts +9 -4
- package/models/Vehicle.js +582 -0
- package/models/VehicleDoor.d.ts +1 -1
- package/models/VehicleDoor.js +52 -0
- package/models/VehicleDoorCollection.d.ts +1 -1
- package/models/VehicleDoorCollection.js +66 -0
- package/models/VehicleMod.d.ts +1 -1
- package/models/VehicleMod.js +43 -0
- package/models/VehicleModCollection.d.ts +2 -2
- package/models/VehicleModCollection.js +227 -0
- package/models/VehicleToggleMod.d.ts +1 -1
- package/models/VehicleToggleMod.js +37 -0
- package/models/VehicleWheel.js +31 -0
- package/models/VehicleWheelCollection.d.ts +1 -1
- package/models/VehicleWheelCollection.js +61 -0
- package/models/VehicleWindow.d.ts +1 -1
- package/models/VehicleWindow.js +43 -0
- package/models/VehicleWindowCollection.d.ts +1 -1
- package/models/VehicleWindowCollection.js +62 -0
- package/package.json +2 -2
- package/ui/Container.d.ts +4 -2
- package/ui/Container.js +39 -0
- package/ui/Effects.d.ts +1 -1
- package/ui/Effects.js +112 -0
- package/ui/Fading.js +74 -0
- package/ui/Hud.d.ts +3 -2
- package/ui/Hud.js +47 -0
- package/ui/InstructionalButtons.js +42 -0
- package/ui/LoadingPrompt.d.ts +1 -1
- package/ui/LoadingPrompt.js +37 -0
- package/ui/Notification.js +17 -0
- package/ui/Rectangle.d.ts +4 -2
- package/ui/Rectangle.js +46 -0
- package/ui/Scaleform.d.ts +2 -1
- package/ui/Scaleform.js +240 -0
- package/ui/Screen.d.ts +6 -3
- package/ui/Screen.js +83 -0
- package/ui/Sprite.d.ts +3 -1
- package/ui/Sprite.js +70 -0
- package/ui/Text.d.ts +6 -3
- package/ui/Text.js +119 -0
- package/ui/Timerbar.js +241 -0
- package/ui/interfaces/IButton.d.ts +1 -1
- package/ui/interfaces/IButton.js +0 -0
- package/ui/interfaces/IDrawable.d.ts +3 -1
- package/ui/interfaces/IDrawable.js +0 -0
- package/ui/menu/Menu.d.ts +9 -4
- package/ui/menu/Menu.js +830 -0
- package/ui/menu/MenuControl.js +20 -0
- package/ui/menu/MenuControls.js +17 -0
- package/ui/menu/MenuSettings.d.ts +1 -1
- package/ui/menu/MenuSettings.js +57 -0
- package/ui/menu/items/UIMenuCheckboxItem.d.ts +3 -3
- package/ui/menu/items/UIMenuCheckboxItem.js +70 -0
- package/ui/menu/items/UIMenuItem.d.ts +10 -4
- package/ui/menu/items/UIMenuItem.js +1103 -0
- package/ui/menu/items/UIMenuListItem.d.ts +3 -3
- package/ui/menu/items/UIMenuListItem.js +118 -0
- package/ui/menu/items/UIMenuSeparatorItem.d.ts +1 -1
- package/ui/menu/items/UIMenuSeparatorItem.js +37 -0
- package/ui/menu/items/UIMenuSliderItem.d.ts +4 -3
- package/ui/menu/items/UIMenuSliderItem.js +180 -0
- package/ui/menu/items/panels/AbstractUIMenuPanel.d.ts +4 -3
- package/ui/menu/items/panels/AbstractUIMenuPanel.js +49 -0
- package/ui/menu/items/panels/UIMenuColorPanel.d.ts +3 -3
- package/ui/menu/items/panels/UIMenuColorPanel.js +215 -0
- package/ui/menu/items/panels/UIMenuGridPanel.d.ts +3 -3
- package/ui/menu/items/panels/UIMenuGridPanel.js +216 -0
- package/ui/menu/items/panels/UIMenuPercentagePanel.d.ts +2 -2
- package/ui/menu/items/panels/UIMenuPercentagePanel.js +138 -0
- package/ui/menu/items/panels/UIMenuStatisticsPanel.d.ts +3 -2
- package/ui/menu/items/panels/UIMenuStatisticsPanel.js +88 -0
- package/ui/menu/items/panels/UIMenuStatisticsPanelItem.d.ts +2 -1
- package/ui/menu/items/panels/UIMenuStatisticsPanelItem.js +48 -0
- package/ui/menu/modules/ListItem.js +18 -0
- package/utils/Animations.js +43 -0
- package/utils/Crypto.js +33 -0
- package/utils/LiteEvent.js +25 -0
- package/utils/Maths.js +18 -0
- package/utils/Point.js +36 -0
- package/utils/Size.js +16 -0
- package/utils/String.d.ts +1 -1
- package/utils/String.js +35 -0
- package/weapon/DlcWeaponData.d.ts +1 -1
- package/weapon/DlcWeaponData.js +40 -0
- package/weapon/Mk2WeaponHash.js +18 -0
- package/weapon/Weapon.d.ts +7 -7
- package/weapon/Weapon.js +276 -0
- package/weapon/WeaponAsset.d.ts +1 -1
- package/weapon/WeaponAsset.js +87 -0
- package/weapon/WeaponCollection.d.ts +3 -2
- package/weapon/WeaponCollection.js +179 -0
- package/weapon/WeaponDisplayNameByHash.d.ts +1 -1
- package/weapon/WeaponDisplayNameByHash.js +73 -0
- package/weapon/WeaponGroup.js +22 -0
- package/weapon/WeaponHudStats.d.ts +1 -1
- package/weapon/WeaponHudStats.js +33 -0
- package/weapon/WeaponLivery.js +17 -0
- package/weapon/WeaponLiveryColor.js +38 -0
- package/weapon/WeaponTint.js +46 -0
- package/weaponComponent/ComponentAttachmentPoint.js +22 -0
- package/weaponComponent/ComponentAttachmentPointByHash.js +307 -0
- package/weaponComponent/ComponentDisplayNameByHash.js +278 -0
- package/weaponComponent/DlcWeaponComponentData.js +40 -0
- package/weaponComponent/InvalidWeaponComponent.d.ts +1 -1
- package/weaponComponent/InvalidWeaponComponent.js +31 -0
- package/weaponComponent/WeaponComponent.d.ts +4 -4
- package/weaponComponent/WeaponComponent.js +124 -0
- package/weaponComponent/WeaponComponentCollection.d.ts +2 -2
- package/weaponComponent/WeaponComponentCollection.js +187 -0
- package/weaponComponent/WeaponComponentHash.js +670 -0
- package/weaponComponent/WeaponComponentHashesByWeaponHash.d.ts +1 -1
- package/weaponComponent/WeaponComponentHashesByWeaponHash.js +864 -0
- package/weaponComponent/WeaponComponentHudStats.js +33 -0
- package/common/index.d.ts +0 -8
- package/common/utils/Vector2.d.ts +0 -1
- package/common/utils/Vector3.d.ts +0 -1
- package/common/utils/Vector4.d.ts +0 -1
- package/common/utils/index.d.ts +0 -12
- package/enums/index.d.ts +0 -42
- package/hashes/index.d.ts +0 -5
- package/index.d.ts +0 -25
- package/models/index.d.ts +0 -18
- package/ui/index.d.ts +0 -15
- package/ui/interfaces/index.d.ts +0 -2
- package/ui/menu/index.d.ts +0 -6
- package/ui/menu/items/index.d.ts +0 -6
- package/ui/menu/items/panels/index.d.ts +0 -6
- package/ui/menu/modules/index.d.ts +0 -1
- package/utils/PointF.d.ts +0 -7
- package/utils/Quaternion.d.ts +0 -10
- package/utils/enumValues.d.ts +0 -12
- package/utils/getStringFromUInt8Array.d.ts +0 -8
- package/utils/getUInt32FromUint8Array.d.ts +0 -8
- package/utils/index.d.ts +0 -9
- package/weapon/index.d.ts +0 -8
- 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
package/utils/String.js
ADDED
|
@@ -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
|
+
};
|
|
@@ -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
|
+
};
|
package/weapon/Weapon.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import type {
|
|
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 {
|
|
10
|
-
import type { WeaponComponentHash } from "../weaponComponent";
|
|
10
|
+
import type { WeaponTint } from "./WeaponTint";
|
|
11
11
|
/**
|
|
12
12
|
* ped weapon
|
|
13
13
|
*
|
package/weapon/Weapon.js
ADDED
|
@@ -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
|
+
};
|
package/weapon/WeaponAsset.d.ts
CHANGED
|
@@ -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
|
*
|