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.
QB + 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
QB + OX_Inventory
function addItem(playerID, item, amount)
exports.ox_inventory:AddItem(playerID, item, amount)
end
QB + 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