diff --git a/gamemode/engine/lib/server/sv_inventory.lua b/gamemode/engine/lib/server/sv_inventory.lua index 382059c..7cab3fb 100644 --- a/gamemode/engine/lib/server/sv_inventory.lua +++ b/gamemode/engine/lib/server/sv_inventory.lua @@ -49,7 +49,7 @@ function Quantum.Server.Inventory.EquipItem( pl, itemindex ) if( itemTbl.equipeffect != nil ) then Quantum.Effect.Give( pl, itemTbl.equipeffect ) -- give the player the effect end - + Quantum.Debug( tostring(pl) .. " equipped item (" .. tostring(slotitem[1]) .. ")" ) -- NETWORKING -- Quantum.Net.Inventory.Update( pl ) -- update the client @@ -81,8 +81,8 @@ function Quantum.Server.Inventory.SetSlotItem( pl, char, pos, itemid, amount ) else local item = Quantum.Item.Get( itemid ) if( isEquippable( item ) || !isStackable( item ) ) then - amount = nil - setItemTbl = { itemid } + amount = 1 + setItemTbl = { itemid, amount } else amount = amount || 1 setItemTbl = { itemid, amount } @@ -91,6 +91,7 @@ function Quantum.Server.Inventory.SetSlotItem( pl, char, pos, itemid, amount ) char.inventory[pos] = setItemTbl -- remove the item -- Sent the new data to the client + amount = amount || 1 Quantum.Net.Inventory.SetItem( pl, pos, itemid, amount ) end @@ -99,8 +100,11 @@ function Quantum.Server.Inventory.GetSlotItem( char, pos ) return char.inventory function Quantum.Server.Inventory.FindStackable( char, item ) if( item.stack ) then local inv = Quantum.Server.Char.GetInventory( char ) + local itemInSlotAmount for i, item2 in pairs( inv ) do - if( item2[1] == item.id && item2[2] < item.stack ) then -- if the item is stackable and it is the same item + itemInSlotAmount = item2[2] || 1 + print( itemInSlotAmount, item.stack ) + if( item2[1] == item.id && itemInSlotAmount < item.stack ) then -- if the item is stackable and it is the same item return i -- return its index end end diff --git a/gamemode/engine/lib/server/sv_networking.lua b/gamemode/engine/lib/server/sv_networking.lua index b763b04..7bd15dd 100644 --- a/gamemode/engine/lib/server/sv_networking.lua +++ b/gamemode/engine/lib/server/sv_networking.lua @@ -126,6 +126,7 @@ function Quantum.Net.Inventory.SetItem( pl, index, itemid, amount ) -- sends a i Quantum.WriteIntcode( Quantum.IntCode.SET_ITEM ) -- write the opcode first net.WriteInt( index, Quantum.calculateNeededBits( Quantum.Inventory.Size ) ) net.WriteString( itemid ) + print( amount, Quantum.calculateNeededBits( Quantum.Inventory.MaxStackSize ) ) net.WriteInt( amount, Quantum.calculateNeededBits( Quantum.Inventory.MaxStackSize ) ) net.Send( pl ) diff --git a/gamemode/settings/sh_items.lua b/gamemode/settings/sh_items.lua index ea06960..37e01a1 100644 --- a/gamemode/settings/sh_items.lua +++ b/gamemode/settings/sh_items.lua @@ -44,6 +44,7 @@ Quantum.Item.Create( "potatoe", { stack = 1, soulbound = false, rarity = Quantum.Rarity.Legendary, + equipslot = Quantum.EquipSlots.Head, consumefunction = function( user ) Quantum.Notify.Info( user, "You consumed a legendary potatoe! You now have 1000 health for 10 seconds!" ) user:SetHealth( 1000 ) diff --git a/gamemode/shared.lua b/gamemode/shared.lua index a0c1f27..cb23c19 100644 --- a/gamemode/shared.lua +++ b/gamemode/shared.lua @@ -13,8 +13,8 @@ GM.Website = "N/A" Quantum = {} Quantum.Version = "v0.3-alpha" -include( "engine/vars/sh_vars.lua" ) -- include the shared constant vars - include( "engine/sh_debug.lua" ) -- add the debug functions and stuff include( "settings/sh_settings.lua" ) + +include( "engine/vars/sh_vars.lua" ) -- include the shared constant vars \ No newline at end of file