oxserver
ox_inventory:RemoveItem
ox server documentation with a FiveM Lua example.
Summary
Removes an item from an inventory via ox_inventory's server export. Use it to take items when a player sells, uses, or trades.
Returns
boolean — whether the removal succeeded.
Parameters
invnumber|stringThe inventory id — usually the player's server ID.itemstringThe item name.countnumberHow many to remove.Example
-- SERVER
local removed = exports.ox_inventory:RemoveItem(src, 'water', 1)
if removed then
-- proceed (e.g. give money for the sale)
endCommon pitfalls
- Always check the return — if the player doesn't have the item, removal fails and you shouldn't give the reward.
- Do the remove-then-reward sequence server-side and check each step, or players can exploit it.
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 →