Inventory

Client-side inventory functions let you check what items the local player has without a server round-trip.


GetItemCount

Returns how many of a given item the player owns.

local count = KOJA.Client.GetItemCount(item)
Parameter
Type
Description

item

string

Item name

Returns number — amount owned (0 if none)

Example

local bread = KOJA.Client.GetItemCount('bread')
if bread > 0 then
    print('Player has ' .. bread .. ' bread')
end

HasItem

Returns whether the player owns at least count of an item.

local has = KOJA.Client.HasItem(item, count)
Parameter
Type
Description

item

string

Item name

count

number?

Minimum required (default: 1)

Returns boolean

Example


GetItems

Returns the player's full inventory as a flat map of { [itemName] = totalCount }.

Returns table{ [itemName] = count }

Example


Notes

  • All three functions use a dedicated adapter for the detected inventory resource. If no adapter is available, they fall back to the framework's player data (ESX.GetPlayerData().inventory or QBCore.Functions.GetPlayerData().items).

  • GetItems may not be available for all inventories on the client side. When unavailable, HasItem and GetItemCount still work via the framework fallback.

Last updated