Santa & Christmas Edition36 maps, limited runlimited runShop the drop
Chapter 01 of 10The Weapon Skins Handbook for FiveM

How weapons work: names, hashes and giving them

In short

A weapon is a name such as WEAPON_PISTOL. The game hashes that name into a number, and natives work with the number. On a framework server the inventory, not the game, records who owns which weapon.

WeaponNameHash (hex)Hash (signed)
PistolWEAPON_PISTOL0x1B06D571453432689
Combat PistolWEAPON_COMBATPISTOL0x5EF9FEC41593441988
SMGWEAPON_SMG0x2BE6766B736523883
Assault RifleWEAPON_ASSAULTRIFLE0xBFEFFF6D-1074790547
Carbine RifleWEAPON_CARBINERIFLE0x83BF0278-2084633992
Pump ShotgunWEAPON_PUMPSHOTGUN0x1D073A89487013001
Sniper RifleWEAPON_SNIPERRIFLE0x05FC3C11100416529
KnifeWEAPON_KNIFE0x99B507EA-1716189206

Each hash is joaat of the lowercase name. A native can hand back the signed form, so compare against a backtick hash rather than a typed number.

The hex and signed columns hold the same 32 bits. The hash is an unsigned 32-bit integer and Lua prints integers as signed, so any value above 2,147,483,647 shows up negative. The whole stock table, with model names and ammo types, is on the weapon hashes reference.

lua
local a = `WEAPON_PISTOL`             -- computed at load time, free in loops
local b = GetHashKey('WEAPON_PISTOL')  -- same number, computed every call

if GetSelectedPedWeapon(PlayerPedId()) == `WEAPON_PISTOL` then
    print('holding a pistol')
end

A backtick hash is resolved once, when the script loads, so it costs nothing inside a loop. GetHashKey returns the same number but works it out on every call.

Server typeGive a weapon with
ox_inventory (ESX, Qbox, ox_core, ND_Core)exports.ox_inventory:AddItem(source, 'WEAPON_PISTOL', 1) on the server
QBCore + qb-inventoryPlayer.Functions.AddItem('weapon_pistol', 1) or the qb-inventory export
ESX default loadoutxPlayer.addWeapon('WEAPON_PISTOL', 50)
StandaloneGiveWeaponToPed(ped, hash, ammo, false, true)

The Weapon Skins Handbook for FiveM

This chapter is one of 10. The handbook also carries the native, control and data-file cheat sheets, a glossary and the official references behind every chapter.

Open the handbook