Weapon attachments in ox_inventory
Attachments are items defined under Components in ox_inventory/data/weapons.lua. Each has a type (flashlight, muzzle, grip, barrel, magazine, sight, skin) and a client.component list of component hashes it can apply. Using the item on a weapon attaches the first compatible component and stores it in the weapon’s metadata.components; removing it gives the item back.
ox_inventory turns weapon components into inventory items that players can buy, trade, craft and loot — then attach to a compatible weapon in a couple of seconds. The defaults cover every vanilla attachment family; addon weapons need a small addition. Here is how the system is put together.

#The default attachment items
| Item | Label | Type |
|---|---|---|
at_flashlight | Tactical Flashlight | flashlight |
at_suppressor_light | Suppressor | muzzle |
at_suppressor_heavy | Tactical Suppressor | muzzle |
at_compensator | Compensator | muzzle |
at_muzzle_flat, …_tactical, …_fat, …_precision, …_heavy, …_slanted, …_split, …_squared, …_bell | Mk II muzzle brakes | muzzle |
at_grip | Grip | grip |
at_barrel | Heavy Barrel | barrel |
at_clip_extended_pistol, …_smg, …_shotgun, …_rifle, …_mg, …_sniper | Extended clips | magazine |
at_clip_drum_smg, …_shotgun, …_rifle | Drum magazines | magazine |
at_scope_macro, …_small, …_medium, …_large, …_advanced, …_nv, …_thermal, at_scope_holo | Scopes and sights | sight |
at_skin_luxe, at_skin_camo, at_skin_woodland and others | Finish kits | skin |
From ox_inventory’s default data/weapons.lua.
#How an attachment item is defined
['at_suppressor_light'] = {
label = 'Suppressor',
weight = 280,
type = 'muzzle',
client = {
image = 'at_suppressor.png',
component = {
`COMPONENT_AT_PI_SUPP`,
`COMPONENT_AT_PI_SUPP_02`,
`COMPONENT_CERAMICPISTOL_SUPP`,
`COMPONENT_PISTOLXM3_SUPP`,
},
usetime = 2500,
},
},typegroups attachments; a weapon holds one attachment of each type.client.componentlists every GTA component this item may apply. When used on a weapon, the first entry the weapon accepts is attached.usetimeis how long attaching takes, in milliseconds.client.imagelets several items share one icon.
#Attachments for addon weapons
An addon weapon usually has its own component names (for example COMPONENT_MYRIFLE_CLIP_02). The existing item will not attach them until you list them:
- Find the component names in the weapon’s
weaponcomponents.metaand itsAttachPointsin weapons.meta. - Add each hash to the matching item’s
client.componentlist (for example the extended clip toat_clip_extended_rifle). - Or create a new item if the attachment is unique to that weapon.
- Restart ox_inventory.
['at_clip_extended_rifle'] = {
label = 'Extended Rifle Clip',
type = 'magazine',
client = {
component = {
-- …existing vanilla hashes…
`COMPONENT_MYRIFLE_CLIP_02`,
},
usetime = 2500,
},
},If the weapon’s own weapons.meta does not list the component in its AttachPoints, no item can attach it — see weapons.meta explained.
#When an attachment will not attach
| Symptom | Cause |
|---|---|
| “Not compatible” | None of the item’s component hashes are accepted by that weapon |
| Attaches but invisible | The component’s model is not streamed or not in weaponarchetypes.meta |
| Lost after relog | Attached with a native instead of the inventory |
| Wrong suppressor for a pistol | Pistols use the light suppressor; rifles use the heavy one |
The component system itself — natives and naming — is covered in weapon components.
Questions
How do attachments work in ox_inventory?
metadata.components.What is the ox_inventory suppressor item called?
at_suppressor_light (pistols) and at_suppressor_heavy (rifles and other long guns).Why does the suppressor not fit my addon weapon?
Do attachments stay after relogging?
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.