qb-inventory
These modifications can only be made if you use the qb-inventory
Add the following code at the end of the file
qb-inventory/server/main.lua
exports("GetStash", function(stashId)
return Stashes[stashId] or {
items = GetStashItems(stashId)
}
end)
exports('GetStashItems', GetStashItems)
RegisterServerEvent('qb-inventory:server:SaveStashItems', function(stashId, items)
MySQL.insert('INSERT INTO stashitems (stash, items) VALUES (@stash, @items) ON DUPLICATE KEY UPDATE items = @items', {
['@stash'] = stashId,
['@items'] = json.encode(items)
})
if Stashes[stashId] then
Stashes[stashId].items = items
end
end)
Modify the function called
InitializeInventory
so that it looks like this
qb-inventory\server\functions.lua
local function InitializeInventory(inventoryId, data)
if Inventories[inventoryId] and Inventories[inventoryId].maxweight then return Inventories[inventoryId] end
Inventories[inventoryId] = {
items = {},
isOpen = false,
label = data and data.label or inventoryId,
maxweight = data and data.maxweight or Config.StashSize.maxweight,
slots = data and data.slots or Config.StashSize.slots
}
return Inventories[inventoryId]
end
Below the previous function, add the export of it
qb-inventory\server\functions.lua
exports('InitializeInventory', InitializeInventory)
Add the following code at the end of the file
qb-inventory\server\functions.lua
exports('GetStashItems', function(identifier)
local inventory = Inventories[identifier]
if not inventory then return end
return inventory.items
end)
Last updated