Skip to content

Commit

Permalink
feat(server/inventory): GetContainerFromSlot
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed May 9, 2023
1 parent d42d65b commit ae0c45b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modules/inventory/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,26 @@ exports('GetInventoryItems', function(inv, owner)
return getInventory(inv, owner)?.items
end)

---@param inv inventory
---@param slotId number
---@return OxInventory?
function Inventory.GetContainerFromSlot(inv, slotId)
local inventory = Inventory(inv)
local slotData = inventory and inventory.items[slotId]

if not slotData then return end

local container = Inventory(slotData.metadata.container)

if not container then
container = Inventory.Create(slotData.metadata.container, slotData.label, 'container', slotData.metadata.size[1], 0, slotData.metadata.size[2], false)
end

return container
end

exports('GetContainerFromSlot', Inventory.GetContainerFromSlot)

---@param inv? inventory
---@param ignoreId? number|false
function Inventory.CloseAll(inv, ignoreId)
Expand Down

0 comments on commit ae0c45b

Please sign in to comment.