# Export and Events

## **EXPORTS**

#### CLIENT EXPORTS

With this export you can search and control player inventory.(Only nearby players)

```lua
exports['bp_inventory']:searchcplayer()
```

#### SERVER EXPORTS

You can add items with this export.

```lua
exports['bp_inventory']:AddItem(source, item, amount, info, slot)
```

You can delete items with this export.

```lua
exports['bp_inventory']:RemoveItem(source, item, amount, slot)
```

With this export, you can get the information of the item with the item name.

```lua
exports['bp_inventory']:GetItemByName(source, item)
```

With this export, you can pull item information and quantity with item name.

```lua
exports['bp_inventory']:hasItem(source, item)
```

With this export you can retrieve information about the weight of the player's inventories.

```lua
exports['bp_inventory']:getWeight(source)
```

The total weight of the player's inventories.

```lua
exports['bp_inventory']:getMaxWeight(source)
```

Pulls information according to inventory type and inventory id. (playerid etc.) <mark style="color:red;">Types</mark> : **backpack, pocket, weapon, clothing, others. (id like playerid or string)**

```lua
exports['bp_inventory']:getinvinfo(type, id)
```

This export creates new inventory information with the incoming information. <mark style="color:red;">Types</mark> : **backpack, pocket, weapon, clothing, others. (id like playerid or string)**

<pre class="language-lua"><code class="lang-lua"><strong>exports['bp_inventory']:insertinvinfo(typed, id, data, slot, weight)
</strong></code></pre>

This export is used to update the existing inventory information. <mark style="color:red;">Types</mark> : **backpack, pocket, weapon, clothing, others. (id like playerid or string)**

```lua
exports['bp_inventory']:updateinvinfo(typed, id, data)
```

## EVENTS

#### CLIENT EVENTS

You can close the inventory with this event.

```lua
TriggerEvent('bp_inventory:closeinventory')
```

You can change clothes with this event.

```lua
TriggerEvent('bp_inventory:setclothing2', iteminfo)
```

### Stash

You can open stash with this event.

* type : ‘stash’
* stashid : ‘example’
* other : { maxweight = weight , slot = slot }
* items : the first occurrence creates items.

```lua
TriggerServerEvent('inventory:server:OpenInventory', "stash", "Motel_1534", false, {{['name'] = "weapon_pistol", ['amount'] = 1}})
```
