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
if KOJA.Client.HasItem('lockpick') then
-- player has at least 1 lockpick
end
if KOJA.Client.HasItem('water', 3) then
-- player has at least 3 water bottles
end
GetItems
Returns the player's full inventory as a flat map of { [itemName] = totalCount }.
local items = KOJA.Client.GetItems()
Returns table — { [itemName] = count }
Example
local items = KOJA.Client.GetItems()
for name, count in pairs(items) do
print(name, count)
end
-- Check a specific item
local knives = items['knife'] or 0
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().inventoryorQBCore.Functions.GetPlayerData().items). GetItemsmay not be available for all inventories on the client side. When unavailable,HasItemandGetItemCountstill work via the framework fallback.
Related pages
- Callbacks — koja-lib provides a callback system that lets client scripts request data from the server and vice versa.
- DUI — DUI (Dynamic UI) allows you to render a web page as a texture on any in-game surface — screens, billboards, laptops, phones, etc.
- Money — Retrieve the local player's money balance from the client side via a server callback.
- Keybinds — Register persistent key bindings that players can rebind in the GTA V settings menu.
- Notifications — koja-lib provides two notification interfaces: SendNotify (routes through the configured backend) and LibNotify (built-in koja-lib notification).
- Player — Functions for reading the local player's data on the client side.
- Client API — back to the section overview