Santa & Christmas Edition36 maps, limited runlimited runShop the drop
Chapter 04 of 10The Weapon Skins Handbook for FiveM

Attachments, tints, ammo, durability and serials

In short

Components swap a weapon’s parts: suppressors, scopes, flashlights, magazines, grips and camos. A tint recolours the whole weapon. Ammo, wear and registration live in ox_inventory item metadata.

client — natives (standalone servers and scripts)
local ped, weapon = PlayerPedId(), `WEAPON_CARBINERIFLE`

if DoesWeaponTakeWeaponComponent(weapon, `COMPONENT_AT_AR_SUPP`) then
    GiveWeaponComponentToPed(ped, weapon, `COMPONENT_AT_AR_SUPP`)
end

SetPedWeaponTintIndex(ped, weapon, 2)   -- 2 = gold on normal weapons
Tint index (normal weapons)Colour
0Default (black)
1Green
2Gold
3Pink
4Army
5LSPD
6Orange
7Platinum

MK II weapons use a larger palette, 0–31. GetWeaponTintCount(hash) returns how many tints a weapon has.

In ox_inventory an attachment is an item listed under Components in data/weapons.lua, at_suppressor_light for example. Each one has a type and a client.component list of component hashes. Using the item on a weapon attaches the first component in that list that fits and records it in metadata.components.

MK II camos are components named COMPONENT_<WEAPON>_MK2_CAMO, _CAMO_02 … _CAMO_10 and _CAMO_IND_01, and SetPedWeaponLiveryColor(ped, weapon, component, tint) colours them. A component that floats away from the weapon has its bone (WAPSupp, WAPScop, WAPFlshLasr, WAPClip, WAPGrip) in the wrong place on the model.

Every stock COMPONENT_ name, its hash and the weapon it fits is listed in the weapon components reference.

Ammo, wear and registration are what make weapons part of a server’s economy, and ox_inventory handles all three through item metadata.

ox_inventory ammo itemCalibreUsed by
ammo-99 mmMost pistols and SMGs
ammo-rifle5.56×45Carbine-type rifles
ammo-rifle27.62×39AK-type rifles
ammo-shotgun12 gaugeShotguns
ammo-sniperSniper roundsSniper rifles

The ammoname of each weapon in data/weapons.lua names the item that reloads it.

  • Durability: a new weapon has metadata.durability = 100, and every shot subtracts the weapon’s durability value (0.1 for pistols, for example). At 0 it is broken until someone repairs it.
  • Serials: a weapon that uses ammo gets registered (the owner’s name) and a serial of six digits, three letters and six digits. Pass a three-character prefix such as serial = 'POL' and it takes the middle position.
  • metadata = { registered = false } creates an unregistered weapon with no serial, which is the black-market version.
  • The infinite ammo natives (SetPedInfiniteAmmo, SetPedInfiniteAmmoClip) suit arenas and events, not a server that runs an inventory.
server — a registered police pistol with 12 rounds loaded
exports.ox_inventory:AddItem(source, 'WEAPON_COMBATPISTOL', 1, { serial = 'POL', ammo = 12 })
exports.ox_inventory:AddItem(source, 'ammo-9', 48)

The Weapon Skins Handbook for FiveM

This chapter is one of 10. The handbook also carries the native, control and data-file cheat sheets, a glossary and the official references behind every chapter.

Open the handbook