# Inventory

{% hint style="success" %}
Our Locker system already includes several default inventories: QB-Inventory for QB-Core, OX, and Quasar Inventory. You can easily add your own inventory via exports.\
Here is the configuration of the Quasar inventory system integrated into our PLocker.
{% endhint %}

QS integration into PLocker

```lua
function InventoryBridge:GetPlayerInventory(xPlayer)
    local playerId = xPlayer.source
    local success, inventory = pcall(function()
        return exports['qs-inventory']:GetInventory(playerId)
    end)
    local formattedItems = {}

    if success and inventory then
        for slot, item in pairs(inventory) do
            if item and item.amount and item.amount > 0 then
                table.insert(formattedItems, {
                    name = item.name,
                    label = item.label or item.name,
                    count = item.amount,
                    metadata = item.info or {}
                })
            end
        end
    end

    return formattedItems
end

function InventoryBridge:AddItem(xPlayer, itemName, count)
    local playerId = xPlayer.source
    return exports['qs-inventory']:AddItem(playerId, itemName, count)
end

function InventoryBridge:RemoveItem(xPlayer, itemName, count)
    local playerId = xPlayer.source
    return exports['qs-inventory']:RemoveItem(playerId, itemName, count)
end

function InventoryBridge:GetItemCount(xPlayer, itemName)
    local playerId = xPlayer.source
    local success, inventory = pcall(function()
        return exports['qs-inventory']:GetInventory(playerId)
    end)

    if success and inventory then
        for slot, item in pairs(inventory) do
            if item and item.name == itemName then
                return item.amount or 0
            end
        end
    end

    return 0
end
```

{% hint style="info" %}
To integrate your inventory, go to `editable/inv/default/main.lua` and modify the code.\
If you need help, feel free to join our Discord.\
Here is the code from `default/main.lua`.
{% endhint %}

```lua
function InventoryBridge:GetPlayerInventory(xPlayer)
    local items = xPlayer.getInventory(true)
    local formattedItems = {}

    for i = 1, #items do
        if items[i].count > 0 then
            table.insert(formattedItems, {
                name = items[i].name,
                label = items[i].label,
                count = items[i].count,
                metadata = items[i].metadata or {}
            })
        end
    end

    return formattedItems
end

function InventoryBridge:AddItem(xPlayer, itemName, count)
    xPlayer.addInventoryItem(itemName, count)
    return true
end

function InventoryBridge:RemoveItem(xPlayer, itemName, count)
    xPlayer.removeInventoryItem(itemName, count)
    return true
end

function InventoryBridge:GetItemCount(xPlayer, itemName)
    local item = xPlayer.getInventoryItem(itemName)
    return item and item.count or 0
end
```
