From 53982348a6c187cd9de776c6ec7d12e86e166ff7 Mon Sep 17 00:00:00 2001 From: AlmTech Software Date: Tue, 31 Dec 2019 15:48:39 +0100 Subject: [PATCH] Bug fixes --- gamemode/engine/lib/server/sv_inventory.lua | 2 ++ gamemode/engine/lib/sh_items.lua | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) 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