|
|
@ -49,7 +49,7 @@ function Quantum.Server.Inventory.EquipItem( pl, itemindex ) |
|
|
|
if( itemTbl.equipeffect != nil ) then |
|
|
|
if( itemTbl.equipeffect != nil ) then |
|
|
|
Quantum.Effect.Give( pl, itemTbl.equipeffect ) -- give the player the effect |
|
|
|
Quantum.Effect.Give( pl, itemTbl.equipeffect ) -- give the player the effect |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
Quantum.Debug( tostring(pl) .. " equipped item (" .. tostring(slotitem[1]) .. ")" ) |
|
|
|
-- NETWORKING -- |
|
|
|
-- NETWORKING -- |
|
|
|
Quantum.Net.Inventory.Update( pl ) -- update the client |
|
|
|
Quantum.Net.Inventory.Update( pl ) -- update the client |
|
|
|
|
|
|
|
|
|
|
@ -81,8 +81,8 @@ function Quantum.Server.Inventory.SetSlotItem( pl, char, pos, itemid, amount ) |
|
|
|
else |
|
|
|
else |
|
|
|
local item = Quantum.Item.Get( itemid ) |
|
|
|
local item = Quantum.Item.Get( itemid ) |
|
|
|
if( isEquippable( item ) || !isStackable( item ) ) then |
|
|
|
if( isEquippable( item ) || !isStackable( item ) ) then |
|
|
|
amount = nil |
|
|
|
amount = 1 |
|
|
|
setItemTbl = { itemid } |
|
|
|
setItemTbl = { itemid, amount } |
|
|
|
else |
|
|
|
else |
|
|
|
amount = amount || 1 |
|
|
|
amount = amount || 1 |
|
|
|
setItemTbl = { itemid, amount } |
|
|
|
setItemTbl = { itemid, amount } |
|
|
@ -91,6 +91,7 @@ function Quantum.Server.Inventory.SetSlotItem( pl, char, pos, itemid, amount ) |
|
|
|
|
|
|
|
|
|
|
|
char.inventory[pos] = setItemTbl -- remove the item |
|
|
|
char.inventory[pos] = setItemTbl -- remove the item |
|
|
|
-- Sent the new data to the client |
|
|
|
-- Sent the new data to the client |
|
|
|
|
|
|
|
amount = amount || 1 |
|
|
|
Quantum.Net.Inventory.SetItem( pl, pos, itemid, amount ) |
|
|
|
Quantum.Net.Inventory.SetItem( pl, pos, itemid, amount ) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -99,8 +100,11 @@ function Quantum.Server.Inventory.GetSlotItem( char, pos ) return char.inventory |
|
|
|
function Quantum.Server.Inventory.FindStackable( char, item ) |
|
|
|
function Quantum.Server.Inventory.FindStackable( char, item ) |
|
|
|
if( item.stack ) then |
|
|
|
if( item.stack ) then |
|
|
|
local inv = Quantum.Server.Char.GetInventory( char ) |
|
|
|
local inv = Quantum.Server.Char.GetInventory( char ) |
|
|
|
|
|
|
|
local itemInSlotAmount |
|
|
|
for i, item2 in pairs( inv ) do |
|
|
|
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 |
|
|
|
return i -- return its index |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|