🎒Inventory

Our built-in inventory supports ox_inventory. It could be that you are using a different inventory but still would like to use our script. That's absolutely possible, just follow the steps below!

Step 1: Finding the inventory system

Go to the sg-panning/bridge/server/qb.lua file and search for the function AddItem and ItemCount.

AddItem

local ox_inv = GetResourceState('ox_inventory') == 'started'

function AddItem(Player, item, amount)
    if ox_inv then 
        local canCarry = exports.ox_inventory:CanCarryItem(source, item, amount)
        if canCarry then
            exports.ox_inventory:AddItem(Player.PlayerData.source, item, amount)
        else
            print('You cannot carry this!')
        end
    else
        Player.Functions.AddItem(item, amount)
    end
end

ItemCount

function itemCount(Player, item, amount)
    local count = 0
    if ox_inv then 
        count = exports.ox_inventory:GetItemCount(Player.PlayerData.source, item)
    else
        for slot, data in pairs(Player.PlayerData.items) do -- Apparently qb only counts the amount from the first slot so I gotta do this.
            if data.name == item then
                count += data.amount
            end
        end
    end
    return count >= amount
end

If you want to change the inventory, make sure to change all the exports and also work if ox_inv then out of the picture. Here are some examples of the exports that you can use to make different inventories work.

QS Inventory

exports['qs-inventory']:AddItem(source, item, count)
exports['qs-inventory']:CanCarryItem(source, item, amount)
exports['qs-inventory']:RemoveItem(source, item, count)
exports['qs-inventory']:GetInventory(player)lua

For example, for AddItem it would look something like this.

local qs_inv = GetResourceState('qs-inventory') == 'started'

function AddItem(Player, item, amount)
    if qs_inv then 
        local canCarry = exports['qs-inventory']:CanCarryItem(source, item, amount)
        if canCarry then
            exports['qs-inventory']:AddItem(Player.PlayerData.source, item, count)
        else
            print('You cannot carry this!')
        end
    else
        Player.Functions.AddItem(item, amount)
    end
end

Step 3: Testing

Basically you're all done, but make sure that you have tested before officially releasing it in your already airing FiveM server to prevent player inconveniences.

Last updated