πŸ”₯All scripts on our website are 50% off!πŸ”₯
Logo

Change Inventory

By default, our scripts are ready to use with qb and esx inventories.

If you want to modify the functions to another inventory, for example OX_Inventory or QS-Inventory here we show you how to do it.
If it is another inventory you will have to check the documentation provided by its developer and adapt it.

Add item

QB-Inventory

function addItem(playerID, item, amount)
    local player = QBCore.Functions.GetPlayer(playerID)
    if player then
        player.Functions.AddItem(item, amount)
        TriggerClientEvent('inventory:client:ItemBox', playerID, QBCore.Shared.Items[item], "add")
    end
end

OX_Inventory

function addItem(playerID, item, amount)
    exports.ox_inventory:AddItem(playerID, item, amount)
end

QS-Inventory

function addItem(playerID, item, amount)
    exports['qs-inventory']:AddItem(playerID, item, amount)
end

ESX

function addItem(playerID, item, amount)
    local xPlayer = ESX.GetPlayerFromId(playerID)
    if xPlayer then
        xPlayer.addInventoryItem(item, amount)
    end
end

Remove item

QB-Inventory

function removeItem(playerID, item, amount)
    local player = QBCore.Functions.GetPlayer(playerID)
    if player then
        player.Functions.RemoveItem(item, amount)
    end
end

OX_Inventory

function removeItem(playerID, item, amount)
    exports.ox_inventory:RemoveItem(playerID, item, amount)
end

QS-Inventory

function removeItem(playerID, item, amount)
    exports['qs-inventory']:RemoveItem(playerID, item, amount)
end

ESX

function removeItem(playerID, item, amount)
    local xPlayer = ESX.GetPlayerFromId(playerID)
    if xPlayer then
        xPlayer.removeInventoryItem(item, amount)
    end
end