local plyMeta = FindMetaTable( "Player" ) function plyMeta:AddInventoryItem(ent, count) local eq = loadData(self,"Inventory") if eq == nil then eq = {} for i=1,16 do eq[i] = {} eq[i].isOccupied = false eq[i].Count = 0 eq[i].Name = "unknown" eq[i].ItemClass = "unknown" eq[i].WeaponClass = "unknown" eq[i].SingleWeight = 0 end end local totalWeight = getTotalWeight(eq) for i, slot in ipairs(eq) do if ent.StackSize == nil then ent.StackSize = 1 end if slot.isOccupied == false or (ent.StackSize > slot.Count and slot.ItemClass == ent:GetClass()) then if ent.Weight ~= nil then slot.SingleWeight = ent.Weight else slot.SingleWeight = 1 end if (slot.SingleWeight + totalWeight) <= getMaxWeight(self, "Inventory") then slot.isOccupied = true if ent.Name ~= nil then slot.Name = ent.Name else slot.Name = ent:GetClass() end slot.ItemClass = ent:GetClass() slot.Count = slot.Count + 1 slot.Model = ent:GetModel() slot.MaxStack = ent.StackSize if slot.ItemClass == "spawned_weapon" then slot.WeaponClass = ent:GetWeaponClass() else slot.WeaponClass = nil end saveData(self, eq,"Inventory") if ent:GetClass() == "spawned_weapon" and ent:Getamount() > 1 then ent:Setamount(ent:Getamount()-1) else ent:Remove() end self:EmitSound(InventoryConfig.Sounds.pickUp) return else showNotification(self, InventoryConfig.Messages.tooHeavy) return end end end -- no space showNotification(ply, InventoryConfig.Messages.noSpace) end