# Weapon licences in FiveM

> Set up weapon licences on a FiveM server: ox_inventory shop licence requirements, where licences are stored on ESX and QBCore, police checks and revoking.

Source: https://fam-tools.com/guides/fivem-weapon-license-system · FAM Tools · published 2026-09-11 · updated 2026-09-11 · about 10 min

**Short answer.** In ox_inventory, add `license = 'weapon'` to a shop item and only players with that licence can buy it. ox_inventory checks licences through its framework bridge: on ESX it reads the `user_licenses` table, on Qbox it reads `metadata.licences`, and on ox_core and ND_Core it asks the framework. Its default data includes a weapon licence purchase point. QBCore stores licences in the player’s metadata (`licences.weapon`).

## Key points

- `license = 'weapon'` on an ox_inventory shop item requires the licence.
- ESX: licences are rows in `user_licenses` (esx_license).
- ox_core / ND_Core: the framework’s own licence functions.
- QBCore: `PlayerData.metadata.licences.weapon`.
- Police checks and revocations are just reads and writes of the same data.

A weapon licence is a simple gate that creates a lot of roleplay: legal gun stores that ask for paperwork, police who check it during a stop, and a reason for criminals to use the black market. ox_inventory supports licence requirements on shop items out of the box; the licence itself lives in your framework.

## Licence-gated shop items in ox_inventory

*ox_inventory/data/shops.lua*

```lua
Ammunation = {
    name = 'Ammunation',
    blip = { id = 110, colour = 69, scale = 0.8 },
    inventory = {
        { name = 'ammo-9', price = 5 },
        { name = 'WEAPON_KNIFE', price = 200 },
        { name = 'WEAPON_PISTOL', price = 1000, metadata = { registered = true }, license = 'weapon' },
    },
    locations = { vec3(-662.180, -934.961, 21.829) },
},
```

Only items with `license` are gated; ammo and melee weapons in the same shop can be bought by anyone. Registered weapons also get a serial — see [serial numbers](https://fam-tools.com/guides/fivem-weapon-serial-numbers).

## Buying the licence

ox_inventory’s default `data/licenses.lua` defines a weapon licence for sale at a location near the Ammu-Nation on Adam’s Apple Boulevard, for $5,000. When a player buys it, ox_inventory takes the money and grants the licence through the framework bridge (on ESX by triggering `esx_license:addLicense`).

*ox_inventory/data/licenses.lua (default)*

```lua
return {
    { name = 'weapon', coords = vec3(12.42198, -1105.82, 29.7854), price = 5000 },
}
```

> **Make it roleplay** — Many servers remove the instant purchase and have police or a gun-store employee issue licences after a check — a background check, a written test or a range qualification.

## Where licences are stored

| Framework | Storage | Check from a script |
| --- | --- | --- |
| ESX | `user_licenses` table (esx_license) | `TriggerEvent('esx_license:checkLicense', src, 'weapon', cb)` or a query on `user_licenses` |
| QBCore | `PlayerData.metadata.licences` | `Player.PlayerData.metadata.licences.weapon` |
| ox_core | Framework licence functions | `player.getLicense('weapon')` |
| ND_Core | Player metadata `licenses` | The framework’s licence helpers |

> **QBCore and ox_inventory** — Official ox_inventory supports ox_core, ESX, Qbox and ND_Core; plain QBCore is not on that list. QBCore-based servers usually run it through Qbox (which reads `metadata.licences`, the same field as QBCore) or a community fork — with a fork, check how it handles licences before relying on `license =`.

## Police checks and revoking

*server.lua — QBCore example: revoke a weapon licence*

```lua
local QBCore = exports['qb-core']:GetCoreObject()

local function setWeaponLicence(targetId, allowed)
    local Player = QBCore.Functions.GetPlayer(targetId)
    if not Player then return end
    local licences = Player.PlayerData.metadata.licences or {}
    licences.weapon = allowed
    Player.Functions.SetMetaData('licences', licences)
end
```

Put these actions behind a job check on the server — only police (and perhaps judges) should be able to grant or revoke. Anything exposed as a net event must verify the caller, as explained on pityus.net in [client vs server scripts](https://pityus.net/guides/fivem-client-vs-server-scripts).

## Questions

### How do I require a weapon licence in ox_inventory shops?

Add `license = 'weapon'` to the shop item in `data/shops.lua`.

### Where are weapon licences stored on ESX?

In the `user_licenses` table used by esx_license, with the licence type `weapon`.

### How do I check a QBCore player’s weapon licence?

Read `Player.PlayerData.metadata.licences.weapon` on the server.

### Can players buy a weapon licence by default?

ox_inventory’s default data includes a weapon licence purchase point for $5,000. Many servers replace it with a police-issued licence.

## Related

- https://fam-tools.com/guides/ox-inventory-shops-config
- https://fam-tools.com/guides/fivem-weapon-serial-numbers
- https://fam-tools.com/guides/fivem-police-armory-setup
- https://fam-tools.com/guides/fivem-weapon-shop-setup
