# How weapon hashes work in FiveM scripts

> Understand FiveM weapon hashes: the joaat algorithm, GetHashKey vs backtick hashes in Lua, signed and unsigned values and debugging hash mismatches.

Source: https://fam-tools.com/guides/fivem-joaat-weapon-hashes · FAM Tools · published 2026-09-11 · updated 2026-09-11 · about 8 min

**Short answer.** A hash is the Jenkins one-at-a-time hash of the lowercase name. In FiveM Lua, write `` `WEAPON_PISTOL` `` (computed at compile time, fastest) or call `GetHashKey('WEAPON_PISTOL')` / `joaat(...)` at runtime. Names are case-insensitive. Natives return hashes as signed 32-bit integers, so `WEAPON_UNARMED` appears as -1569615261 even though its hex is 0xA2719263 (2725352035 unsigned). Convert before comparing with unsigned values from websites.

## Key points

- Backticks: `` `WEAPON_PISTOL` `` — compile-time, fastest.
- `GetHashKey` / `joaat` — runtime, for dynamic names.
- Case-insensitive: `weapon_pistol` = `WEAPON_PISTOL`.
- Natives use signed values; many lists show unsigned or hex.
- Unsigned → signed: subtract 2³² if above 0x7FFFFFFF.

GTA V identifies weapons, models and components by 32-bit hashes of their names. Scripts compare them constantly — “is the player holding a pistol?” — and most hash bugs come from mixing the three ways to get a hash, or from signed and unsigned versions of the same number.

## Three ways to get a hash

*client.lua*

```lua
local a = `WEAPON_PISTOL`               -- compile time
local b = GetHashKey('WEAPON_PISTOL')  -- runtime native
local c = joaat('weapon_pistol')       -- runtime, FiveM Lua helper
print(a == b, b == c)                  -- true  true

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

Backticks only work with literal names. Use `GetHashKey` or `joaat` when the name comes from a config or database. Cfx.re measured backtick comparisons at less than half the cost of calling `GetHashKey` in a hot loop.

## Signed vs unsigned

*Computed with the joaat algorithm.*

| Name | Hex | Unsigned | Signed (what natives return) |
| --- | --- | --- | --- |
| `WEAPON_UNARMED` | 0xA2719263 | 2725352035 | -1569615261 |
| `WEAPON_PISTOL` | 0x1B06D571 | 453432689 | 453432689 |
| `WEAPON_PISTOL_MK2` | 0xBFE256D4 | 3219281620 | -1075685676 |
| `WEAPON_CARBINERIFLE` | 0x83BF0278 | 2210333304 | -2084633992 |
| `COMPONENT_PISTOL_CLIP_01` | 0xFED0FD71 | 4275109233 | -19858063 |

*Converting*

```lua
local function toSigned(h)
    if h > 0x7FFFFFFF then return h - 0x100000000 end
    return h
end

local function toUnsigned(h)
    if h < 0 then return h + 0x100000000 end
    return h
end
```

Hashes below 0x80000000 are identical in both forms, which is why some weapons “work” and others silently fail when a table stores unsigned numbers. The complete list with both values: [weapon names and hashes](https://fam-tools.com/guides/gta-5-weapon-names-hashes-list).

## JavaScript and C#

In JavaScript use `GetHashKey('WEAPON_PISTOL')`; in C# `(uint)API.GetHashKey("WEAPON_PISTOL")` or the `WeaponHash` enum. When moving hashes between languages or storing them as JSON, keep one convention (signed or name strings) for the whole project. If you only need the number for one name, [FAM Tools has a joaat calculator](https://fam-tools.com/free-tools/hash-calculator) that also searches backwards from a hash you already have.

## Debugging hash mismatches

1. Print both values: `print(GetSelectedPedWeapon(ped), `WEAPON_X`)`.
2. If they differ by exactly 4294967296, it is a signed/unsigned mix.
3. If they are unrelated, check spelling (`WEAPON_CARBINERIFLE`, not `WEAPON_CARBINE_RIFLE`).
4. For add-on weapons, make sure the weapon is actually streamed and loaded.

## Questions

### What is joaat in FiveM?

The Jenkins one-at-a-time hash GTA V uses for names; FiveM Lua exposes it as `joaat()` and backtick literals.

### Why is WEAPON_UNARMED negative?

Natives return signed 32-bit integers. 0xA2719263 is 2725352035 unsigned and -1569615261 signed.

### Is GetHashKey case-sensitive?

No. The name is lowercased before hashing.

### Should I use backticks or GetHashKey?

Backticks for fixed names (faster), `GetHashKey`/`joaat` for names from config or data.

## Related

- https://fam-tools.com/guides/gta-5-weapon-names-hashes-list
- https://fam-tools.com/guides/fivem-give-weapon-to-player
- https://fam-tools.com/guides/fivem-weapon-components-attachments
- https://fam-tools.com/guides/fivem-weapon-display-names-addtextentry
