diff --git a/gamemode/engine/lib/server/sv_inventory.lua b/gamemode/engine/lib/server/sv_inventory.lua index 4e6dcf0..8b29b2f 100644 --- a/gamemode/engine/lib/server/sv_inventory.lua +++ b/gamemode/engine/lib/server/sv_inventory.lua @@ -108,6 +108,8 @@ function Quantum.Server.Inventory.GiveItem( pl, itemid, amount ) local inv = Quantum.Server.Char.GetInventory( char ) local item = Quantum.Item.Get( itemid ) + if( item == nil ) then Quantum.Error( "Tried to give " .. tostring(pl) .. " a non-existent item! Item '" .. tostring(itemid) .. "' does not exist." ) return end + if( #inv + 1 <= Quantum.Inventory.Width * Quantum.Inventory.Height || Quantum.Server.Inventory.FindStackable( char, item ) != nil ) then sortItem( char, itemid, amount ) diff --git a/gamemode/engine/lib/sh_items.lua b/gamemode/engine/lib/sh_items.lua index 9f9b2b1..2111259 100644 --- a/gamemode/engine/lib/sh_items.lua +++ b/gamemode/engine/lib/sh_items.lua @@ -21,7 +21,7 @@ function Quantum.Item.Create( itemid, args ) usefunction = args.usefunction, -- use function consumefunction = args.consumefunction --consume function } - math.Clamp( item.stack, 1, Quantum.Inventory.MaxStackSize ) -- clamp it so it does not go over the max size + item.stack = math.Clamp( item.stack, 1, Quantum.Inventory.MaxStackSize ) -- clamp it so it does not go over the max size Quantum.Items[itemid] = item return item end