Weapon licences in FiveM
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).
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
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.
#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).
return {
{ name = 'weapon', coords = vec3(12.42198, -1105.82, 29.7854), price = 5000 },
}#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 |
#Police checks and revoking
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)
endPut 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.
Questions
How do I require a weapon licence in ox_inventory shops?
license = 'weapon' to the shop item in data/shops.lua.Where are weapon licences stored on ESX?
user_licenses table used by esx_license, with the licence type weapon.How do I check a QBCore player’s weapon licence?
Player.PlayerData.metadata.licences.weapon on the server.Can players buy a weapon licence by default?
Ready to pick a map?
Twelve themes on three base map styles, $8 each, instant download.
Relevant to what you just read
The tool for this
Twenty theme pairs for ox_lib and ox_inventory From $15, built in the browser, exported as a drop-in resource.