onWeaponSerialGenerated

Purpose

Triggered when a weapon serial number is generated during a shop purchase. Use this hook to integrate with MDT systems, weapon registration databases, or log weapon sales for audit trails.

When It Triggers

  • A player purchases a weapon item from any shop

  • The weapon is in the configured serialWeapons list (Config.WeaponSerial.serialWeapons)

  • Serial generation is enabled (Config.WeaponSerial.enabled = true)

  • Fires once per weapon β€” if a player buys 3 pistols, the hook fires 3 times with unique serials

Parameters

Parameter
Type
Description

data.source

number

Server ID of the buyer

data.playerName

string

Steam/FiveM display name of the buyer

data.characterName

string

In-game character name (first + last)

data.identifier

string

Unique player identifier (citizenid for QBCore, license for ESX)

data.weaponName

string

Item name (e.g., 'WEAPON_PISTOL')

data.weaponLabel

string

Display label (e.g., 'Pistol')

data.serial

string

Generated serial number (e.g., '482917ABK637201')

data.registered

string

Registered owner name, or nil if registerToOwner is false

data.shopId

string

Unique shop identifier (e.g., 'gunstore_1')

data.shopName

string

Display name of the shop (e.g., 'Ammu-Nation')

data.shopType

string

Shop type (e.g., 'gunstore', 'police_armory')

data.timestamp

number

Unix timestamp of the purchase

data.metadata

table

Full item metadata table containing serial, registered, and any custom fields

Example

Notes

  • The serial format is configurable via Config.WeaponSerial.serialFormat (default: [6 digits][3 letters][6 digits], matching ox_inventory)

  • Police armory purchases use the 'POL' prefix by default (e.g., 482917POL637201) β€” configurable via shopTypePrefixes

  • Only weapons listed in Config.WeaponSerial.serialWeapons will trigger this hook β€” melee weapons, throwables, and utility items are excluded by default

Last updated