Weapon Serialization & Evidence System
The XR-MDT includes a robust weapon serialization system that allows you to generate unique serial numbers, register weapon ownership, and track them in the evidence database (mdt_weapons).
1. How it Works
Serial numbers are generated using theGenerateWeaponSerial export. The generation logic is implemented in editable/server/main.lua as EditTable.LSPD.Functions.GenerateWeaponSerial().
The serial format follows: {Prefix}-{Format} where X in the format string is replaced with a random alphanumeric character (0-9, A-Z).
Generated serial numbers should be stored in the weapon’s item metadata in your inventory script. When a weapon is checked via the MDT, the system looks up the serial number in the mdt_weapons database table.
2. Configuration
Customize the serial number format inconfigs/config.main.lua:
SN-A3B2-K9X1-MNP7
[!NOTE] TheGenerateWeaponSerialfunction does not currently check the database for uniqueness (unlikeGenerateVinwhich does). The randomness of the format is relied upon for uniqueness. For guaranteed uniqueness, add a DB check insideEditTable.LSPD.Functions.GenerateWeaponSerialineditable/server/main.lua.
3. Inventory Integration
ox_inventory
To generate a serial for a weapon upon receiving it (e.g., in a shop or crafting script):qb-inventory
In QB inventories, serial numbers are typically stored in theinfo table:
qs-inventory (Quasar)
4. API Reference (Exports)
GenerateWeaponSerial
Generates a unique serial number based on your Config.WeaponSerialization config.
Returns: string — The generated serial (e.g., "SN-A1B2-C3D4-E5F6")
GenerateVin
Generates a unique Vehicle Identification Number (12-character alphanumeric), verified against the database for uniqueness.
Returns: string — The unique VIN.
RegisterWeapon
Registers a weapon in the MDT evidence system (mdt_weapons table).
| Parameter | Type | Description |
|---|---|---|
citizenid | string | The owner’s unique identifier. |
serial | string | The unique serial number. |
model | string | The weapon model name / label (e.g. 'Combat Pistol'). |
boolean — Success
GetWeaponOwner
Fetches ownership and history details for a specific serial number from mdt_weapons.
| Parameter | Type | Description |
|---|---|---|
serial | string | The serial number to look up. |
table|nil — Contains: serial, owner (name), citizenid, model, date
5. Script Integration Hook
If you want to automatically register weapons when they are processed by an inventory or weapon shop, hook into your script:
[!IMPORTANT]
The MDT only tracks weapons that have been explicitly registered via RegisterWeapon. It does NOT automatically scan all inventory items for performance reasons. Always call the registration export when a new weapon is issued to a player.
6. Armory System
In addition to the serialization system, XR-MDT includes a dedicated Armory module (server/sv_armory.lua, client/cl_armory.lua) for law enforcement.
The Armory system tracks:
- Kits (
mdt_armory_kits) — Predefined weapon loadout templates. - Stock (
mdt_armory_stock) — Current available quantities per kit.
armory_access = true in the job’s Grades config.
© XR-Core Systems | Professional FiveM Resources
