ox_inventory

These modifications can only be made if you use the ox_inventory

  • Add the following function at the end of the file

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
  • Below the previous function, add the export of it

ox_inventory/modules/inventory/server.lua
exports('SetStash', Inventory.SetStash)

Last updated