> For the complete documentation index, see [llms.txt](https://docs.kojascripts.eu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kojascripts.eu/koja-lib/api-reference/client-api/inventory.md).

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kojascripts.eu/koja-lib/api-reference/client-api/inventory.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
