Fixed major item bug

master
AlmTech Software 5 years ago
parent df827d3b9e
commit 84fbe253b0
  1. 12
      gamemode/engine/lib/server/sv_inventory.lua
  2. 1
      gamemode/engine/lib/server/sv_networking.lua
  3. 1
      gamemode/settings/sh_items.lua
  4. 4
      gamemode/shared.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

@ -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 )

@ -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 )

@ -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
Loading…
Cancel
Save