# 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.

```lua
local count = KOJA.Client.GetItemCount(item)
```

| Parameter | Type     | Description |
| --------- | -------- | ----------- |
| `item`    | `string` | Item name   |

**Returns** `number` — amount owned (0 if none)

**Example**

```lua
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.

```lua
local has = KOJA.Client.HasItem(item, count)
```

| Parameter | Type      | Description                   |
| --------- | --------- | ----------------------------- |
| `item`    | `string`  | Item name                     |
| `count`   | `number?` | Minimum required (default: 1) |

**Returns** `boolean`

**Example**

```lua
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 }`.

```lua
local items = KOJA.Client.GetItems()
```

**Returns** `table` — `{ [itemName] = count }`

**Example**

```lua
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().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.

## Related pages

- [Callbacks](/koja-lib/api-reference/client-api/callbacks) — koja-lib provides a callback system that lets client scripts request data from the server and vice versa.
- [DUI](/koja-lib/api-reference/client-api/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](/koja-lib/api-reference/client-api/money) — Retrieve the local player's money balance from the client side via a server callback.
- [Keybinds](/koja-lib/api-reference/client-api/keybinds) — Register persistent key bindings that players can rebind in the GTA V settings menu.
- [Notifications](/koja-lib/api-reference/client-api/notifications) — koja-lib provides two notification interfaces: SendNotify (routes through the configured backend) and LibNotify (built-in koja-lib notification).
- [Player](/koja-lib/api-reference/client-api/player) — Functions for reading the local player's data on the client side.
- [Client API](/koja-lib/api-reference/client-api) — back to the section overview
