ox_inventory/modules/inventory/server.lua
function Inventory.SetStash(stashid, items)
local items = items
local stash = Inventory(stashid)
if not stash then return end
Inventory.CloseAll(stash)
stash.changed = true
stash.items = {}
stash.weight = 0
for k,i in pairs(items) do
if i.name then
local item = Items(i.name)
if item then
local metadata, count = Items.Metadata(stash, item, i.metadata or {}, i.count)
local slotWeight = Inventory.SlotWeight(item, {count=count, metadata=metadata})
stash.weight += slotWeight
stash.items[i.slot] = {name = item.name, label = item.label, degrade = i.degrade or 0, weight = slotWeight, slot = i.slot, count = count, description = item.description, metadata = metadata, stack = item.stack, close = item.close}
end
end
end
Inventories[stash.id] = stash
Inventory.Save(stash)
end
ox_inventory/modules/inventory/server.lua
exports('SetStash', Inventory.SetStash)