oxserver
ox_inventory:AddItem
ox server documentation with a FiveM Lua example.
Summary
Adds an item to a player's inventory (or any inventory) via ox_inventory's server export. The standard way to give items on servers using ox_inventory.
Returns
boolean, string — success and a reason/response.
Parameters
invnumber|stringThe inventory id — usually the player's server ID.itemstringThe item name (must exist in items.lua).countnumberHow many to add.metadatatableOptional. Item metadata (durability, serial, etc.).Example
-- SERVER
local success = exports.ox_inventory:AddItem(src, 'water', 1)
if success then
-- item added
end
-- with metadata
exports.ox_inventory:AddItem(src, 'phone', 1, { serial = '12345' })Common pitfalls
- The item must be defined in ox_inventory's items.lua, or it silently fails. Duplicate item names also cause problems — check with a duplicate finder.
- This is a server export — calling it client-side won't work.
- Check the return value; inventories can be full.
Related functions
Related guides
FiveM scripts done right
Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.
Browse Scripts →