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
Managing jobs on your server?
Viper Multi-Job lets players hold several jobs and switch between them with grade, salary and duty handled — QBCore, QBox and ESX, validated server-side.
See Viper Multi-Job →