diff --git a/gamemode/core/meta/sh_inventory.lua b/gamemode/core/meta/sh_inventory.lua index ffd3db3c..67a951c2 100644 --- a/gamemode/core/meta/sh_inventory.lua +++ b/gamemode/core/meta/sh_inventory.lua @@ -338,19 +338,15 @@ end -- @treturn number The Y position that the item was removed from function META:Remove(id, bNoReplication, bNoDelete, bTransferring) local x2, y2 + local item = ix.item.instances[id] - for x = 1, self.w do - if (self.slots[x]) then - for y = 1, self.h do - local item = self.slots[x][y] - - if (item and item.id == id) then - self.slots[x][y] = nil + if (item and item.invID == self.id) then + local x, y = item.gridX, item.gridY + if (self.slots[x] and self.slots[x][y] and self.slots[x][y].id == id) then + self.slots[x][y] = nil - x2 = x2 or x - y2 = y2 or y - end - end + x2 = x + y2 = y end end @@ -370,8 +366,6 @@ function META:Remove(id, bNoReplication, bNoDelete, bTransferring) end if (!bNoDelete) then - local item = ix.item.instances[id] - if (item and item.OnRemoved) then item:OnRemoved() end diff --git a/gamemode/core/meta/sh_item.lua b/gamemode/core/meta/sh_item.lua index a95845d6..f65d04de 100644 --- a/gamemode/core/meta/sh_item.lua +++ b/gamemode/core/meta/sh_item.lua @@ -419,38 +419,10 @@ function ITEM:Remove(bNoReplication, bNoDelete) local inv = ix.item.inventories[self.invID] if (self.invID > 0 and inv) then - local failed = false - - for x = self.gridX, self.gridX + (self.width - 1) do - if (inv.slots[x]) then - for y = self.gridY, self.gridY + (self.height - 1) do - local item = inv.slots[x][y] - - if (item and item.id == self.id) then - inv.slots[x][y] = nil - else - failed = true - end - end - end - end - - if (failed) then - inv.slots = {} - for k, _ in inv:Iter() do - if (k.invID == inv:GetID()) then - for x = self.gridX, self.gridX + (self.width - 1) do - for y = self.gridY, self.gridY + (self.height - 1) do - inv.slots[x][y] = k.id - end - end - end - end - - if (IsValid(inv.owner) and inv.owner:IsPlayer()) then - inv:Sync(inv.owner, true) - end - + local x, y = self.gridX, self.gridY + if (inv.slots[x] and inv.slots[x][y] and inv.slots[x][y].id == self.id) then + inv.slots[x][y] = nil + else return false end else