class Weapon
package fivem.client.natives
Static methods
staticAddAmmoToPedByType(ped:Dynamic, ammoType:Int, ammo:Int):Dynamic
staticCreateAirDefenseArea(p0:Float, p1:Float, p2:Float, p3:Float, p4:Float, p5:Float, p6:Float, p7:Float, p8:Float, p9:Float, weaponHash:Int):Int
staticCreateAirDefenseSphere(x:Float, y:Float, z:Float, radius:Float, p4:Float, p5:Float, p6:Float, weaponHash:Int):Int
Both coordinates are from objects in the decompiled scripts.
Native related to _0xECDC202B25E5CF48 p1 value. The only weapon hash used in the decompiled scripts is weapon_air_defence_gun. These two natives are used by the yacht script, decompiled scripts suggest it and the weapon hash used (valkyrie's rockets) are also used by yachts.
staticDoesAirDefenseZoneExist(zoneId:Int):Bool
staticFireAirDefenseWeapon(zoneId:Int, x:Float, y:Float, z:Float):Dynamic
staticGetMaxAmmoByType(ped:Dynamic, ammoType:Int, ammo:Dynamic):Bool
staticGetPedAmmoTypeFromWeapon2(ped:Dynamic, weaponHash:Int):Int
Returns the base/default ammo type of the specified ped's specified weapon.
Use GET_PED_AMMO_TYPE_FROM_WEAPON if you want current ammo type (like AMMO_MG_INCENDIARY/AMMO_MG_TRACER while using MkII magazines) and use this if you want base ammo type. (AMMO_MG)staticGetPedWeaponLiveryColor(ped:Dynamic, weaponHash:Int, camoComponentHash:Int):Int
staticGetWeaponComponentVariantExtraComponentCount(componentHash:Int):Int
staticGetWeaponComponentVariantExtraComponentModel(componentHash:Int, extraComponentIndex:Int):Int
staticGetWeaponObjectLiveryColor(weaponObject:Dynamic, camoComponentHash:Int):Int
staticGetWeaponTimeBetweenShots(weaponHash:Int):Float
staticGiveLoadoutToPed(ped:Dynamic, loadoutHash:Int):Dynamic
List of all available loadouts:
LOADOUT_DEFAULT
LOADOUT_ANIMAL
LOADOUT_COUGAR
LOADOUT_HILLBILLY
LOADOUT_CULT
LOADOUT_CHEAT_0
LOADOUT_CHEAT_1
LOADOUT_GUARD
LOADOUT_NETWORK_BOT
LOADOUT_LOST
LOADOUT_LOST_L1
LOADOUT_LOST_L2
LOADOUT_LOST_L3
LOADOUT_MEXICAN
LOADOUT_MEXICAN_L1
LOADOUT_MEXICAN_L2
LOADOUT_MEXICAN_L3
LOADOUT_FAMILY
LOADOUT_ASIAN
LOADOUT_SECUR
LOADOUT_POLICE_GUARD
LOADOUT_COP
LOADOUT_COP_L1
LOADOUT_COP_L2
LOADOUT_COP_L3
LOADOUT_SWAT
LOADOUT_SWAT_NO_LASER
LOADOUT_COP_SHOTGUN
LOADOUT_FIREMAN
LOADOUT_COP_HELI
LOADOUT_COP_BOAT
LOADOUT_ARMY
LOADOUT_ANIMAL_RETRIEVER
LOADOUT_SMALL_DOG
LOADOUT_TIGER_SHARK
LOADOUT_HAMMERHEAD_SHARK
LOADOUT_KILLER_WHALE
LOADOUT_BOAR
LOADOUT_PIG
LOADOUT_COYOTE
LOADOUT_DEER
LOADOUT_HEN
LOADOUT_RABBIT
LOADOUT_CAT
LOADOUT_COWstaticIsAnyAirDefenseZoneInsideSphere(x:Float, y:Float, z:Float, radius:Float, SphereIndex:Dynamic):Bool
staticRemoveAirDefenseZone(zoneId:Int):Bool
staticRemoveAllAirDefenseZones():Dynamic
staticSetCanPedEquipAllWeapons(ped:Dynamic, toggle:Bool):Dynamic
Does the same as _SET_CAN_PED_SELECT_WEAPON except for all weapons.
staticSetCanPedEquipWeapon(ped:Dynamic, weaponHash:Int, toggle:Bool):Dynamic
Disables selecting the given weapon. Ped isn't forced to put the gun away. However you can't reselect the weapon if you holster then unholster. Weapon is also grayed out on the weapon wheel.
staticSetFlashLightEnabled(ped:Dynamic, toggle:Bool):Dynamic
Enables/disables flashlight on ped's weapon.
NativeDB Introduced: v2060staticSetPedWeaponLiveryColor(ped:Dynamic, weaponHash:Int, camoComponentHash:Int, colorIndex:Int):Dynamic
staticSetPlayerAirDefenseZoneFlag(player:Dynamic, zoneId:Int, enable:Bool):Dynamic
staticSetWeaponDamageModifier(weaponHash:Int, damageMultiplier:Float):Dynamic
Changes the weapon damage output by the given multiplier value. Does NOT need to be called every frame.
staticSetWeaponExplosionRadiusMultiplier(weaponHash:Int, multiplier:Float):Dynamic
NativeDB Introduced: v2372staticSetWeaponObjectLiveryColor(weaponObject:Dynamic, camoComponentHash:Int, colorIndex:Int):Dynamic
staticaddAmmoToPed(ped:Dynamic, weaponHash:Int, ammo:Int):Dynamic
staticcanUseWeaponOnParachute(weaponHash:Int):Bool
this returns if you can use the weapon while using a parachute staticclearEntityLastWeaponDamage(entity:Dynamic):Dynamic
staticclearPedLastWeaponDamage(ped:Dynamic):Dynamic
Does NOT seem to work with HAS_PED_BEEN_DAMAGED_BY_WEAPON. Use CLEAR_ENTITY_LAST_WEAPON_DAMAGE and HAS_ENTITY_BEEN_DAMAGED_BY_WEAPON instead.
staticcreateWeaponObject(weaponHash:Int, ammoCount:Int, x:Float, y:Float, z:Float, bCreateDefaultComponents:Bool, scale:Float, customModelHash:Int):Dynamic
Create a weapon object that cannot be attached to a ped. If you want to create a weapon object that can be attached to a ped, use CREATE_OBJECT instead.
NativeDB Added Parameter 9: BOOL bRegisterAsNetworkObject
NativeDB Added Parameter 10: BOOL bScriptHostObjectstaticdoesWeaponTakeWeaponComponent(weaponHash:Int, componentHash:Int):Bool
staticenableLaserSightRendering(toggle:Bool):Dynamic
Enables laser sight on any weapon.
It doesn't work. Neither on tick nor OnKeyDown staticexplodeProjectiles(ped:Dynamic, weaponHash:Int, p2:Bool):Dynamic
WEAPON::EXPLODE_PROJECTILES(PLAYER::PLAYER_PED_ID(), func_221(0x00000003), 0x00000001); staticgetAmmoInClip(ped:Dynamic, weaponHash:Int, ammo:Dynamic):Bool
staticgetAmmoInPedWeapon(ped:Dynamic, weaponhash:Int):Int
WEAPON::GET_AMMO_IN_PED_WEAPON(PLAYER::PLAYER_PED_ID(), a_0)
From decompiled scripts
Returns total ammo in weapon
GTALua Example :
natives.WEAPON.GET_AMMO_IN_PED_WEAPON(plyPed, WeaponHash) staticgetBestPedWeapon(ped:Dynamic, ignoreAmmoCount:Bool):Int
staticgetCurrentPedVehicleWeapon(ped:Dynamic, weaponHash:Dynamic):Bool
staticgetCurrentPedWeapon(ped:Dynamic, weaponHash:Dynamic, p2:Bool):Bool
The return value seems to indicate returns true if the hash of the weapon object weapon equals the weapon hash.
p2 seems to be 1 most of the time; and is not implemented.staticgetIsPedGadgetEquipped(ped:Dynamic, gadgetHash:Int):Bool
gadgetHash - was always 0xFBAB5776 ("GADGET_PARACHUTE"). staticgetLockonDistanceOfCurrentPedWeapon(ped:Dynamic):Float
staticgetMaxAmmo(ped:Dynamic, weaponHash:Int, ammo:Dynamic):Bool
staticgetMaxRangeOfCurrentPedWeapon(ped:Dynamic):Float
staticgetPedAmmoByType(ped:Dynamic, ammoType:Int):Int
staticgetPedAmmoTypeFromWeapon(ped:Dynamic, weaponHash:Int):Int
Returns the current ammo type of the specified ped's specified weapon.
MkII magazines will change the return value, like Pistol MkII returning AMMO_PISTOL without any components and returning AMMO_PISTOL_TRACER after Tracer Rounds component is attached.
Use 0xF489B44DD5AF4BD9 if you always want AMMO_PISTOL.staticgetPedLastWeaponImpactCoord(ped:Dynamic, coords:Dynamic):Bool
Pass ped. Pass address of Vector3.
The coord will be put into the Vector3.
The return will determine whether there was a coord found or not. staticgetPedWeaponTintIndex(ped:Dynamic, weaponHash:Int):Int
staticgetPedWeapontypeInSlot(ped:Dynamic, weaponSlot:Int):Int
staticgetSelectedPedWeapon(ped:Dynamic):Int
staticgetWeaponClipSize(weaponHash:Int):Int
// Returns the size of the default weapon component clip.
Use it like this:
char cClipSize[32];
Hash cur;
if (WEAPON::GET_CURRENT_PED_WEAPON(playerPed, &cur, 1))
{
if (WEAPON::IS_WEAPON_VALID(cur))
{
int iClipSize = WEAPON::GET_WEAPON_CLIP_SIZE(cur);
sprintf_s(cClipSize, "ClipSize: %.d", iClipSize);
vDrawString(cClipSize, 0.5f, 0.5f);
}
} staticgetWeaponComponentHudStats(componentHash:Int, outData:Dynamic):Bool
staticgetWeaponComponentTypeModel(componentHash:Int):Int
staticgetWeaponDamage(weaponHash:Int, componentHash:Int):Float
This native does not return damages of weapons from the melee and explosive group.
staticgetWeaponDamageType(weaponHash:Int):Int
0=unknown (or incorrect weaponHash)
1= no damage (flare,snowball, petrolcan)
2=melee
3=bullet
4=force ragdoll fall
5=explosive (RPG, Railgun, grenade)
6=fire(molotov)
8=fall(WEAPON_HELI_CRASH)
10=electric
11=barbed wire
12=extinguisher
13=gas
14=water cannon(WEAPON_HIT_BY_WATER_CANNON) staticgetWeaponHudStats(weaponHash:Int, outData:Dynamic):Bool
// members should be aligned to 8 bytes by default but it's best to use alignas here, just to be sure
struct WeaponHudStatsData
{
alignas(8) uint8_t hudDamage; // 0x0000
alignas(8) uint8_t hudSpeed; // 0x0008
alignas(8) uint8_t hudCapacity; // 0x0010
alignas(8) uint8_t hudAccuracy; // 0x0018
alignas(8) uint8_t hudRange; // 0x0020
};
Usage:
WeaponHudStatsData data;
if (GET_WEAPON_HUD_STATS(weaponHash, (Any*)&data))
{
// uint8_t damagePercentage = data.hudDamage etc...
} staticgetWeaponObjectFromPed(ped:Dynamic, p1:Bool):Dynamic
Drops the current weapon and returns the object
Unknown behavior when unarmed. staticgetWeaponObjectTintIndex(weapon:Dynamic):Int
staticgetWeaponTintCount(weaponHash:Int):Int
staticgetWeapontypeGroup(weaponHash:Int):Int
Gets and returns the hash of the group of the specified weapon (group names can be found/changed under "Group" in the weapons' meta file). Note that the group is not the same as the location on the weapon wheel.
staticgetWeapontypeModel(weaponHash:Int):Int
Returns the model of any weapon.
Can also take an ammo hash?
sub_6663a(&l_115B, WEAPON::GET_WEAPONTYPE_MODEL(${ammo_rpg})); staticgetWeapontypeSlot(weaponHash:Int):Int
staticgiveDelayedWeaponToPed(ped:Dynamic, weaponHash:Int, ammoCount:Int, bForceInHand:Bool):Dynamic
Gives a weapon to PED with a delay, example:
WEAPON::GIVE_DELAYED_WEAPON_TO_PED(PED::PLAYER_PED_ID(), MISC::GET_HASH_KEY("WEAPON_PISTOL"), 1000, false)staticgiveWeaponComponentToPed(ped:Dynamic, weaponHash:Int, componentHash:Int):Dynamic
staticgiveWeaponComponentToWeaponObject(weaponObject:Dynamic, addonHash:Int):Dynamic
addonHash:
(use WEAPON::GET_WEAPON_COMPONENT_TYPE_MODEL() to get hash value)
${component_at_ar_flsh}, ${component_at_ar_supp}, ${component_at_pi_flsh}, ${component_at_scope_large}, ${component_at_ar_supp_02}staticgiveWeaponObjectToPed(weaponObject:Dynamic, ped:Dynamic):Dynamic
staticgiveWeaponToPed(ped:Dynamic, weaponHash:Int, ammoCount:Int, isHidden:Bool, bForceInHand:Bool):Dynamic
statichasEntityBeenDamagedByWeapon(entity:Dynamic, weaponHash:Int, weaponType:Int):Bool
It determines what weapons caused damage:
If you want to define only a specific weapon, second parameter=weapon hash code, third parameter=0
If you want to define any melee weapon, second parameter=0, third parameter=1.
If you want to identify any weapon (firearms, melee, rockets, etc.), second parameter=0, third parameter=2.statichasPedBeenDamagedByWeapon(ped:Dynamic, weaponHash:Int, weaponType:Int):Bool
It determines what weapons caused damage:
If you want to define only a specific weapon, second parameter=weapon hash code, third parameter=0
If you want to define any melee weapon, second parameter=0, third parameter=1.
If you want to identify any weapon (firearms, melee, rockets, etc.), second parameter=0, third parameter=2. statichasPedGotWeapon(ped:Dynamic, weaponHash:Int, p2:Bool):Bool
p2 should be FALSE, otherwise it seems to always return FALSE
Bool does not check if the weapon is current equipped, unfortunately. statichasPedGotWeaponComponent(ped:Dynamic, weaponHash:Int, componentHash:Int):Bool
statichasVehicleGotProjectileAttached(driver:Dynamic, vehicle:Dynamic, weaponHash:Int, p3:Dynamic):Bool
Third Parameter = unsure, but pretty sure it is weapon hash
--> get_hash_key("weapon_stickybomb")
Fourth Parameter = unsure, almost always -1 statichasWeaponAssetLoaded(weaponHash:Int):Bool
statichasWeaponGotWeaponComponent(weapon:Dynamic, addonHash:Int):Bool
statichidePedWeaponForScriptedCutscene(ped:Dynamic, toggle:Bool):Dynamic
Hides the players weapon during a cutscene. staticisFlashLightOn(ped:Dynamic):Bool
staticisPedArmed(ped:Dynamic, typeFlags:Int):Bool
Checks if the ped is currently equipped with a weapon matching a bit specified using a bitwise-or in typeFlags.
| Bit value | Effect |
|---|---|
| 1 | Melee weapons |
| 2 | Explosive weapons |
| 4 | Any other weapons |
| Not specifying any bit will lead to the native always returning 'false', and for example specifying '4 | 2' will check for any weapon except fists and melee weapons. |
|---|
staticisPedCurrentWeaponSilenced(ped:Dynamic):Bool
This native returns a true or false value.
Ped ped = The ped whose weapon you want to check. staticisPedWeaponComponentActive(ped:Dynamic, weaponHash:Int, componentHash:Int):Bool
staticisPedWeaponReadyToShoot(ped:Dynamic):Bool
staticisWeaponValid(weaponHash:Int):Bool
staticmakePedReload(ped:Dynamic):Bool
Forces a ped to reload only if they are able to; if they have a full magazine, they will not reload.
staticrefillAmmoInstantly(ped:Dynamic):Bool
staticremoveAllPedWeapons(ped:Dynamic, p1:Bool):Dynamic
Parameter p1 does not seem to be used or referenced in game binaries.\
* **Note:** When called for networked entities, a `CRemoveAllWeaponsEvent` will be created per request.
staticremoveAllProjectilesOfType(weaponHash:Int, explode:Bool):Dynamic
If explode true, then removal is done through exploding the projectile. Basically the same as EXPLODE_PROJECTILES but without defining the owner ped.
staticremoveWeaponAsset(weaponHash:Int):Dynamic
staticremoveWeaponComponentFromPed(ped:Dynamic, weaponHash:Int, componentHash:Int):Dynamic
staticremoveWeaponComponentFromWeaponObject(weaponObject:Dynamic, addonHash:Int):Dynamic
staticremoveWeaponFromPed(ped:Dynamic, weaponHash:Int):Dynamic
This native removes a specified weapon from your selected ped.
Weapon Hashes: pastebin.com/0wwDZgkF
Example:
C#:
Function.Call(Hash.REMOVE_WEAPON_FROM_PED, Game.Player.Character, 0x99B507EA);
C++:
WEAPON::REMOVE_WEAPON_FROM_PED(PLAYER::PLAYER_PED_ID(), 0x99B507EA);
The code above removes the knife from the player. staticrequestWeaponAsset(weaponHash:Int, p1:Int, p2:Int):Dynamic
Nearly every instance of p1 I found was 31. Nearly every instance of p2 I found was 0.
REQUEST_WEAPON_ASSET(iLocal_1888, 31, 26); staticrequestWeaponHighDetailModel(weaponObject:Dynamic):Dynamic
staticsetAmmoInClip(ped:Dynamic, weaponHash:Int, ammo:Int):Bool
staticsetCurrentPedVehicleWeapon(ped:Dynamic, weaponHash:Int):Bool
staticsetCurrentPedWeapon(ped:Dynamic, weaponHash:Int, bForceInHand:Bool):Dynamic
staticsetFlashLightFadeDistance(distance:Float):Dynamic
staticsetPedAmmoByType(ped:Dynamic, ammoType:Int, ammo:Int):Dynamic
staticsetPedAmmoToDrop(ped:Dynamic, ammo:Int):Dynamic
staticsetPedChanceOfFiringBlanks(ped:Dynamic, xBias:Float, yBias:Float):Dynamic
staticsetPedCurrentWeaponVisible(ped:Dynamic, visible:Bool, deselectWeapon:Bool, p3:Bool, p4:Bool):Dynamic
Has 5 parameters since latest patches. staticsetPedDropsInventoryWeapon(ped:Dynamic, weaponHash:Int, xOffset:Float, yOffset:Float, zOffset:Float, ammoCount:Int):Dynamic
staticsetPedDropsWeapon(ped:Dynamic):Dynamic
staticsetPedDropsWeaponsWhenDead(ped:Dynamic, toggle:Bool):Dynamic
staticsetPedGadget(ped:Dynamic, gadgetHash:Int, p2:Bool):Dynamic
p1/gadgetHash was always 0xFBAB5776 ("GADGET_PARACHUTE").
p2 is always true. staticsetPedInfiniteAmmo(ped:Dynamic, toggle:Bool, weaponHash:Int):Dynamic
staticsetPedInfiniteAmmoClip(ped:Dynamic, toggle:Bool):Dynamic
staticsetPedWeaponTintIndex(ped:Dynamic, weaponHash:Int, tintIndex:Int):Dynamic
tintIndex can be the following:
0 : Default/Black
1 : Green
2 : Gold
3 : Pink
4 : Army
5 : LSPD
6 : Orange
7 : Platinum
tintIndex for MK2 weapons :
0 : Classic Black
1 : Classic Gray
2 : Classic Two-Tone
3 : Classic White
4 : Classic Beige
5 : Classic Green
6 : Classic Blue
7 : Classic Earth
8 : Classic Brown & Black
9 : Red Contrast
10 : Blue Contrast
11 : Yellow Contrast
12 : Orange Contrast
13 : Bold Pink
14 : Bold Purple & Yellow
15 : Bold Orange
16 : Bold Green & Purple
17 : Bold Red Features
18 : Bold Green Features
19 : Bold Cyan Features
20 : Bold Yellow Features
21 : Bold Red & White
22 : Bold Blue & White
23 : Metallic Gold
24 : Metallic Platinum
25 : Metallic Gray & Lilac
26 : Metallic Purple & Lime
27 : Metallic Red
28 : Metallic Green
29 : Metallic Blue
30 : Metallic White & Aqua
31 : Metallic Orange & Yellow
32 : Mettalic Red and YellowstaticsetPickupAmmoAmountScaler(p0:Float):Dynamic
staticsetWeaponAnimationOverride(ped:Dynamic, animStyle:Int):Dynamic
Changes the selected ped aiming animation style, you can find the list of animations below.
These are stored in the weaponanimations.meta file located in Grand Theft Auto V\update\update.rpf\common\data\ai\weaponanimations.meta.
For Lua, it's best if you send the animation using compile-time jenkins hashes to avoid overhead. An example is shown down below.
Animations
enum eWeaponAnimationOverrides {
Ballistic = 0x5534A626,
Default = 0xE4DF46D5,
Franklin = 0x44C24694,
Gang = 0xBC066B98,
Michael = 0x55932F38,
MP_F_Freemode = 0xACB10C83,
Trevor = 0x2737D5AC,
Hillbilly = 0x8503D409,
Gang1H = 0x724A7AB7,
FirstPerson = 0xEE38E8E0,
FirstPersonAiming = 0xC76297A3,
FirstPersonRNG = 0xA4FDD608,
FirstPersonScope = 0x28117C22,
FirstPersonMichael = 0xEAA2550B,
FirstPersonMichaelAiming = 0x3E6FF30F,
FirstPersonMichaelRNG = 0xB7A826C1,
FirstPersonMichaelScope = 0xC554CF97,
FirstPersonFranklin = 0xC407163A,
FirstPersonFranklinAiming = 0x3D4B7B03,
FirstPersonFranklinRNG = 0xBE79B0B4,
FirstPersonFranklinScope = 0xAFEA6593,
FirstPersonTrevor = 0xA65D5351,
FirstPersonTrevorAiming = 0xF9BE8ED9,
FirstPersonTrevorRNG = 0xD181ED09,
FirstPersonTrevorScope = 0x34A67D6D,
FirstPersonMPFemale = 0x8431583F,
Fat = 0xC531A409,
SuperFat = 0x529E5780,
Female = 0x6D155A1B,
GangFemale = 0x678ADF82,
}