Fixed item stacking bug

master
AlmTech Software 5 years ago
parent 1330d1bc41
commit 10c35355e5
  1. 14
      gamemode/engine/lib/server/sv_inventory.lua

@ -91,12 +91,18 @@ local function sortItem( char, itemid, amount )
if( itemInSlot != nil ) then if( itemInSlot != nil ) then
if( itemInSlot[1] == itemid && itemInSlot[2] < stacksize ) then if( itemInSlot[1] == itemid && itemInSlot[2] < stacksize ) then
local setAmt = math.Clamp( itemInSlot[2] + amount, 1, stacksize ) local add = itemInSlot[2] + amount
local diff = ( itemInSlot[2] + amount ) - setAmt if( add > stacksize ) then
rest = rest - diff ------------------------------------------------------ FIX THIS (DIFF IS WRONG) rest = rest - ( stacksize - itemInSlot[2] )
else
rest = rest - amount
end
local setAmt = math.Clamp( add, 1, stacksize )
--local diff = amount - setAmt
--rest = rest - diff ------------------------------------------------------ FIX THIS (DIFF IS WRONG)
Quantum.Server.Inventory.SetSlotItem( char, index, itemid, setAmt ) Quantum.Server.Inventory.SetSlotItem( char, index, itemid, setAmt )
print( "1", setAmt, rest, index, diff ) print( "1", setAmt, rest, index )
end end
else else
local setAmt = math.Clamp( amount, 1, stacksize ) local setAmt = math.Clamp( amount, 1, stacksize )

Loading…
Cancel
Save