ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
oxserver

ox_inventory:GetItem / Search

ox server documentation with a FiveM Lua example.

Summary

Reads what a player has in ox_inventory — get the count/metadata of an item, or search their inventory. Use before removing items or gating actions on having an item.

Returns

table|number — item data or count, depending on call.

Parameters

invnumberThe inventory id (player server ID).
itemstringThe item name.

Example

-- count of an item
local count = exports.ox_inventory:Search(src, 'count', 'water')
if count > 0 then
  -- player has water
end

Common pitfalls

  • Server-side export; don't call it on the client.
  • Check counts server-side before removing/rewarding to prevent exploits.
  • Item must exist in items.lua.

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 →