The following edits should be made in qb-inventory/server/main.lua
Search the event inventory:server:SetInventoryData, inside this event you should have a line pretty similar to this:
if (fromInventory=="player" orfromInventory=="hotbar") and (QBCore.Shared.SplitStr(toInventory, "-")[1] =="itemshop" ortoInventory=="crafting") thenreturnend
Replace that line with the following:
Search the function SetItemData and replace it with:
Replace the function AddToStash:
Search the function addTrunkItems and replace it with:
Search for the event inventory:server:SaveInventory and replace it with:
Search for the event inventory:server:OpenInventory and do the following:
Add the parameter newLabel inside the function()
Replace secondInv.label = 'Stash-'..id with the following:
Should look something like this:
Copy/paste this code at the end of the file:
Last updated
if isRestricted(toInventory) then return end
local function SetItemData(source, itemName, key, val, slot)
if not itemName or not key then return false end
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
local item = nil
if slot then
item = Player.PlayerData.items[slot]
else
item = GetItemByName(source, itemName)
end
if not item then return false end
item[key] = val
Player.PlayerData.items[item.slot] = item
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
return true
end
local function AddToStash(stashId, slot, otherslot, itemName, amount, info)
local slot = slot or 1
amount = tonumber(amount) or 1
local ItemData = SharedItems(itemName)
if not ItemData then
print("Item "..itemName.." doesn't exist")
return
end
Stashes[stashId] = Stashes[stashId] or {}
Stashes[stashId]['items'] = Stashes[stashId]['items'] or {}
Stashes[stashId].items[slot] = Stashes[stashId].items[slot] or {}
if not ItemData.unique then
if Stashes[stashId].items[slot] and Stashes[stashId].items[slot].name == itemName then
Stashes[stashId].items[slot].amount = Stashes[stashId].items[slot].amount + amount
else
local itemInfo = SharedItems(itemName:lower())
Stashes[stashId].items[slot] = {
name = itemInfo['name'],
amount = amount,
info = info or '',
label = itemInfo['label'],
description = itemInfo['description'] or '',
weight = itemInfo['weight'],
type = itemInfo['type'],
unique = itemInfo['unique'],
useable = itemInfo['useable'],
image = itemInfo['image'],
slot = slot,
}
end
else
if Stashes[stashId].items[slot] and Stashes[stashId].items[slot].name == itemName then
local itemInfo = SharedItems(itemName:lower())
Stashes[stashId].items[otherslot] = {
name = itemInfo['name'],
amount = amount,
info = info or '',
label = itemInfo['label'],
description = itemInfo['description'] or '',
weight = itemInfo['weight'],
type = itemInfo['type'],
unique = itemInfo['unique'],
useable = itemInfo['useable'],
image = itemInfo['image'],
slot = otherslot,
}
else
local itemInfo = SharedItems(itemName:lower())
Stashes[stashId].items[slot] = {
name = itemInfo['name'],
amount = amount,
info = info or '',
label = itemInfo['label'],
description = itemInfo['description'] or '',
weight = itemInfo['weight'],
type = itemInfo['type'],
unique = itemInfo['unique'],
useable = itemInfo['useable'],
image = itemInfo['image'],
slot = slot,
}
end
end
end
function addTrunkItems(plate, items) -- av-scripts
Trunks[plate] = {}
Trunks[plate].label = "Trunk-"..plate
Trunks[plate].items = items
end
RegisterNetEvent('inventory:server:SaveInventory', function(type, id) -- av-scripts
local src = source
if type == 'trunk' then
if IsVehicleOwned(id) then
SaveOwnedVehicleItems(id, Trunks[id].items)
else
Trunks[id].isOpen = false
end
elseif type == 'glovebox' then
if (IsVehicleOwned(id)) then
SaveOwnedGloveboxItems(id, Gloveboxes[id].items)
else
Gloveboxes[id].isOpen = false
end
elseif type == 'stash' then
SaveStashItems(id, Stashes[id].items)
elseif type == 'drop' then
if Drops[id] then
Drops[id].isOpen = false
if Drops[id].items == nil or next(Drops[id].items) == nil then
Drops[id] = nil
TriggerClientEvent('inventory:client:RemoveDropItem', -1, id)
end
end
end
TriggerEvent("av_scripts:inventorySaved",src,type,id)
end)
secondInv.label = newLabel or 'Stash-' .. id
RegisterNetEvent('inventory:server:OpenInventory', function(name, id, other, newLabel) -- ADD IT HERE
local src = source
local ply = Player(src)
local Player = QBCore.Functions.GetPlayer(src)
if ply.state.inv_busy then
return QBCore.Functions.Notify(src, Lang:t('notify.noaccess'), 'error')
end
if name and id then
local secondInv = {}
if name == 'stash' then
if Stashes[id] then
if Stashes[id].isOpen then
local Target = QBCore.Functions.GetPlayer(Stashes[id].isOpen)
if Target then
TriggerClientEvent('inventory:client:CheckOpenState', Stashes[id].isOpen, name, id, Stashes[id].label)
else
Stashes[id].isOpen = false
end
end
end
local maxweight = 1000000
local slots = 50
if other then
maxweight = other.maxweight or 1000000
slots = other.slots or 50
end
secondInv.name = 'stash-' .. id
secondInv.label = newLabel or 'Stash-' .. id -- REPLACE HERE
-- There's more code than this in your inventory
-- So please DON'T copy/paste any of this code to your inventory, just add the needed lines
-- av-scripts export:
function WipeStash(id) -- for old qb-inventory
Stashes[id] = {}
Stashes[id].items = {}
SaveStashItems(id, Stashes[id].items)
end
exports('addStashItem', AddToStash)
exports('addTrunkItems', addTrunkItems)
exports("GetStashItems", GetStashItems)
exports("SaveStashItems",SaveStashItems)
exports('RemoveFromStash', RemoveFromStash)
exports("WipeStash", WipeStash)