Inventory

Our PanelAdmin 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 PPanelAdmin.

QS integration into PPanelAdmin

function InventoryBridge:GiveItem(xPlayer, itemName, count, metadata)
    local playerId = xPlayer.source
    local success, result = pcall(function()
        return exports['qs-inventory']:AddItem(playerId, itemName, count, nil, metadata)
    end)
    return success and result
end

function InventoryBridge:GetAllItems()
    local items = {}
    local success, qsItems = pcall(function()
        return exports['qs-inventory']:GetItemList()
    end)

    if success and qsItems then
        for itemName, itemData in pairs(qsItems) do
            table.insert(items, {
                name = itemName,
                label = itemData.label or itemName,
                weight = itemData.weight or 0,
                type = itemData.type or 'item',
                unique = itemData.unique or false
            })
        end
    end

    return items
end

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.

function InventoryBridge:GiveItem(xPlayer, itemName, count, metadata)
    if metadata then
        return false
    end

    local item = xPlayer.getInventoryItem(itemName)
    if not item then
        return false
    end

    if item.limit ~= -1 and (item.count + count) > item.limit then
        return false
    end

    xPlayer.addInventoryItem(itemName, count)
    return true
end

function InventoryBridge:GetAllItems()
    local items = {}

    if ESX and ESX.Items then
        for itemName, itemData in pairs(ESX.Items) do
            table.insert(items, {
                name = itemName,
                label = itemData.label or itemName,
                weight = itemData.weight or 0,
                type = itemData.type or 'item',
                unique = itemData.unique or false
            })
        end
    end

    return items
end

Last updated