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)

Last updated