> For the complete documentation index, see [llms.txt](https://docs.menanak47.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.menanak47.com/qbcore/ak47_qb_inventory/exports/client.md).

# Client

### Ready

Is player inverntory is ready to use

```lua
exports['ak47_inventory']:Ready()
```

Return: `boolean`

### OpenInventory

```lua
exports['ak47_inventory']:OpenInventory(data)
```

* data: `table` or `string`
  * `string:` target inventory identifier
  * `table:`
    * `identifier` (inventory identifier)
    * `label` (inventory label)
    * `type` (inventory type: stash, backpack, glovebox, trunk)
    * `maxWeight` (inventory max weight)
    * `slots` (inventory max slots)

Example:&#x20;

{% tabs %}
{% tab title="Existing Stash" %}

```lua
exports['ak47_inventory']:OpenInventory('stash:1234')
```

{% endtab %}

{% tab title="New/Housing Stash" %}

```lua
exports['ak47_inventory']:OpenInventory({
	identifier = 'stash:1234',
	label = 'Housing Stash',
	type = 'stash',
	maxWeight = 120000,
	slots = 50,
})
```

{% endtab %}

{% tab title="Player Inventory" %}

```lua
--player server id
exports['ak47_inventory']:OpenInventory(5)
```

{% endtab %}
{% endtabs %}

### OpenNearbyInventory

```lua
-- opens nearby player invetnroy
exports['ak47_inventory']:OpenNearbyInventory()
```

### CloseInventory

```lua
exports['ak47_inventory']:CloseInventory()
```

### Items

{% tabs %}
{% tab title="All Items" %}

```lua
exports['ak47_inventory']:Items()
```

{% endtab %}

{% tab title="Single Item" %}

```lua
exports['ak47_inventory']:Items('water')
```

{% endtab %}
{% endtabs %}

### GetItem

```lua
exports['ak47_inventory']:GetItem(name, info, strict)
```

* name: `string`
  * item name
* info?: `any`
  * Only returns the amount of items that strictly match the given info.
* Strictly match info properties, otherwise use partial matching.

### GetFirstItem

```lua
exports['ak47_inventory']:GetFirstItem(item)
```

* item: `string`
  * item name

Return: `table`

* first item table with total item amount & properties

### GetItemLabel

```lua
exports['ak47_inventory']:GetItemLabel(name)
```

* name: `string`
  * item name
* return: `string`
  * item label

### HasItems

```lua
exports['ak47_inventory']:HasItems(items)
```

* items: `table`
  * table of items
* return:&#x20;
  * `boolean`
  * `table` table of missing items with amount

Example:

```lua
exports['ak47_inventory']:HasItems({
    water = 5,
    bread = 3
})
```

### Search <a href="#search" id="search"></a>

```lua
exports['ak47_inventory']:Search(searchType, item, info)
```

* searchType: `'slots'` or `'amount'`
  * `'slots'` returns a table of slots where the item was found at.
  * `'`amount`'` returns the amount of the specified item in player's inventory. If searching for multiple items returns key-value pairs of itemName = amount.
* item: `table` or `string`
  * Can be a single item name or array of item names.
* info?: `table` or `string`
  * If info is provided as a string it will search the item's `info.type` property.

#### Amount <a href="#count" id="count"></a>

{% tabs %}
{% tab title="Single Item" %}

```lua
local amount = exports['ak47_inventory']:Search('amount', 'water')
print('You have '..amount.. ' water')
```

{% endtab %}

{% tab title="Multiple Items" %}

```lua
local inventory = exports['ak47_inventory']:Search('amount', {'meat', 'skin'}, {grade="1"})
 
if inventory then
    for name, amount in pairs(inventory) do
        print('You have '..amount..' '..name)
    end
end
```

{% endtab %}
{% endtabs %}

#### Slots <a href="#slots" id="slots"></a>

{% tabs %}
{% tab title="Single Item" %}

```lua
local water = exports['ak47_inventory']:Search('slots', 'water')
local amount = 0
 
for _, v in pairs(water) do
    print(v.slot..' contains '..v.amount..' water '..json.encode(v.info))
    amount = amount + v.amount
end
 
print('You have '..amount..' water')
```

{% endtab %}

{% tab title="Multiple Items" %}

```lua
local items = exports['ak47_inventory']:Search('slots', {'meat', 'skin'}, 'deer')
 
if items then
    for name, data in pairs(items) do
        local amount = 0
 
        for _, v in pairs(data) do
            if v.slot then
                print(v.slot..' contains '..v.amount..' '..name..' '..json.encode(v.info))
                amount = amount + v.amount
            end
        end
 
        print('You have '..amount..' '..name)
    end
end
```

{% endtab %}
{% endtabs %}

### GetAmount

```lua
exports['ak47_inventory']:GetAmount(itemName, info, strict)
```

* itemName: `string`
* info?: `table`
* strict?: `boolean`
  * Strictly match info properties, otherwise use partial matching.

Return:

* amount: `number`

### GetPlayerItems

```lua
exports['ak47_inventory']:GetPlayerItems()
```

Return:

* items: `table`

### GetPlayerWeight

```lua
exports['ak47_inventory']:GetPlayerWeight()
```

Return:

* inventoryWeight: `number`

### GetPlayerMaxWeight

```lua
exports['ak47_inventory']:GetPlayerMaxWeight()
```

Return:

* maxWeight: `number`

### GetSlotWithItem <a href="#getslotwithitem" id="getslotwithitem"></a>

```lua
exports['ak47_inventory']:GetSlotWithItem(itemName, info, strict)
```

* itemName: `string`
* info?: `table`
* strict?: `boolean`
  * Strictly match info properties, otherwise use partial matching.

Return:

* slotData: `table?`

### GetSlotIdWithItem <a href="#getslotidwithitem" id="getslotidwithitem"></a>

```lua
exports['ak47_inventory']:GetSlotIdWithItem(itemName, info, strict)
```

* itemName: `string`
* info?: `table`
* strict?: `boolean`
  * Strictly match info properties, otherwise use partial matching.

Return:

* slotId: `number?`

### GetSlotsWithItem <a href="#getslotswithitem" id="getslotswithitem"></a>

```lua
exports['ak47_inventory']:GetSlotsWithItem(itemName, info, strict)
```

* itemName: `string`
* info?: `table`
* strict?: `boolean`
  * Strictly match info properties, otherwise use partial matching.

Return:

* slotsData: `table[]?`

### GetSlotIdsWithItem

```lua
exports['ak47_inventory']:GetSlotIdsWithItem(itemName, info, strict)
```

* itemName: `string`
* info?: `table`
* strict?: `boolean`
  * Strictly match info properties, otherwise use partial matching.

Return:

* slotIds: `number[]?`

### SetInventoryBusy

```lua
exports['ak47_inventory']:SetInventoryBusy(boolean) --true/false
```

Use Case:

```lua
local invBusy = LocalPlayer.state.invBusy
 
if invBusy then
    -- Do stuff when busy
else
    -- Do stuff when not busy
end
```

### UnEquipeWeapon

```lua
exports['ak47_inventory']:UnEquipeWeapon()
```
