diff --git a/gamemode/engine/lib/server/sv_inventory.lua b/gamemode/engine/lib/server/sv_inventory.lua index d2cd3d4..382059c 100644 --- a/gamemode/engine/lib/server/sv_inventory.lua +++ b/gamemode/engine/lib/server/sv_inventory.lua @@ -11,7 +11,7 @@ Quantum.Inventory.Size = Quantum.Inventory.Width * Quantum.Inventory.Height function Quantum.Server.Inventory.Create( char ) char.inventory = {} - char.equiped = { + char.equipped = { [Quantum.EquipSlots.Head] = -1, -- -1 means that it is empty [Quantum.EquipSlots.Chest] = -1, [Quantum.EquipSlots.Legs] = -1, @@ -40,14 +40,19 @@ function Quantum.Server.Inventory.EquipItem( pl, itemindex ) local equipslot = itemTbl.equipslot if( equipslot == nil ) then - Quantum.Error( tostring(pl) .. " tried to equip an non-equipable item: (" .. tostring(itemTbl[1]) .. ")" ) + Quantum.Error( tostring(pl) .. " tried to equip an non-equippable item: (" .. tostring(itemTbl[1]) .. ")" ) return else if( Quantum.EquipSlots[equipslot] != nil ) then - char.equiped[equipslot] = slotitem[1] -- set it in the table + + char.equipped[equipslot] = slotitem[1] -- set it in the table if( itemTbl.equipeffect != nil ) then Quantum.Effect.Give( pl, itemTbl.equipeffect ) -- give the player the effect end + + -- NETWORKING -- + Quantum.Net.Inventory.Update( pl ) -- update the client + else Quantum.Error( tostring(pl) .. " tried to equip an item in a non-existent equip slot: (" .. tostring(equipslot) .. ")" ) return @@ -56,6 +61,19 @@ function Quantum.Server.Inventory.EquipItem( pl, itemindex ) end end +function Quantum.Server.Inventory.UnEquipItem( pl, equipslot ) + local char = Quantum.Server.Char.GetCurrentCharacter( pl ) + if( char.equipped[equipslot] != nil && char.equipped[equipslot] != -1 ) then + local itemTbl = Quantum.Item.Get( char.equipped[equipslot] ) + + if( itemTbl.equipeffect != nil ) then -- remove the items effect + Quantum.Effect.Remove( pl, itemTbl.equipeffect ) + end + + char.equipped[equipslot] = nil + end +end + function Quantum.Server.Inventory.SetSlotItem( pl, char, pos, itemid, amount ) local setItemTbl = {} if( amount < 1 ) then diff --git a/gamemode/engine/lib/sh_effects.lua b/gamemode/engine/lib/sh_effects.lua index ea3228e..d523d14 100644 --- a/gamemode/engine/lib/sh_effects.lua +++ b/gamemode/engine/lib/sh_effects.lua @@ -79,7 +79,7 @@ if SERVER then -- server only functions end end - function Quantum.Effects.RemoveAll( pl ) + function Quantum.Effect.RemoveAll( pl ) local char = Quantum.Server.Char.GetCurrentCharacter( pl ) if( char.effects != nil ) then Quantum.Debug( "Removing all " .. tostring(pl) .. " effects." ) @@ -113,7 +113,7 @@ if SERVER then -- server only functions end hook.Add( "PlayerDeath", "Quantum_Effects_LooseOnDeath", function( ply ) - Quantum.Effects.RemoveAll( ply ) -- remove all effects + Quantum.Effect.RemoveAll( ply ) -- remove all effects end) end \ No newline at end of file