# QB Inventory

{% hint style="warning" %}
This guide is for qb-inventory version 2.x or higher. Old versions or inspired/custom inventories based on qb-inventory are NOT supported.
{% endhint %}

* Go to **qb-inventory/server/functions.lua** and add the following export after `InitializeInventory` function:

```lua
exports('registerInventory', InitializeInventory)
```

<figure><img src="https://1688068901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bCwnajAqpi3Viykb5Wi%2Fuploads%2FbZBLBqO6Jfh6M2fjyDcO%2Fimage.png?alt=media&#x26;token=eab3f87b-162b-45f2-9d03-80267b4c5ec2" alt=""><figcaption></figcaption></figure>

* Go to **qb-inventory/server/main.lua** and add the following line inside the `qb-inventory:server:closeInventory` event:

```lua
TriggerEvent("av_scripts:inventorySaved", src, nil, inventory)
```

<figure><img src="https://1688068901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bCwnajAqpi3Viykb5Wi%2Fuploads%2FoV20BQTqVNF3V4vYox5D%2Fimage.png?alt=media&#x26;token=e44405a8-c8d2-4618-8a60-fbabdef08cfa" alt=""><figcaption></figcaption></figure>

* In **qb-inventory/server/main.lua** add the following code in the end of the file:

```lua
function WipeStash(identifier)
    if Inventories and Inventories[identifier] then
        Inventories[identifier]['items'] = {}
    end
    local exists = MySQL.single.await('SELECT `items` FROM `inventories` WHERE `identifier` = ?', {
        identifier
    })
    if exists and exists['items'] then
        local empty = {}
        MySQL.update.await('UPDATE `inventories` SET `items` = ? WHERE `identifier` = ?', {
            json.encode(empty), identifier
        })
    end
end

exports('WipeStash', WipeStash)
```
