WeaponClient

getSelectedPedWeapon

GET_SELECTED_PED_WEAPON0x0A6DB4965674D243

The GTA V native GET_SELECTED_PED_WEAPON of the WEAPON namespace, as LS:MP client scripts call it: the global function getSelectedPedWeapon, in JavaScript and in Lua.

SignatureJavaScript
getSelectedPedWeapon(ped: Ped): Hash
SignatureLua
getSelectedPedWeapon(ped: Ped): Hash

Usage

JavaScript
const hash = getSelectedPedWeapon(ped);
Lua
local hash = getSelectedPedWeapon(ped)

Parameters

ParameterTypeJavaScriptLua
pedPednumberinteger

Returns

Hash JavaScript number, Lua integer

A game hash. Natives return it unsigned (0 to 4294967295), the value lsmp.hash gives. As an argument, the signed and unsigned forms of a hash are the same value.

Notes

From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.

Returns the hash of the weapon.

var num7 = getSelectedPedWeapon(num4);
sub_27D3(num7);
switch (num7)
{
    case 0x24B17070:

Also see getCurrentPedWeapon. Difference?


The difference is that getSelectedPedWeapon simply returns the ped's current weapon hash but getCurrentPedWeapon also checks the weapon object and returns true if the hash of the weapon object equals the weapon hash
Full list of weapons by DurtyFree: https://github.com/DurtyFree/gta-v-data-dumps/blob/master/weapons.json

Reference

Namespace
Weapon WEAPON
In the game
Hash GET_SELECTED_PED_WEAPON(Ped ped)
Hash
0x0A6DB4965674D243

Open in the interactive natives reference