box-circle-checkInventory

circle-check

QS integration into PLocker

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
circle-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.

Last updated