示例#1
0
        public static bool CreateEntity(Network.GamePackets.EnitityCreate eC, Client.GameState client, ref string message)
        {
            if (eC.Name.Length > 16)
                eC.Name = eC.Name.Substring(0, 16);
            if (eC.Name == "")
                return false;

            if (InvalidCharacters(eC.Name))
            {
                message = "Invalid characters inside the name.";
                return false;
            }
            var rdr = new MySqlReader(new MySqlCommand(MySqlCommandType.SELECT).Select("entities").Where("name", eC.Name));
            if (rdr.Read())
            {
                rdr.Close();
                message = "The chosen name is already in use.";
                return false;
            }
            rdr.Close();
            client.Entity = new Game.Entity(Game.EntityFlag.Player, false);
            client.Entity.Name = eC.Name;
            DataHolder.GetStats(eC.Class, 1, client);
            client.Entity.UID = Program.EntityUID.Next;
            new MySqlCommand(MySqlCommandType.UPDATE).Update("configuration").Set("EntityID", client.Entity.UID).Where("Server", ServerBase.Constants.ServerName).Execute();
            client.CalculateStatBonus();
            client.CalculateHPBonus();
            client.Entity.Hitpoints = client.Entity.MaxHitpoints;
            client.Entity.Mana = (ushort)(client.Entity.Spirit * 5);
            client.Entity.Class = eC.Class;
            client.Entity.Body = eC.Body;
            if (eC.Body == 1003 || eC.Body == 1004)
                client.Entity.Face = (ushort)ServerBase.Kernel.Random.Next(1, 50);
            else
                client.Entity.Face = (ushort)ServerBase.Kernel.Random.Next(201, 250);
            byte Color = (byte)ServerBase.Kernel.Random.Next(4, 8);
            client.Entity.HairStyle = (ushort)(Color * 100 + 10 + (byte)ServerBase.Kernel.Random.Next(4, 9));
            client.Account.EntityID = client.Entity.UID;
            client.Account.Save();
            //723753

            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT);
            cmd.Insert("entities").Insert("Name", eC.Name).Insert("Owner", client.Account.Username).Insert("Class", eC.Class).Insert("UID", client.Entity.UID)
                .Insert("Hitpoints", client.Entity.Hitpoints).Insert("Mana", client.Entity.Mana).Insert("Body", client.Entity.Body)
                .Insert("Face", client.Entity.Face).Insert("HairStyle", client.Entity.HairStyle).Insert("Strength", client.Entity.Strength)
                .Insert("Agility", client.Entity.Agility).Insert("Vitality", client.Entity.Vitality).Insert("Spirit", client.Entity.Spirit);

            cmd.Execute();
            message = "ANSWER_OK";

            return true;
        }
        public Reincarnation(Client.GameState client, byte new_class)
        {
            if (client.Entity.Level < 130)
                return;
            _client = client;
            RemoveSkill = new SafeDictionary<ushort, PhoenixProject.Interfaces.ISkill>(500);
            Addskill = new SafeDictionary<ushort, PhoenixProject.Interfaces.ISkill>(500);
            #region Low level items
            for (byte i = 1; i < 9; i++)
            {
                if (i != 7)
                {
                    Interfaces.IConquerItem item = client.Equipment.TryGetItem(i);
                    if (item != null && item.ID != 0)
                    {
                        try

                        {
                            //client.UnloadItemStats(item, false);
                            Database.ConquerItemInformation cii = new PhoenixProject.Database.ConquerItemInformation(item.ID, item.Plus);
                            item.ID = cii.LowestID(Network.PacketHandler.ItemMinLevel(Network.PacketHandler.ItemPosition(item.ID)));
                            item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                            item.Send(client);
                            client.LoadItemStats(client.Entity);
                            Database.ConquerItemTable.UpdateItemID(item, client);
                        }
                        catch
                        {
                            Console.WriteLine("Reborn item problem: " + item.ID);
                        }
                    }
                }
            }
            Interfaces.IConquerItem hand = client.Equipment.TryGetItem(5);
            if (hand != null)
            {
                client.Equipment.Remove(5);
                client.CalculateStatBonus();
                client.CalculateHPBonus();
                client.SendStatMessage();
            }
            else
                //client.Screen.send(client.Entity.SpawnPacket, false);
            #endregion

            #region Remove Extra Skill
            if (client.Entity.FirstRebornClass == 15 && client.Entity.SecondRebornClass == 15 && client.Entity.Class == 15)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.DragonWhirl);
            }
            if (client.Entity.FirstRebornClass == 25 && client.Entity.SecondRebornClass == 25 && client.Entity.Class == 25)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.Perseverance);
            }
            if (client.Entity.FirstRebornClass == 45 && client.Entity.SecondRebornClass == 45 && client.Entity.Class == 45)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.StarArrow);
            }
            if (client.Entity.FirstRebornClass == 55 && client.Entity.SecondRebornClass == 55 && client.Entity.Class == 55)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.PoisonStar);
            }
            if (client.Entity.FirstRebornClass == 65 && client.Entity.SecondRebornClass == 65 && client.Entity.Class == 65)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.SoulShackle);
            }
            if (client.Entity.FirstRebornClass == 135 && client.Entity.SecondRebornClass == 135 && client.Entity.Class == 135)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.AzureShield);
            }
            if (client.Entity.FirstRebornClass == 145 && client.Entity.SecondRebornClass == 145 && client.Entity.Class == 145)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.HeavenBlade);
            }
            #endregion
            Database.ReincarnationTable.NewReincarnated(client.Entity);
            Game.Features.Reincarnation.ReincarnateInfo info = new Game.Features.Reincarnation.ReincarnateInfo();
            info.UID = client.Entity.UID;
            info.Level = client.Entity.Level;
            info.Experience = client.Entity.Experience;
            ServerBase.Kernel.ReincarnatedCharacters.Add(info.UID, info);
            client.Entity.FirstRebornClass = client.Entity.SecondRebornClass;
            client.Entity.SecondRebornClass = client.Entity.Class;
            client.Entity.Class = new_class;
            client.Entity.SecondRebornLevel = client.Entity.Level;
            client.Entity.Level = 15;
            client.Entity.Experience = 0;
            client.Entity.Atributes =
             (ushort)(client.ExtraAtributePoints(client.Entity.FirstRebornClass, client.Entity.FirstRebornLevel) +
              client.ExtraAtributePoints(client.Entity.SecondRebornClass, client.Entity.SecondRebornLevel) + 62);

            client.Spells.Clear();
            client.Spells = new SafeDictionary<ushort, PhoenixProject.Interfaces.ISkill>(100);
            switch (client.Entity.FirstRebornClass)
            {
                case 15:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Cyclone);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Hercules);
                        Add(PhoenixProject.Game.Enums.SkillIDs.SpiritHealing);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Robot);
                        break;
                    }
                case 25:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.SuperMan);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Dash);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Shield);
                        break;
                    }
                case 45:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Intensify);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Scatter);
                        Add(PhoenixProject.Game.Enums.SkillIDs.RapidFire);
                        Add(PhoenixProject.Game.Enums.SkillIDs.XPFly);
                        Add(PhoenixProject.Game.Enums.SkillIDs.AdvancedFly);
                        break;
                    }
                case 55:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.FatalStrike);
                        Add(PhoenixProject.Game.Enums.SkillIDs.ShurikenVortex);
                        Add(PhoenixProject.Game.Enums.SkillIDs.ToxicFog);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TwofoldBlades);
                        Add(PhoenixProject.Game.Enums.SkillIDs.PoisonStar);

                        break;
                    }
                case 65:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.RadiantPalm);
                        Add(PhoenixProject.Game.Enums.SkillIDs.WhirlWindKick);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TripleAttack);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Oblivion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Serenity);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Compassion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.DeflectionAura);
                        break;
                    }
                case 75:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.RadiantPalm);
                        Add(PhoenixProject.Game.Enums.SkillIDs.WhirlWindKick);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TripleAttack);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Oblivion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Serenity);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Compassion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.DeflectionAura);
                        break;
                    }
                case 135:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Thunder);
                        Add(PhoenixProject.Game.Enums.SkillIDs.WaterElf);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Cure);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Lightning);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Volcano);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Pray);
                        Add(PhoenixProject.Game.Enums.SkillIDs.AdvancedCure);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Meditation);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Stigma);
                        break;
                    }
                case 140:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Thunder);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Cure);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Lightning);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Tornado);
                        Add(PhoenixProject.Game.Enums.SkillIDs.FireCircle);
                        Add(PhoenixProject.Game.Enums.SkillIDs.FireMeteor);
                        Add(PhoenixProject.Game.Enums.SkillIDs.FireRing);
                        break;
                    }

            }

            byte PreviousClass = client.Entity.FirstRebornClass;
            byte toClass = (byte)(client.Entity.SecondRebornClass - 4);

            Interfaces.ISkill[] ADD_spells = this.Addskill.Values.ToArray();
            foreach (Interfaces.ISkill skill in ADD_spells)
            {
                skill.Available = true;
                if (!client.Spells.ContainsKey(skill.ID))
                    client.Spells.Add(skill.ID, skill);
            }
            #region Spells
            Interfaces.ISkill[] spells = client.Spells.Values.ToArray();
            foreach (Interfaces.ISkill spell in spells)
            {
                spell.PreviousLevel = spell.Level;
                spell.Level = 0;
                spell.Experience = 0;
                #region Pirate
                if (PreviousClass == 75)
                {
                    if (client.Entity.Class != 71)
                    {
                        switch (spell.ID)
                        {
                            case 10490:
                            case 10415:
                            case 10381:
                                client.RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                #region Monk
                if (PreviousClass == 65)
                {
                    if (client.Entity.Class != 61)
                    {
                        switch (spell.ID)
                        {
                            case 10490:
                            case 10415:
                            case 10381:
                                client.RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                #region Warrior
                if (PreviousClass == 25)
                {
                    if (client.Entity.Class != 21)
                    {
                        switch (spell.ID)
                        {
                            case 1025:
                                if (client.Entity.Class != 21 && client.Entity.Class != 132)
                                    client.RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                #region Ninja
                if (toClass != 51)
                {
                    switch (spell.ID)
                    {
                        case 6010:
                        case 6000:
                        case 6011:
                            client.RemoveSpell(spell);
                            break;
                    }
                }
                #endregion
                #region Trojan
                if (toClass != 11)
                {
                    switch (spell.ID)
                    {
                        case 1115:
                            client.RemoveSpell(spell);
                            break;
                    }
                }
                #endregion
                #region Archer
                if (toClass != 41)
                {
                    switch (spell.ID)
                    {
                        case 8001:
                        case 8000:
                        case 8003:
                        case 9000:
                        case 8002:
                        case 8030:
                            client.RemoveSpell(spell);
                            break;
                    }
                }
                #endregion
                #region WaterTaoist
                if (PreviousClass == 135)
                {
                    if (toClass != 132)
                    {
                        switch (spell.ID)
                        {
                            case 1000:
                            case 1001:
                            case 1010:
                            case 1125:
                            case 1100:
                            case 8030:
                                client.RemoveSpell(spell);
                                break;
                            case 1050:
                            case 1175:
                            case 1170:
                                if (toClass != 142)
                                    client.RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                #region FireTaoist
                if (PreviousClass == 145)
                {
                    if (toClass != 142)
                    {
                        switch (spell.ID)
                        {
                            case 1000:
                            case 1001:
                            case 1150:
                            case 1180:
                            case 1120:
                            case 1002:
                            case 1160:
                            case 1165:
                                client.RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                if (client.Spells.ContainsKey(spell.ID))
                    if (spell.ID != (ushort)Game.Enums.SkillIDs.Reflect)
                        spell.Send(client);
            }
            #endregion
            Add(PhoenixProject.Game.Enums.SkillIDs.Bless);

            Addskill.Clear();
            Addskill = new SafeDictionary<ushort, PhoenixProject.Interfaces.ISkill>(100);

            PreviousClass = client.Entity.SecondRebornClass;
            toClass = client.Entity.Class;
            switch (client.Entity.SecondRebornClass)
            {
                case 15:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Robot);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Cyclone);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Hercules);
                        Add(PhoenixProject.Game.Enums.SkillIDs.SpiritHealing);

                        break;
                    }
                case 25:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.SuperMan);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Dash);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Shield);
                        break;
                    }
                case 45:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Intensify);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Scatter);
                        Add(PhoenixProject.Game.Enums.SkillIDs.RapidFire);
                        Add(PhoenixProject.Game.Enums.SkillIDs.XPFly);
                        Add(PhoenixProject.Game.Enums.SkillIDs.AdvancedFly);
                        break;
                    }
                case 55:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.FatalStrike);
                        Add(PhoenixProject.Game.Enums.SkillIDs.ShurikenVortex);
                        Add(PhoenixProject.Game.Enums.SkillIDs.ToxicFog);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TwofoldBlades);
                        break;
                    }
                case 65:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.RadiantPalm);
                        Add(PhoenixProject.Game.Enums.SkillIDs.WhirlWindKick);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TripleAttack);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Oblivion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Serenity);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Compassion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.DeflectionAura);
                        break;
                    }
                case 75:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.RadiantPalm);
                        Add(PhoenixProject.Game.Enums.SkillIDs.WhirlWindKick);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TripleAttack);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Oblivion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Serenity);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Compassion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.DeflectionAura);
                        break;
                    }
                case 135:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Thunder);
                        Add(PhoenixProject.Game.Enums.SkillIDs.WaterElf);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Cure);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Lightning);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Volcano);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Pray);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Stigma);
                        Add(PhoenixProject.Game.Enums.SkillIDs.AdvancedCure);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Meditation);
                        break;
                    }
                case 140:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Thunder);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Cure);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Lightning);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Tornado);
                        Add(PhoenixProject.Game.Enums.SkillIDs.FireCircle);
                        Add(PhoenixProject.Game.Enums.SkillIDs.FireMeteor);
                        Add(PhoenixProject.Game.Enums.SkillIDs.FireRing);
                        break;
                    }

            }

            //PreviousClass = client.Entity.FirstRebornClass;
            //toClass = client.Entity.SecondRebornClass;
            Add(PhoenixProject.Game.Enums.SkillIDs.Bless);

            Interfaces.ISkill[] aADD_spells = this.Addskill.Values.ToArray();
            foreach (Interfaces.ISkill skill in aADD_spells)
            {
                skill.Available = true;
                if (!client.Spells.ContainsKey(skill.ID))
                    client.Spells.Add(skill.ID, skill);
            }
            #region Spells
            Interfaces.ISkill[] aspells = client.Spells.Values.ToArray();
            foreach (Interfaces.ISkill aspell in spells)
            {
                aspell.PreviousLevel = aspell.Level;
                aspell.Level = 0;
                aspell.Experience = 0;
                #region Pirate
                if (PreviousClass == 75)
                {
                    if (client.Entity.Class != 71)
                    {
                        switch (aspell.ID)
                        {
                            case 10490:
                            case 10415:
                            case 10381:
                                client.RemoveSpell(aspell);
                                break;
                        }
                    }
                }
                #endregion
                #region Monk
                if (PreviousClass == 65)
                {
                    if (client.Entity.Class != 61)
                    {
                        switch (aspell.ID)
                        {
                            case 10490:
                            case 10415:
                            case 10381:
                                client.RemoveSpell(aspell);
                                break;
                        }
                    }
                }
                #endregion
                #region Warrior
                if (PreviousClass == 25)
                {
                    if (client.Entity.Class != 21)
                    {
                        switch (aspell.ID)
                        {
                            case 1025:
                                if (client.Entity.Class != 21 && client.Entity.Class != 132)
                                    client.RemoveSpell(aspell);
                                break;
                        }
                    }
                }
                #endregion
                #region Ninja
                if (toClass != 51)
                {
                    switch (aspell.ID)
                    {
                        case 6010:
                        case 6000:
                        case 6011:
                            client.RemoveSpell(aspell);
                            break;
                    }
                }
                #endregion
                #region Trojan
                if (toClass != 11)
                {
                    switch (aspell.ID)
                    {
                        case 1115:
                            client.RemoveSpell(aspell);
                            break;
                    }
                }
                #endregion
                #region Archer
                if (toClass != 41)
                {
                    switch (aspell.ID)
                    {
                        case 8001:
                        case 8000:
                        case 8003:
                        case 9000:
                        case 8002:
                        case 8030:
                            client.RemoveSpell(aspell);
                            break;
                    }
                }
                #endregion
                #region WaterTaoist
                if (PreviousClass == 135)
                {
                    if (toClass != 132)
                    {
                        switch (aspell.ID)
                        {
                            case 1000:
                            case 1001:
                            case 1010:
                            case 1125:
                            case 1100:
                            case 8030:
                                client.RemoveSpell(aspell);
                                break;
                            case 1050:
                            case 1175:
                            case 1170:
                                if (toClass != 142)
                                    client.RemoveSpell(aspell);
                                break;
                        }
                    }
                }
                #endregion
                #region FireTaoist
                if (PreviousClass == 145)
                {
                    if (toClass != 142)
                    {
                        switch (aspell.ID)
                        {
                            case 1000:
                            case 1001:
                            case 1150:
                            case 1180:
                            case 1120:
                            case 1002:
                            case 1160:
                            case 1165:
                                client.RemoveSpell(aspell);
                                break;
                        }
                    }
                }
                #endregion
                if (client.Spells.ContainsKey(aspell.ID))
                    if (aspell.ID != (ushort)Game.Enums.SkillIDs.Reflect)
                        aspell.Send(client);
            }
            #endregion
            Addskill.Clear();
            Addskill = new SafeDictionary<ushort, PhoenixProject.Interfaces.ISkill>(20);
            #region Add Extra Skill
            if (client.Entity.FirstRebornClass == 15 && client.Entity.SecondRebornClass == 15 && client.Entity.Class == 11)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.DragonWhirl);
            }
            if (client.Entity.FirstRebornClass == 25 && client.Entity.SecondRebornClass == 25 && client.Entity.Class == 21)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.Perseverance);
            }
            if (client.Entity.FirstRebornClass == 45 && client.Entity.SecondRebornClass == 45 && client.Entity.Class == 41)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.StarArrow);
            }
            if (client.Entity.FirstRebornClass == 55 && client.Entity.SecondRebornClass == 55 && client.Entity.Class == 55)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.PoisonStar);
                Add(PhoenixProject.Game.Enums.SkillIDs.CounterKill);
            }
            if (client.Entity.FirstRebornClass == 65 && client.Entity.SecondRebornClass == 65 && client.Entity.Class == 61)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.SoulShackle);
            }
            if (client.Entity.FirstRebornClass == 135 && client.Entity.SecondRebornClass == 135 && client.Entity.Class == 132)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.AzureShield);
            }
            if (client.Entity.FirstRebornClass == 145 && client.Entity.SecondRebornClass == 145 && client.Entity.Class == 142)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.HeavenBlade);
            }
            #endregion
            Interfaces.ISkill[] aaADD_spells = this.Addskill.Values.ToArray();
            foreach (Interfaces.ISkill skill in aaADD_spells)
            {
                skill.Available = true;
                if (!client.Spells.ContainsKey(skill.ID))
                    client.Spells.Add(skill.ID, skill);
            }

            #region Proficiencies
            foreach (Interfaces.ISkill proficiency in client.Proficiencies.Values)
            {
                proficiency.PreviousLevel = proficiency.Level;
                proficiency.Level = 0;
                proficiency.Experience = 0;
                proficiency.Send(client);
            }
            #endregion
            Database.DataHolder.GetStats(client.Entity.Class, client.Entity.Level, client);
            client.CalculateStatBonus();
            client.CalculateHPBonus();
            client.GemAlgorithm();
            client.SendStatMessage();
            Network.PacketHandler.WorldMessage(client.Entity.Name + " has got Reincarnation! Congratulations!");
        }
        static unsafe void HandlePacket(byte[] packet, Client.GameState client)
        {
            try
            {

                if (packet == null)
                    return;
                if (client == null)
                    return;
                fixed (byte* ptr = packet)
                {
                    var type = *((ushort*)(ptr + 2));
                    ushort Length = BitConverter.ToUInt16(packet, 0);
                    ushort ID = BitConverter.ToUInt16(packet, 2);

                    ushort ID2 = BitConverter.ToUInt16(packet, 4);
                    switch (ID)
                    {
                        #region Packet Spook Mob
                        case 2400:
                            {
                                client.Send(new NpcReply(NpcReply.MessageBox, "The Thrilling Spooks are sealed up, inside here Better speak to the Heavenly Master ,if you want more detalis"));
                                #region
                                client.OnMessageBoxOK =
                                delegate
                                {
                                    client.Entity.Teleport(8892, 28, 26);
                                };
                                client.OnMessageBoxCANCEL =
                                    delegate
                                    {
                                        client.OnMessageBoxEventParams = new object[0];
                                    };
                                #endregion

                                break;
                            }
                        #endregion
                        #region Arsenal [2201][2202][2203]
                        case 2202:
                            {
                                if (packet[16] == 0) packet[16] = 8;
                                client.Send(ArsenalPacket.ArsenalInscribedPage(client, packet, (PhoenixProject.Game.Features.Arsenal_ID)packet[16]));
                                break;
                            }
                        case 2203:
                            {
                                client.Send(ArsenalPacket.GuildArsenal(client));
                                if (client.Guild != null)
                                    if (client.Guild.Arsenal != null)
                                        client.Guild.Arsenal.Update(client.Guild);
                                byte pType = packet[4];
                                byte i_type = packet[8];
                                uint i_Uid = BitConverter.ToUInt32(packet, 12);

                                if (i_type == 0) i_type = 8;
                                switch (pType)
                                {
                                    case 0:
                                        {
                                            if (client.Guild != null)
                                                client.Guild.Arsenal.UnlockArsenal(client, (PhoenixProject.Game.Features.Arsenal_ID)i_type);
                                            break;
                                        }
                                    case 1:
                                        {
                                            PhoenixProject.Interfaces.IConquerItem Item = null;
                                            if (client.Inventory.TryGetItem(i_Uid, out Item))
                                            {
                                                if (client != null)
                                                {
                                                    if (Item != null)
                                                    {
                                                        if (i_type != 0 && i_type <= 8)
                                                        {
                                                            if (client.Guild != null)
                                                            {
                                                                if (client.Guild.Arsenal != null)
                                                                {
                                                                    client.Guild.Arsenal.InscribeItem(client, Item, (PhoenixProject.Game.Features.Arsenal_ID)i_type);
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            break;
                                        }
                                    case 2://Uninscribe
                                        {
                                            PhoenixProject.Game.Features.Arsenal_Client ac = null;
                                            if (client.Guild.Arsenal.Arsenals[(PhoenixProject.Game.Features.Arsenal_ID)i_type].Inscribed.TryGetValue(i_Uid, out ac))
                                                client.Guild.Arsenal.RemoveItem(client, ac.Item, (PhoenixProject.Game.Features.Arsenal_ID)i_type);
                                            break;
                                        }
                                    case 4:
                                        {
                                            client.Send(ArsenalPacket.GuildArsenal(client));
                                            break;
                                        }
                                }
                                break;
                            }
                        #endregion
                        #region EnitityCreate (1001)
                        case 1001:
                            {
                                if (client.Action == 1)
                                {
                                    EnitityCreate EC = new EnitityCreate();
                                    EC.Deserialize(packet);
                                    string Message = "";
                                    Boolean Created = Database.EntityTable.CreateEntity(EC, client, ref Message);
                                    client.Send(new Message(Message, "ALLUSERS", System.Drawing.Color.Orange, GamePackets.Message.PopUP));
                                    if (Created)
                                        Console.WriteLine(client.Account.Username + " Sucesfully Created a new Character " + EC.Name);
                                    client.JustCreated = true;
                                }
                                break;
                            }
                        #endregion
                        #region Chat/Message (1004)
                        case 1004:
                            {
                                if (client.Action != 2)
                                    return;
                                Message message = new Message();
                                message.Deserialize(packet);
                                if (message.__Message.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries).Length > 0)
                                    message.__Message = message.__Message.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries)[0];
                                Chat(message, client);
                                break;
                            }
                        #endregion
                        #region Item/Ping (1009)
                        case 1009:
                            {
                                if (client.Action != 2)
                                    return;
                                ItemUsage usage = new ItemUsage(false);
                                usage.Deserialize(packet);
                                if (!client.Entity.Dead || usage.ID == ItemUsage.Ping)
                                {
                                    switch (usage.ID)
                                    {
                                        case 53:
                                            {
                                                uint ItemAdd = BitConverter.ToUInt32(packet, 8);

                                                Interfaces.IConquerItem item_new = null;
                                                if (client.Inventory.TryGetItem(ItemAdd, out item_new))
                                                {
                                                    uint obtined_points = 0;
                                                    Database.ConquerItemInformation iteminfo = new PhoenixProject.Database.ConquerItemInformation(ItemAdd, 0);
                                                    Dictionary<uint, uint> amount = new Dictionary<uint, uint>();//packet[20]);
                                                    for (ushort i = 84; i < 84 + 4 * packet[20]; i += 4)
                                                    {
                                                        uint item_swap = BitConverter.ToUInt32(packet, i);
                                                        if (client.Inventory.ContainsUID(item_swap))
                                                        {
                                                            Interfaces.IConquerItem item = null;
                                                            if (client.Inventory.TryGetItem(item_swap, out item))
                                                            {
                                                                amount.Add(item_swap, i);
                                                            }
                                                            switch (item.ID)
                                                            {
                                                                case 191505:
                                                                case 191605:
                                                                case 191705:
                                                                case 191805:
                                                                case 191905:
                                                                case 191405:
                                                                case 183325:
                                                                case 183315:
                                                                case 183375:
                                                                case 183305:
                                                                    {
                                                                        obtined_points += 300;
                                                                        break;
                                                                    }
                                                                default:
                                                                    obtined_points += 50;
                                                                    break;
                                                            }
                                                        }
                                                    }
                                                    if (iteminfo.BaseInformation.ConquerPointsWorth > obtined_points)
                                                    {
                                                        uint add_cps = 0;
                                                        add_cps = (uint)(iteminfo.BaseInformation.ConquerPointsWorth - obtined_points);
                                                        if (add_cps < client.Entity.ConquerPoints)
                                                        {
                                                            client.Entity.ConquerPoints -= (uint)add_cps;
                                                            foreach (uint key in amount.Keys)
                                                            {
                                                                if (client.Inventory.ContainsUID(key))
                                                                    client.Inventory.Remove(key, PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                            }
                                                            client.Inventory.Add(ItemAdd, 0, 1);

                                                        }
                                                    }
                                                    else
                                                    {
                                                        foreach (uint key in amount.Keys)
                                                        {
                                                            if (client.Inventory.ContainsUID(key))
                                                                client.Inventory.Remove(key, PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                        }
                                                        client.Inventory.Add(ItemAdd, 0, 1);

                                                    }
                                                }
                                                break;
                                            }
                                        case 52:
                                            {
                                                var item = Database.ConquerItemTable.LoadItem(usage.UID);
                                                item.Mode = PhoenixProject.Game.Enums.ItemMode.ChatItem;
                                                item.Send(client);
                                                break;
                                            }
                                        case 41:
                                            {
                                                // var item = Database.ConquerItemTable.LoadItem(usage.UID);
                                                usage.dwParam = 1;
                                                client.Send(usage);
                                                break;
                                            }
                                        case ItemUsage.SwitchEquipsBack:
                                        case ItemUsage.SwitchEquips:
                                            {
                                                client.AlternateEquipment = usage.ID == ItemUsage.SwitchEquips;
                                                if (usage.ID == 45)
                                                {
                                                    ClientEquip equips = new ClientEquip(client);
                                                    client.Send(equips);
                                                    client.Equipment.UpdateEntityPacket2();

                                                    client.LoadItemStats2(client.Entity);
                                                    client.CalculateStatBonus();
                                                    client.CalculateHPBonus();
                                                    client.Send(WindowStats(client));
                                                }
                                                else
                                                {
                                                    ClientEquip equips = new ClientEquip();
                                                    equips.DoEquips(client);
                                                    client.Send(equips);
                                                    client.Equipment.UpdateEntityPacket();

                                                    client.LoadItemStats(client.Entity);
                                                    client.CalculateStatBonus();
                                                    client.CalculateHPBonus();
                                                    client.Send(WindowStats(client));
                                                }
                                                usage.dwParam = 1;
                                                client.Send(usage);
                                                break;
                                            }
                                        case ItemUsage.ArrowReload:
                                            {
                                                ReloadArrows(client.Equipment.TryGetItem(ConquerItem.LeftWeapon), client);
                                                break;
                                            }
                                        case ItemUsage.ShowBoothItems:
                                            {
                                                ShowBoothItems(usage, client);
                                                break;
                                            }
                                        case ItemUsage.AddItemOnBoothForSilvers:
                                        case ItemUsage.AddItemOnBoothForConquerPoints:
                                            {
                                                AddItemOnBooth(usage, client);
                                                break;
                                            }
                                        case ItemUsage.BuyFromBooth:
                                            {
                                                BuyFromBooth(usage, client);
                                                break;
                                            }
                                        case ItemUsage.RemoveItemFromBooth:
                                            {
                                                RemoveItemFromBooth(usage, client);
                                                break;
                                            }
                                        case ItemUsage.EquipItem:
                                            {

                                                EquipItem(usage, client);

                                                break;
                                            }
                                        case ItemUsage.UnequipItem:
                                            {

                                                UnequipItem(usage, client);

                                                break;
                                            }
                                        case ItemUsage.BuyFromNPC:
                                            {
                                                HandleBuyFromNPC(usage, client);
                                                break;
                                            }
                                        case ItemUsage.SellToNPC:
                                            {
                                                HandleSellToNPC(usage, client);
                                                break;
                                            }
                                        case ItemUsage.Repair:
                                            {
                                                HandleRepair(usage, client);
                                                break;
                                            }
                                        case ItemUsage.MeteorUpgrade:
                                        case ItemUsage.DragonBallUpgrade:
                                            {
                                                UpgradeItem(usage, client);
                                                break;
                                            }
                                        case ItemUsage.Ping:
                                            {
                                                if (Time32.Now < client.LastPing.AddSeconds(2))
                                                {
                                                    client.PingCount++;
                                                    if (client.PingCount == 40)
                                                    {
                                                        client.Send(new Message("Speed hack detected!", System.Drawing.Color.BlanchedAlmond, Message.TopLeft));
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                }

                                                client.LastPingT = client.LastPing;
                                                client.LastPing = Time32.Now;

                                                if (client.LastPing > client.LastPingT.AddSeconds(2))
                                                    client.PingCount = 0;
                                                usage.TimeStamp += 200;
                                                client.Send(ReturnFinal(packet));
                                                client.Send(usage);

                                                break;
                                            }
                                        case ItemUsage.ViewWarehouse:
                                            {
                                                usage.dwParam = client.MoneySave;
                                                client.Send(usage);
                                                break;
                                            }
                                        case ItemUsage.WarehouseDeposit:
                                            {
                                                if (client.Entity.Money >= usage.dwParam)
                                                {
                                                    client.Entity.Money -= usage.dwParam;
                                                    client.MoneySave += usage.dwParam;
                                                }
                                                break;
                                            }
                                        case ItemUsage.WarehouseWithdraw:
                                            {
                                                if (client.MoneySave >= usage.dwParam)
                                                {
                                                    client.Entity.Money += usage.dwParam;
                                                    client.MoneySave -= usage.dwParam;
                                                }
                                                break;
                                            }
                                        case ItemUsage.DropItem:
                                            {
                                                DropItem(usage, client);
                                                break;
                                            }
                                        case ItemUsage.DropMoney:
                                            {
                                                DropMoney(usage, client);
                                                break;
                                            }
                                        case ItemUsage.Enchant:
                                            {
                                                EnchantItem(usage, client);
                                                break;
                                            }
                                        case ItemUsage.SocketTalismanWithItem:
                                            {
                                                SocketTalismanWithItem(usage, client);
                                                break;
                                            }
                                        case ItemUsage.SocketTalismanWithCPs:
                                            {
                                                SocketTalismanWithCPs(usage, client);
                                                break;
                                            }
                                        case ItemUsage.RedeemGear:
                                            {
                                                var item = client.DeatinedItem[usage.UID];
                                                if (item != null)
                                                {
                                                    if (DateTime.Now > item.Date.AddDays(7))
                                                    {
                                                        client.Send(new Message("This item is expired!", System.Drawing.Color.Red, Message.TopLeft));

                                                        return;
                                                    }
                                                    if (client.Entity.ConquerPoints >= item.ConquerPointsCost)
                                                    {
                                                        client.Entity.ConquerPoints -= item.ConquerPointsCost;
                                                        Database.EntityTable.UpdateCps(client);

                                                        usage.dwParam = client.Entity.UID;
                                                        usage.dwExtraInfo3 = item.ConquerPointsCost;
                                                        client.Send(usage);

                                                        client.Inventory.Add(item.Item, PhoenixProject.Game.Enums.ItemUse.Add);

                                                        Database.ClaimItemTable.Redeem(usage.UID, client);
                                                        Database.DetainedItemTable.Claim(usage.UID, client);
                                                        client.DeatinedItem.Remove(item.UID);

                                                        if (ServerBase.Kernel.GamePool.ContainsKey(item.GainerUID))
                                                        {
                                                            GameState pClient;
                                                            if (ServerBase.Kernel.GamePool.TryGetValue(item.GainerUID, out pClient))
                                                            {
                                                                if (pClient.Entity != null)
                                                                {
                                                                    pClient.ClaimableItem[item.UID].OwnerUID = 500;
                                                                    pClient.ClaimableItem[item.UID].MakeItReadyToClaim();
                                                                    usage.dwParam = pClient.Entity.UID;
                                                                    usage.ID = ItemUsage.ClaimGear;
                                                                    pClient.Send(usage);
                                                                    pClient.ClaimableItem[item.UID].Send(pClient);
                                                                }
                                                            }
                                                        }

                                                        Message message = new Message(" " + client.Entity.Name + " has redeemed his Gear and Pay " + item.ConquerPointsCost + " CPS . Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
                                                        ServerBase.Kernel.SendWorldMessage(message, ServerBase.Kernel.GamePool.Values);
                                                    }
                                                }
                                                else
                                                {
                                                    client.Send(new Message("The item you want to redeem has already been redeemed.", System.Drawing.Color.Red, Message.TopLeft));
                                                }
                                                break;
                                            }
                                        case ItemUsage.ClaimGear:
                                            {
                                                // Console.WriteLine(" usage " + usage.UID + "");
                                                var item = client.ClaimableItem[usage.UID];
                                                // Console.WriteLine(" usage i  " + item.UID + "");
                                                if (item != null)
                                                {
                                                    if (item.Bound)
                                                    {
                                                        client.Send(new Message("Unnclaimable item!", System.Drawing.Color.Red, Message.TopLeft));
                                                        return;
                                                    }
                                                    if (DateTime.Now < item.Date.AddDays(7) && item.OwnerUID != 500)
                                                    {
                                                        client.Send(new Message("This item is not expired. You cannot claim it yet!", System.Drawing.Color.Red, Message.TopLeft));
                                                        return;
                                                    }
                                                    if (item.OwnerUID == 500)
                                                        client.Entity.ConquerPoints += item.ConquerPointsCost;
                                                    else
                                                    {
                                                        client.Inventory.Add(item.Item, PhoenixProject.Game.Enums.ItemUse.Move);
                                                        Message message = new Message("Thank you for arresting " + item.OwnerName + " , " + item.GainerName + ". The arrested one has redeemed his items and you have received a great deal of ConquerPoints as reward. Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
                                                        ServerBase.Kernel.SendWorldMessage(message, ServerBase.Kernel.GamePool.Values);
                                                    }
                                                    Database.ClaimItemTable.Claim(usage.UID, client);
                                                    client.ClaimableItem.Remove(item.UID);

                                                    usage.dwParam = client.Entity.UID;
                                                    usage.dwExtraInfo3 = item.ConquerPointsCost;
                                                    //Database.EntityTable.UpdateCps(client);
                                                    client.Send(usage);
                                                    Message message2 = new Message("Thank you for arresting red/black name players " + client.Entity.Name + " has recived " + item.ConquerPointsCost + " CPS . Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
                                                    ServerBase.Kernel.SendWorldMessage(message2, ServerBase.Kernel.GamePool.Values);
                                                }
                                                else
                                                {
                                                    client.Send(new Message("The item you want to claim has already been claimed.", System.Drawing.Color.Red, Message.TopLeft));
                                                }
                                                break;
                                            }
                                        case 43:
                                            {
                                                uint UID = BitConverter.ToUInt32(packet, 4);
                                                if (packet[20] == 1)
                                                {
                                                    if (client.Inventory.ContainsUID(BitConverter.ToUInt32(packet, 84)))//76
                                                    {
                                                        Interfaces.IConquerItem item = null;
                                                        if (client.Inventory.TryGetItem(UID, out item))
                                                        {
                                                            UInt32 iType = item.ID / 1000;
                                                            Positions pos = GetPositionFromID(item.ID);
                                                            if (pos == Positions.Garment)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.RightAccessory)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.LeftAccessory)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.Bottle)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.Steed)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.SteedArmor)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.SteedTalisman)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.AttackTalisman)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.DefenceTalisman)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                            {
                                                                if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                {
                                                                    if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                        item.SocketOne = PhoenixProject.Game.Enums.Gem.EmptySocket;
                                                                    client.Inventory.Remove(BitConverter.ToUInt32(packet, 84), PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                                    item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                                    item.Send(client);
                                                                    usage.dwParam = 1;
                                                                    client.LoadItemStats(client.Entity);
                                                                    client.CalculateStatBonus();
                                                                    client.CalculateHPBonus();
                                                                    Database.ConquerItemTable.UpdateSockets(item);
                                                                }
                                                            }
                                                            else if (item.SocketTwo == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                            {
                                                                uint rand = (uint)PhoenixProject.ServerBase.Kernel.Random.Next(1, 700);
                                                                if (rand > 320)
                                                                // if (PhoenixProject.ServerBase.Kernel.PercentSuccess(30))
                                                                {
                                                                    if (item.SocketTwo == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                        item.SocketTwo = PhoenixProject.Game.Enums.Gem.EmptySocket;
                                                                    client.Inventory.Remove(BitConverter.ToUInt32(packet, 84), PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                                    item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                                    item.Send(client);
                                                                    usage.dwParam = 1;
                                                                    client.LoadItemStats(client.Entity);
                                                                    client.CalculateStatBonus();
                                                                    client.CalculateHPBonus();
                                                                    Database.ConquerItemTable.UpdateSockets(item);
                                                                }
                                                                else
                                                                {
                                                                    usage.dwParam = 0;
                                                                    client.Inventory.Add(1200006, 0, 1);
                                                                    client.Inventory.Remove(BitConverter.ToUInt32(packet, 84), PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                                }
                                                            }
                                                            /*&  }
                                                              else
                                                              {
                                                                  if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                      item.SocketOne = PhoenixProject.Game.Enums.Gem.EmptySocket;
                                                                  client.Inventory.Remove(BitConverter.ToUInt32(packet, 80), PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                                  item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                                  item.Send(client);
                                                                  client.LoadItemStats(item);
                                                                  Database.ConquerItemTable.UpdateItem(item, client);
                                                              }*/
                                                        }
                                                    }
                                                }
                                                if (packet[20] == 5)
                                                {
                                                    Interfaces.IConquerItem item = null;
                                                    if (client.Inventory.TryGetItem(UID, out item))
                                                    {
                                                        Dictionary<uint, uint> dbs = new Dictionary<uint, uint>();//packet[20]);
                                                        for (ushort i = 84; i < 84 + 4 * packet[20]; i += 4)
                                                        {
                                                            if (client.Inventory.ContainsUID(BitConverter.ToUInt32(packet, i)))
                                                            {
                                                                dbs.Add(BitConverter.ToUInt32(packet, i), i);
                                                            }
                                                        }

                                                        if (client.Inventory.Contains(1088000, 5))
                                                        {
                                                            if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                return;
                                                            if (item.SocketTwo == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                item.SocketTwo = PhoenixProject.Game.Enums.Gem.EmptySocket;
                                                            foreach (uint key in dbs.Keys)
                                                            {
                                                                if (client.Inventory.ContainsUID(key))
                                                                    client.Inventory.Remove(key, PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                            }
                                                            usage.dwParam = 1;
                                                            item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                            item.Send(client);
                                                            client.LoadItemStats(client.Entity);
                                                            client.CalculateStatBonus();
                                                            client.CalculateHPBonus();
                                                            Database.ConquerItemTable.UpdateSockets(item);
                                                        }
                                                    }
                                                }
                                                if (packet[20] == 7)
                                                {
                                                    Interfaces.IConquerItem item = null;
                                                    if (client.Inventory.TryGetItem(UID, out item))
                                                    {
                                                        if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                            return;

                                                        Dictionary<uint, uint> drill = new Dictionary<uint, uint>();//packet[20]);
                                                        for (ushort i = 84; i < 84 + 4 * packet[20]; i += 4)
                                                        {
                                                            if (client.Inventory.ContainsUID(BitConverter.ToUInt32(packet, i)))
                                                            {
                                                                drill.Add(BitConverter.ToUInt32(packet, i), i);
                                                            }
                                                        }

                                                        if (client.Inventory.Contains(1200006, 7))
                                                        {

                                                            if (item.SocketTwo == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                item.SocketTwo = PhoenixProject.Game.Enums.Gem.EmptySocket;
                                                            foreach (uint key in drill.Keys)
                                                            {
                                                                if (client.Inventory.ContainsUID(key))
                                                                    client.Inventory.Remove(key, PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                            }
                                                            usage.dwParam = 1;
                                                            item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                            item.Send(client);
                                                            client.LoadItemStats(client.Entity);
                                                            client.CalculateStatBonus();
                                                            client.CalculateHPBonus();
                                                            Database.ConquerItemTable.UpdateSockets(item);
                                                        }
                                                    }
                                                }
                                                if (packet[20] == 12)
                                                {
                                                    Interfaces.IConquerItem item = null;
                                                    if (client.Inventory.TryGetItem(UID, out item))
                                                    {
                                                        Dictionary<uint, uint> dbs = new Dictionary<uint, uint>();//packet[20]);
                                                        for (ushort i = 84; i < 84 + 4 * packet[20]; i += 4)
                                                        {
                                                            if (client.Inventory.ContainsUID(BitConverter.ToUInt32(packet, i)))
                                                            {
                                                                dbs.Add(BitConverter.ToUInt32(packet, i), i);
                                                            }
                                                        }

                                                        if (client.Inventory.Contains(1088000, 12))
                                                        {
                                                            if (item.SocketOne != PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                return;
                                                            if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                item.SocketOne = PhoenixProject.Game.Enums.Gem.EmptySocket;
                                                            foreach (uint key in dbs.Keys)
                                                            {
                                                                if (client.Inventory.ContainsUID(key))
                                                                    client.Inventory.Remove(key, PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                            }
                                                            usage.dwParam = 1;
                                                            //client.Inventory.Remove(DragonBall, 12);
                                                            item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                            item.Send(client);
                                                            client.LoadItemStats(client.Entity);
                                                            client.CalculateStatBonus();
                                                            client.CalculateHPBonus();
                                                            Database.ConquerItemTable.UpdateSockets(item);
                                                        }
                                                    }

                                                }
                                                client.Send(packet);
                                                break;
                                            }
                                        case 40:
                                            {
                                                uint ItemAdd = (uint)((packet[4] & 0xFF) | ((packet[5] & 0xFF) << 8) | ((packet[6] & 0xFF) << 16) | ((packet[7] & 0xFF) << 24));

                                                Interfaces.IConquerItem item_new = null;
                                                if (client.Inventory.TryGetItem(ItemAdd, out item_new))
                                                {
                                                    UInt32 iType = item_new.ID / 1000;
                                                    Positions pos = GetPositionFromID(item_new.ID);
                                                    if (pos == Positions.Garment)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.RightAccessory)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.LeftAccessory)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.Bottle)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.Steed)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.SteedArmor)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.SteedTalisman)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.AttackTalisman)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.DefenceTalisman)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (item_new.Bless == 7)
                                                        return;

                                                    Queue<uint> amount = new Queue<uint>(packet[20]);

                                                    for (ushort i = 84; i < 84 + 4 * packet[20]; i += 4)
                                                    {
                                                        if (client.Inventory.ContainsUID((uint)((packet[i] & 0xFF) | ((packet[(byte)(i + 1)] & 0xFF) << 8) | ((packet[(byte)(i + 2)] & 0xFF) << 16) | ((packet[(byte)(i + 3)] & 0xFF) << 24))))
                                                            amount.Enqueue((uint)((packet[i] & 0xFF) | ((packet[(byte)(i + 1)] & 0xFF) << 8) | ((packet[(byte)(i + 2)] & 0xFF) << 16) | ((packet[(byte)(i + 3)] & 0xFF) << 24)));
                                                        else
                                                            return;
                                                    }

                                                    byte oldbless = item_new.Bless;
                                                    if (item_new.Bless == 0 && amount.Count == 5)
                                                        item_new.Bless = 1;
                                                    else if (item_new.Bless == 1 && amount.Count == 1)
                                                        item_new.Bless = 3;
                                                    else if (item_new.Bless == 3 && amount.Count == 3)
                                                        item_new.Bless = 5;
                                                    else if (item_new.Bless == 5 && amount.Count == 5)
                                                        item_new.Bless = 7;
                                                    if (oldbless == item_new.Bless)
                                                        return;

                                                    while (amount.Count != 0)
                                                        client.Inventory.Remove(amount.Dequeue(), PhoenixProject.Game.Enums.ItemUse.Remove, true);

                                                    item_new.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                    item_new.Send(client);
                                                    usage.dwParam = 1;
                                                    Database.ConquerItemTable.UpdateBless(item_new);
                                                }
                                                client.Send(packet);
                                                break;
                                            }
                                        case ItemUsage.GemCompose:
                                            {
                                                #region GemCompose
                                                UInt32 Ident = usage.UID;
                                                client.Inventory.Remove(Ident, 15);
                                                client.Inventory.Add(Ident + 1, 0, 1);
                                                usage.dwParam = 1;
                                                client.Send(usage);
                                                #endregion
                                                break;
                                            }
                                        case ItemUsage.ToristSuper:
                                            {
                                                #region GemCompose
                                                if (client.Entity.Money >= 100000)
                                                {
                                                    client.Inventory.Remove(700002, 1);
                                                    client.Inventory.Remove(700012, 1);
                                                    client.Inventory.Remove(700022, 1);
                                                    client.Inventory.Remove(700032, 1);
                                                    client.Inventory.Remove(700042, 1);
                                                    client.Inventory.Remove(700052, 1);
                                                    client.Inventory.Remove(700062, 1);
                                                    client.Entity.Money -= 100000;
                                                    client.Inventory.Add(700072, 0, 1);

                                                    usage.dwParam = 1;
                                                    client.Send(usage);
                                                }
                                                usage.dwParam = 0;
                                                client.Send(usage);
                                                #endregion
                                                break;
                                            }
                                        case ItemUsage.SplitStack:
                                            {
                                                Interfaces.IConquerItem mainItem = null;
                                                Interfaces.IConquerItem minorItem = new ConquerItem(true);
                                                Database.ConquerItemInformation infos = null;
                                                minorItem.Color = (PhoenixProject.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                                if (client.Inventory.TryGetItem(usage.UID, out mainItem))
                                                {
                                                    infos = new PhoenixProject.Database.ConquerItemInformation(mainItem.ID, 0);
                                                    if (mainItem.StackSize > 1 && mainItem.StackSize <= infos.BaseInformation.StackSize)
                                                    {
                                                        if (client.Inventory.Count < 40)
                                                        {
                                                            client.SpiltStack = false;
                                                            ushort Amount = (ushort)usage.dwParam;

                                                            mainItem.StackSize -= Amount;
                                                            mainItem.Mode = Game.Enums.ItemMode.Update;
                                                            mainItem.Send(client);
                                                            mainItem.Mode = Game.Enums.ItemMode.Default;
                                                            Database.ConquerItemTable.UpdateStack(mainItem);
                                                            minorItem.ID = mainItem.ID;
                                                            minorItem.StackSize += Amount;
                                                            minorItem.Durability = mainItem.Durability;
                                                            client.Inventory.Add(minorItem, Game.Enums.ItemUse.CreateAndAdd);

                                                        }
                                                    }
                                                }
                                                break;
                                            }
                                        case ItemUsage.MergeStackableItems:
                                            {
                                                Interfaces.IConquerItem mainItem = null;
                                                Interfaces.IConquerItem minorItem = new ConquerItem(true);
                                                Database.ConquerItemInformation infos = null;
                                                minorItem.Color = (PhoenixProject.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                                if (client.Inventory.TryGetItem(usage.UID, out mainItem) && client.Inventory.TryGetItem(usage.dwParam, out minorItem))
                                                {
                                                    if (mainItem.ID == minorItem.ID)
                                                    {
                                                        infos = new PhoenixProject.Database.ConquerItemInformation(mainItem.ID, 0);
                                                        if (mainItem.StackSize < 1)
                                                            mainItem.StackSize = 1;
                                                        if (minorItem.StackSize < 1)
                                                            minorItem.StackSize = 1;

                                                        if ((mainItem.StackSize + minorItem.StackSize) <= infos.BaseInformation.StackSize)
                                                        {
                                                            mainItem.StackSize += minorItem.StackSize;
                                                            mainItem.Mode = Game.Enums.ItemMode.Update;
                                                            mainItem.Send(client);
                                                            mainItem.Mode = Game.Enums.ItemMode.Default;
                                                            Database.ConquerItemTable.UpdateStack(mainItem);

                                                            client.Inventory.Remove(minorItem, Game.Enums.ItemUse.Remove);
                                                        }
                                                    }
                                                }
                                                break;
                                            }
                                        case 34:
                                            {
                                                break;
                                            }
                                        case 54://downgrade
                                            {
                                                Interfaces.IConquerItem item = null;
                                                Interfaces.IConquerItem minorItem = new ConquerItem(true);
                                                //Database.ConquerItemInformation infos = null;
                                                // uint newid = infos.LowestID(infos.BaseInformation.Level);

                                                //minorItem.Color = (PhoenixProject.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                                if (client.Inventory.TryGetItem(usage.UID, out item) && client.Entity.ConquerPoints >= 54)
                                                {
                                                    Database.ConquerItemInformation cii = new PhoenixProject.Database.ConquerItemInformation(item.ID, item.Plus);

                                                    uint kimzz = 0;
                                                    kimzz = item.ID;

                                                Kimozzz:
                                                    uint kimo = kimzz - 10;
                                                    uint kimo2 = kimzz - 20;
                                                    uint kimo3 = kimzz - 30;
                                                    ushort postion = ItemPosition(kimo);
                                                    ushort postion2 = ItemPosition(kimo2);
                                                    ushort postion3 = ItemPosition(kimo3);
                                                    Database.ConquerItemInformation cii1 = new PhoenixProject.Database.ConquerItemInformation(kimo, 0);
                                                    Database.ConquerItemInformation cii2 = new PhoenixProject.Database.ConquerItemInformation(kimo2, 0);
                                                    Database.ConquerItemInformation cii3 = new PhoenixProject.Database.ConquerItemInformation(kimo3, 0);

                                                    if (Database.ConquerItemInformation.BaseInformations.ContainsKey(kimo))
                                                    {
                                                        if (cii1.BaseInformation.Level >= 10 && postion != 4 && postion != 5)
                                                        {
                                                            kimzz = kimo;
                                                            goto Kimozzz;
                                                        }
                                                        else
                                                        {
                                                            if (cii1.BaseInformation.Level > 10)
                                                            {
                                                                kimzz = kimo;
                                                                goto Kimozzz;
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (Database.ConquerItemInformation.BaseInformations.ContainsKey(kimo2))
                                                        {
                                                            if (cii2.BaseInformation.Level >= 10 && postion2 != 4 && postion2 != 5)
                                                            {
                                                                kimzz = kimo2;
                                                                goto Kimozzz;
                                                            }
                                                            else
                                                            {
                                                                if (cii2.BaseInformation.Level > 10)
                                                                {
                                                                    kimzz = kimo2;
                                                                    goto Kimozzz;
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (Database.ConquerItemInformation.BaseInformations.ContainsKey(kimo3))
                                                            {
                                                                if (cii3.BaseInformation.Level >= 10 && postion3 != 4 && postion3 != 5)
                                                                {
                                                                    kimzz = kimo3;
                                                                    goto Kimozzz;
                                                                }
                                                                else
                                                                {
                                                                    if (cii3.BaseInformation.Level > 10)
                                                                    {
                                                                        kimzz = kimo3;
                                                                        goto Kimozzz;
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {

                                                                // return;
                                                            }
                                                        }
                                                    }

                                                    item.ID = kimzz;

                                                    PhoenixProject.Database.ConquerItemTable.UpdateItemID(item, client);
                                                    item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                    item.Send(client);
                                                    client.Entity.ConquerPoints -= 54;
                                                }
                                                else
                                                {
                                                    usage.dwParam = 2;
                                                }
                                                break;
                                            }
                                        default:
                                            {
                                                Console.WriteLine("Unhandled item usage type : " + usage.ID);
                                                break;
                                            }
                                    }
                                }
                                break;
                            }
                        #endregion
                        #region String (1015)
                        case 1015:
                            {
                                if (client.Action == 2)
                                {
                                    _String str2 = new _String(false);
                                    str2.Deserialize(packet);
                                    if ((str2.Type == 0x1a) && (str2.Texts.Count > 0))
                                    {
                                        IEnumerator enumerator = Kernel.GamePool.Values.GetEnumerator();
                                        enumerator.MoveNext();
                                        int count = Kernel.GamePool.Count;
                                        for (uint i = 0; i < count; i++)
                                        {
                                            if (i >= count)
                                            {
                                                break;
                                            }
                                            current = enumerator.Current as GameState;
                                            if (current.Entity.Name == str2.Texts[0])
                                            {
                                                string str3 = "";
                                                str3 = ((str3 + current.Entity.UID + " ") + current.Entity.Level + " ") + current.Entity.BattlePower + " #";
                                                if (current.Entity.GuildID != 0)
                                                {
                                                    str3 = str3 + current.Guild.Name + " fNone# ";
                                                }
                                                else
                                                {
                                                    str3 = str3 + "None fNone# ";
                                                }
                                                str3 = (str3 + current.Entity.Spouse + " ") + ((byte)current.Entity.NobilityRank) + " ";
                                                if ((current.Entity.Body % 10) < 3)
                                                {
                                                    str3 = str3 + "1";
                                                }
                                                else
                                                {
                                                    str3 = str3 + "0";
                                                }
                                                str2.Texts.Add(str3);
                                                client.Send(str2);
                                            }
                                            enumerator.MoveNext();
                                        }
                                    }
                                    break;
                                }
                            }
                            break;
                        #endregion
                        #region KnownPersons (1019)
                        case 1019:
                            {
                                KnownPersons knownP = new KnownPersons(false);
                                knownP.Deserialize(packet);
                                switch (knownP.Type)
                                {
                                    case KnownPersons.RequestFriendship:
                                        {
                                            AddFriend(knownP, client);
                                            break;
                                        }
                                    case KnownPersons.RemovePerson:
                                        {
                                            RemoveFriend(knownP, client);
                                            break;
                                        }
                                    case KnownPersons.RemoveEnemy:
                                        {
                                            RemoveEnemy(knownP, client);
                                            break;
                                        }
                                }
                                break;
                            }
                        #endregion
                        #region Vote /Attack
                        case 1022:
                            {

                                if (client.Action != 2)
                                    return;
                                uint dmg = BitConverter.ToUInt32(packet, 24);
                                uint AttackType = BitConverter.ToUInt32(packet, 20);
                                uint AttackType2 = BitConverter.ToUInt32(packet, 26);

                                switch (AttackType)
                                {
                                    case 36:
                                        {
                                            GamePackets.Attack attack2 = new Attack(false);
                                            attack2.Deserialize(packet);
                                            CloudSaintsJar.Execute(client, attack2);
                                            break;
                                        }
                                    case 39:
                                        {
                                            if (!Kernel.VotePool.ContainsKey(client.Account.IP))
                                            {
                                                if (!Kernel.VotePoolUid.ContainsKey(client.Entity.UID))
                                                {
                                                    client.Entity.ConquerPoints += Database.rates.VotePrize;
                                                    PhoenixProject.Game.ConquerStructures.PlayersVot Vot = new PhoenixProject.Game.ConquerStructures.PlayersVot();
                                                    Vot.AdressIp = client.Account.IP;
                                                    Vot.Uid = client.Entity.UID;
                                                    Kernel.VotePool.Add(Vot.AdressIp, Vot);
                                                    Kernel.VotePoolUid.Add(Vot.Uid, Vot);
                                                    Database.EntityTable.SavePlayersVot(Vot);
                                                    client.Send(new Message("" + PhoenixProject.Database.rates.VoteUrl + "", System.Drawing.Color.Red, Network.GamePackets.Message.Website));
                                                }
                                                else
                                                {
                                                    client.Send(new Message("" + PhoenixProject.Database.rates.VoteUrl + "", System.Drawing.Color.Red, Network.GamePackets.Message.Website));
                                                }
                                            }
                                            else
                                            {
                                                client.Send(new Message("" + PhoenixProject.Database.rates.VoteUrl + "", System.Drawing.Color.Red, Network.GamePackets.Message.Website));

                                            }
                                            break;
                                        }
                                    default:
                                        {
                                            if (client.Entity.MapID == 8880 || client.Entity.MapID == 8881) return;
                                            GamePackets.Attack attack = new Attack(false);
                                            attack.Deserialize(packet);
                                            Attack(attack, client);
                                            break;
                                        }
                                }
                                break;
                            }
                        #endregion
                        #region ChiSystem
                        case 2533:
                            {

                                ChiSystem2.Handle(packet, client);
                                break;
                            }
                        #endregion
                        #region CountryFlag
                        case 2430:
                            {
                                KimoCountryFlag kimo = new KimoCountryFlag(false);
                                kimo.Deserialize(packet);
                                client.Entity.CountryFlag = kimo.FlagID;
                                kimo.UID = client.Entity.UID;
                                client.SendScreen(kimo, true);
                                break;
                            }
                        #endregion
                        #region Teams (1023)
                        case 1023:
                            {
                                if (client.Action != 2)
                                    return;
                                Team teamPacket = new Team();
                                teamPacket.Deserialize(packet);
                                switch (teamPacket.Type)
                                {
                                    case Team.Create: CreateTeam(teamPacket, client); break;
                                    case Team.AcceptJoinRequest: AcceptRequestToJoinTeam(teamPacket, client); break;
                                    case Team.AcceptInvitation: AcceptInviteToJoinTeam(teamPacket, client); break;
                                    case Team.InviteRequest: SendInviteToJoinTeam(teamPacket, client); break;
                                    case Team.JoinRequest: SendRequestJoinToTeam(teamPacket, client); break;
                                    case Team.ExitTeam: LeaveTeam(teamPacket, client); break;
                                    case Team.Dismiss: DismissTeam(teamPacket, client); break;
                                    case Team.Kick: KickFromTeam(teamPacket, client); break;
                                    case Team.ForbidJoining:
                                        {
                                            foreach (Client.GameState Teammate in client.Team.Teammates)
                                                if (Teammate != null)
                                                {
                                                    Teammate.Team.ForbidJoin = true;
                                                    Teammate.Send(teamPacket);
                                                }

                                            break;
                                        }
                                    case Team.UnforbidJoining:
                                        {
                                            foreach (Client.GameState Teammate in client.Team.Teammates)
                                                if (Teammate != null)
                                                {
                                                    Teammate.Team.ForbidJoin = false;
                                                    Teammate.Send(teamPacket);
                                                }

                                            break;
                                        }
                                    case Team.LootMoneyOff:
                                        {
                                            foreach (Client.GameState Teammate in client.Team.Teammates)
                                                if (Teammate != null)
                                                {
                                                    Teammate.Team.PickupMoney = false;
                                                    Teammate.Send(teamPacket);
                                                }
                                            break;
                                        }
                                    case Team.LootMoneyOn:
                                        {
                                            foreach (Client.GameState Teammate in client.Team.Teammates)
                                                if (Teammate != null)
                                                {
                                                    Teammate.Team.PickupMoney = true;
                                                    Teammate.Send(teamPacket);
                                                }
                                            break;
                                        }
                                    case Team.LootItemsOn:
                                        {
                                            foreach (Client.GameState Teammate in client.Team.Teammates)
                                                if (Teammate != null)
                                                {
                                                    Teammate.Team.PickupItems = true;
                                                    Teammate.Send(teamPacket);
                                                }
                                            break;
                                        }
                                    case Team.LootItemsOff:
                                        {
                                            foreach (Client.GameState Teammate in client.Team.Teammates)
                                                if (Teammate != null)
                                                {
                                                    Teammate.Team.PickupItems = false;
                                                    Teammate.Send(teamPacket);
                                                }
                                            break;
                                        }
                                }
                                break;
                            }
                        #endregion
                        #region Atributes Set (1024)
                        case 1024:
                            {
                                if (client.Action != 2)
                                    return;
                                uint AddStr = BitConverter.ToUInt32(packet, 8);
                                uint AddAgi = BitConverter.ToUInt32(packet, 12);
                                uint AddVit = BitConverter.ToUInt32(packet, 16);
                                uint AddSpi = BitConverter.ToUInt32(packet, 20);
                                if (client.Entity.Atributes == 0)
                                    return;

                                uint TotalStatPoints = AddStr + AddAgi + AddVit + AddSpi;

                                if (client.Entity.Atributes >= TotalStatPoints)
                                {
                                    client.Entity.Strength += (ushort)AddStr;
                                    client.Entity.Agility += (ushort)AddAgi;
                                    client.Entity.Vitality += (ushort)AddVit;
                                    client.Entity.Spirit += (ushort)AddSpi;
                                    client.Entity.Atributes -= (ushort)TotalStatPoints;
                                    client.Send(packet);
                                }
                                client.CalculateStatBonus();
                                client.CalculateHPBonus();
                                client.GemAlgorithm();
                                break;
                            }
                        #endregion
                        #region Socketing (1027)
                        case 1027:
                            {
                                EmbedSocket socket = new EmbedSocket(false);
                                socket.Deserialize(packet);
                                SocketItem(socket, client);
                                break;
                            }
                        #endregion
                        #region Character Statistics (1040)
                        case 1040:
                            {
                                uint UID = BitConverter.ToUInt32(packet, 4);
                                Client.GameState Client;
                                if (ServerBase.Kernel.GamePool.TryGetValue(UID, out Client))
                                {
                                    client.Send(WindowStats(Client));
                                }
                                break;
                            }
                        #endregion
                        #region LoginPacket (1052)
                        case 1052:
                            {
                                if (client.Action == 1)
                                {
                                    Connect connect = new Connect();
                                    connect.Deserialize(packet);
                                    AppendConnect(connect, client);
                                }
                                else
                                {
                                    //Console.WriteLine(" yes");
                                    client.Disconnect();
                                    //DoLogin(client);
                                }
                                break;
                            }
                        #endregion
                        #region Trade (1056)

                        case 1056:
                            {
                                if (client.Action != 2)
                                    return;
                                Trade trade = new Trade(false);
                                trade.Deserialize(packet);
                                switch (trade.Type)
                                {
                                    case Trade.Request:
                                        RequestTrade(trade, client);
                                        break;
                                    case Trade.Close:
                                        CloseTrade(trade, client);
                                        break;
                                    case Trade.AddItem:
                                        AddTradeItem(trade, client);
                                        break;
                                    case Trade.SetMoney:
                                        SetTradeMoney(trade, client);
                                        break;
                                    case Trade.SetConquerPoints:
                                        SetTradeConquerPoints(trade, client);
                                        break;
                                    case Trade.Accept:
                                        AcceptTrade(trade, client);
                                        break;
                                }
                                break;
                            }

                        #endregion Trade (1056)
                        #region Floor items (1101)
                        case 1101:
                            {
                                if (client.Action != 2)
                                    return;
                                FloorItem floorItem = new FloorItem(false);
                                floorItem.Deserialize(packet);
                                client.SpiltStack = true;
                                PickupItem(floorItem, client);
                                client.SpiltStack = false;
                                break;
                            }
                        #endregion
                        #region Warehouses (1102)
                        case 1102:
                            {
                                if (client.Action != 2)
                                    return;

                                Warehouse warehousepacket = new Warehouse(false);
                                warehousepacket.Deserialize(packet);
                                switch (warehousepacket.Type)
                                {
                                    case Warehouse.Entire:
                                        {
                                            Game.ConquerStructures.Warehouse wh = client.Warehouses[(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID)warehousepacket.NpcID];
                                            if (wh == null) return;
                                            byte count = 0;
                                            warehousepacket.Count = 1;
                                            warehousepacket.Type = Warehouse.AddItem;
                                            for (; count < wh.Count; count++)
                                            {
                                                warehousepacket.Append(wh.Objects[count]);
                                                client.Send(warehousepacket);
                                            }
                                            break;
                                        }
                                    case Warehouse.AddItem:
                                        {
                                            if (client.Booth != null)
                                            {
                                                Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Sorry you cant add items into your warehouse while you in Booth");
                                                npc.OptionID = 255;
                                                client.Send(npc.ToArray());
                                                return;
                                            }
                                            Game.ConquerStructures.Warehouse wh = client.Warehouses[(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID)warehousepacket.NpcID];
                                            if (wh == null) return;
                                            Interfaces.IConquerItem item = null;
                                            if (client.Inventory.TryGetItem(warehousepacket.UID, out item))
                                            {
                                                if (item.ID >= 729960 && item.ID <= 729970)
                                                    return;
                                                if (item.ID == 750000)
                                                    return;
                                                if (!ConquerItem.isRune(item.UID))
                                                {
                                                    if (wh.Add(item))
                                                    {
                                                        warehousepacket.UID = 0;
                                                        warehousepacket.Count = 1;
                                                        warehousepacket.Append(item);
                                                        client.Send(warehousepacket);
                                                        return;
                                                    }
                                                }
                                                else client.Send(new Message("You can not store Flame Stone Rune's in Warehouse", System.Drawing.Color.Red, Message.TopLeft));
                                            }
                                            break;
                                        }
                                    case Warehouse.RemoveItem:
                                        {
                                            Game.ConquerStructures.Warehouse wh = client.Warehouses[(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID)warehousepacket.NpcID];
                                            if (wh == null) return;
                                            if (wh.ContainsUID(warehousepacket.UID))
                                            {
                                                if (wh.Remove(warehousepacket.UID))
                                                {
                                                    client.Send(warehousepacket);
                                                    return;
                                                }
                                            }
                                            break;
                                        }
                                    default:
                                        {
                                            Console.WriteLine("Unknown type: " + warehousepacket.Type);
                                            break;
                                        }
                                }
                                break;
                            }
                        #endregion
                        #region GuildCommands (1107)
                        case 1107:
                            {
                                GuildCommand command = new GuildCommand(false);
                                command.Deserialize(packet);
                                switch (command.Type)
                                {
                                    case GuildCommand.Neutral1:
                                    case GuildCommand.Neutral2:
                                        {
                                            string name = System.Text.Encoding.UTF7.GetString(packet, 26, packet[25]);
                                            if (client.Guild != null)
                                            {
                                                if (client.AsMember.Rank == PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                {
                                                    client.Guild.RemoveAlly(name);
                                                    foreach (var guild in ServerBase.Kernel.Guilds.Values)
                                                    {
                                                        if (guild.Name == name && client.Guild.Name != name)
                                                        {
                                                            guild.RemoveAlly(client.Guild.Name);
                                                        }
                                                    }
                                                    client.Guild.RemoveEnemy(name);
                                                }
                                            }
                                            break;
                                        }
                                    case GuildCommand.Allied:
                                        {
                                            string name = System.Text.Encoding.UTF8.GetString(packet, 26, packet[25]);
                                            if (client.Guild != null)
                                            {
                                                if (client.AsMember.Rank == PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                {
                                                    AllyGuilds(name, client);
                                                }
                                            }
                                            break;
                                        }
                                    case GuildCommand.Enemied:
                                        {
                                            string name = System.Text.Encoding.UTF7.GetString(packet, 26, packet[25]);
                                            if (client.Guild != null)
                                            {
                                                if (client.AsMember.Rank == PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                {
                                                    client.Guild.AddEnemy(name);
                                                }
                                            }
                                            break;
                                        }
                                    default:
                                        {
                                            client.Send(packet);
                                            break;
                                        }
                                    case GuildCommand.Bulletin:
                                        {
                                            string message = System.Text.Encoding.UTF7.GetString(packet, 26, packet[25]);
                                            if (client.Guild != null)
                                            {
                                                if (client.AsMember.Rank == PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                {
                                                    client.Guild.Bulletin = message;
                                                    client.Guild.SendGuild(client);
                                                    Database.GuildTable.UpdateBulletin(client.Guild, client.Guild.Bulletin);
                                                }
                                            }
                                            break;
                                        }
                                    case GuildCommand.DonateSilvers:
                                        {
                                            if (client.Guild != null)
                                            {
                                                if (client.Entity.Money >= command.dwParam)
                                                {
                                                    client.Guild.SilverFund += command.dwParam;
                                                    Database.GuildTable.SaveFunds(client.Guild);
                                                    client.AsMember.SilverDonation += command.dwParam;
                                                    client.Entity.Money -= command.dwParam;
                                                    client.Guild.SendGuild(client);
                                                }
                                            }
                                            break;
                                        }
                                    case GuildCommand.DonateConquerPoints:
                                        {
                                            if (client.Guild != null)
                                            {
                                                if (client.Entity.ConquerPoints >= command.dwParam)
                                                {
                                                    client.Guild.ConquerPointFund += command.dwParam;
                                                    Database.GuildTable.SaveFunds(client.Guild);
                                                    client.AsMember.ConquerPointDonation += command.dwParam;
                                                    client.Entity.ConquerPoints -= command.dwParam;
                                                    client.Guild.SendGuild(client);
                                                }
                                            }
                                            break;
                                        }
                                    case GuildCommand.Refresh:
                                        {
                                            if (client.AsMember != null)
                                            {
                                                if (client.Guild != null)
                                                    client.Guild.SendGuild(client);
                                            }
                                            break;
                                        }
                                    case GuildCommand.Discharge:
                                        {
                                            string name = System.Text.Encoding.UTF7.GetString(packet, 26, packet[25]);
                                            if (client.Guild != null)
                                            {
                                                if (client.AsMember.Rank == PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                {
                                                    var member = client.Guild.GetMemberByName(name);
                                                    if (member != null)
                                                    {
                                                        if (member.ID != client.Entity.UID)
                                                        {
                                                            if (member.Rank == PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                                            {
                                                                client.Guild.DeputyLeaderCount--;
                                                                member.Rank = PhoenixProject.Game.Enums.GuildMemberRank.Member;
                                                                if (member.IsOnline)
                                                                {
                                                                    client.Guild.SendGuild(member.Client);
                                                                    member.Client.Entity.GuildRank = (ushort)member.Rank;
                                                                    member.Client.Screen.FullWipe();
                                                                    member.Client.Screen.Reload(null);
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            break;
                                        }
                                    case GuildCommand.Promote:
                                        {
                                            if (client.Guild != null)
                                            {
                                                if (client.AsMember.Rank == PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                {
                                                    if (client.Guild.Members.ContainsKey(command.dwParam))
                                                    {
                                                        var member = client.Guild.Members[command.dwParam];
                                                        if (member.Rank == PhoenixProject.Game.Enums.GuildMemberRank.Member)
                                                        {
                                                            member.Rank = PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader;
                                                            if (member.IsOnline)
                                                            {
                                                                client.Guild.SendGuild(member.Client);
                                                                member.Client.Entity.GuildRank = (ushort)member.Rank;
                                                                member.Client.Screen.FullWipe();
                                                                member.Client.Screen.Reload(null);
                                                            }
                                                        }
                                                        else if (member.Rank == PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                                        {
                                                            member.Rank = PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader;
                                                            if (member.IsOnline)
                                                            {
                                                                client.Guild.SendGuild(member.Client);
                                                                member.Client.Entity.GuildRank = (ushort)member.Rank;
                                                                member.Client.Screen.FullWipe();
                                                                member.Client.Screen.Reload(null);
                                                            }
                                                            client.AsMember.Rank = PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader;
                                                            client.Guild.SendGuild(client);
                                                            client.Entity.GuildRank = (ushort)client.AsMember.Rank;
                                                            client.Screen.FullWipe();
                                                            client.Screen.Reload(null);
                                                        }
                                                    }
                                                }
                                            }
                                            break;
                                        }
                                    case GuildCommand.JoinRequest:
                                        {
                                            if (ServerBase.Kernel.GamePool.ContainsKey(command.dwParam))
                                            {
                                                var Client = ServerBase.Kernel.GamePool[command.dwParam];
                                                if (Client.OnHoldGuildJoin == client.OnHoldGuildJoin && Client.OnHoldGuildJoin != 0)
                                                {
                                                    if (Client.Guild != null)
                                                    {
                                                        if (Client.AsMember.Rank != PhoenixProject.Game.Enums.GuildMemberRank.Member)
                                                        {
                                                            Client.Guild.AddMember(client);
                                                            Client.OnHoldGuildJoin = 0;
                                                            client.OnHoldGuildJoin = 0;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (client.AsMember.Rank != PhoenixProject.Game.Enums.GuildMemberRank.Member)
                                                        {
                                                            client.Guild.AddMember(Client);
                                                            Client.OnHoldGuildJoin = 0;
                                                            client.OnHoldGuildJoin = 0;
                                                        }
                                                    }
                                                    return;
                                                }
                                                if (client.Guild == null)
                                                {
                                                    command.dwParam = client.Entity.UID;
                                                    Client.Send(command);
                                                    Client.OnHoldGuildJoin = (uint)new Random().Next();
                                                    client.OnHoldGuildJoin = Client.OnHoldGuildJoin;
                                                }
                                            }
                                            break;
                                        }
                                    case GuildCommand.InviteRequest:
                                        {
                                            if (ServerBase.Kernel.GamePool.ContainsKey(command.dwParam))
                                            {
                                                var Client = ServerBase.Kernel.GamePool[command.dwParam];
                                                if (Client.OnHoldGuildJoin == client.OnHoldGuildJoin && Client.OnHoldGuildJoin != 0)
                                                {
                                                    if (Client.Guild != null)
                                                    {
                                                        if (Client.AsMember.Rank != PhoenixProject.Game.Enums.GuildMemberRank.Member)
                                                        {
                                                            Client.Guild.AddMember(client);
                                                            Client.OnHoldGuildJoin = 0;
                                                            client.OnHoldGuildJoin = 0;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (client.AsMember.Rank != PhoenixProject.Game.Enums.GuildMemberRank.Member)
                                                        {
                                                            client.Guild.AddMember(Client);
                                                            Client.OnHoldGuildJoin = 0;
                                                            client.OnHoldGuildJoin = 0;
                                                        }
                                                    }
                                                    return;
                                                }
                                                if (client.Guild != null)
                                                {
                                                    command.dwParam = client.Entity.UID;
                                                    Client.Send(command);
                                                    Client.OnHoldGuildJoin = 0;
                                                    client.OnHoldGuildJoin = Client.OnHoldGuildJoin;
                                                }
                                            }
                                            break;
                                        }
                                    case GuildCommand.Quit:
                                        {
                                            if (client.Guild != null)
                                            {
                                                if (client.AsMember.Rank != PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                {
                                                    client.Guild.ExpelMember(client.Entity.Name, true);
                                                }
                                            }
                                            break;
                                        }
                                }
                                break;
                            }
                        #endregion

                        #region Enlight (1127)
                        case 1127:
                            {
                                Enlight enlight = new Enlight(false);
                                enlight.Deserialize(packet);
                                if (ServerBase.Kernel.GamePool.ContainsKey(enlight.Enlighted))
                                {
                                    var Client = ServerBase.Kernel.GamePool[enlight.Enlighted];

                                    if (enlight.Enlighter == client.Entity.UID && enlight.Enlighted != enlight.Enlighter)
                                    {
                                        if (Client.Entity.ReceivedEnlightenPoints < 5)
                                        {
                                            if (client.Entity.EnlightenPoints >= 100)
                                            {
                                                if (Client.Entity.EnlightmentTime <= 80)
                                                {
                                                    client.Entity.EnlightenPoints -= 100;
                                                    Client.Entity.EnlightmentStamp = Time32.Now;
                                                    Client.IncreaseExperience(Game.Attacking.Calculate.Percent((int)Client.ExpBall, .10F), false);
                                                    Client.SendScreen(packet, true);
                                                    Client.Entity.ReceivedEnlightenPoints++;
                                                    Client.Entity.EnlightmentTime += 20;
                                                    if (client.Entity.EnlightmentTime > 80)
                                                        client.Entity.EnlightmentTime = 100;
                                                    else if (client.Entity.EnlightmentTime > 60)
                                                        client.Entity.EnlightmentTime = 80;
                                                    else if (client.Entity.EnlightmentTime > 40)
                                                        client.Entity.EnlightmentTime = 60;
                                                    else if (client.Entity.EnlightmentTime > 20)
                                                        client.Entity.EnlightmentTime = 40;
                                                    else if (client.Entity.EnlightmentTime > 0)
                                                        client.Entity.EnlightmentTime = 20;
                                                }
                                                else client.Send(new Message("You can't enlighten " + Client.Entity.Name + " yet because he has to wait a few minutes until he can be enlightened again.", System.Drawing.Color.Red, Message.TopLeft));
                                            }
                                            else client.Send(new Message("You can't enlighten " + Client.Entity.Name + " because you don't have enough enlighten points!", System.Drawing.Color.Red, Message.TopLeft));
                                        }
                                        else client.Send(new Message("You can't enlighten " + Client.Entity.Name + " because he/she was enlightened today five times already!", System.Drawing.Color.Red, Message.TopLeft));
                                    }
                                }
                                break;
                            }
                        #endregion
                        #region QuizShow (2068)
                        case 2068:
                            {
                                try
                                {

                                    byte Answered = (byte)(packet[8] - 1);

                                    int L = Environment.TickCount;
                                    int Now = (L - client.QuizInfo.LastAnswer) / 1000 + 1;
                                    ushort qn = PhoenixProject.Game.ConquerStructures.QuizShow.QuestionNO;
                                    if ((ushort)((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points) > 0)
                                    {
                                        client.QuizInfo.Time += (ushort)Now;
                                        client.QuizInfo.Score += (ushort)((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points);
                                        client.Entity.QuizPoints += (ushort)((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points);
                                        client.Entity.ConquerPoints += (ushort)((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points * 10);
                                        client.Send(new Message("You have won " + ((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points).ToString() + " quiz points and " + ((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points * 10).ToString() + " ConquerPoints", System.Drawing.Color.Red, Message.TopLeft));
                                        uint exp = 1000;
                                        exp = (uint)(exp * ((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points));
                                        client.IncreaseExperience((ulong)exp, false);
                                        Program.kimo3 = Answered;
                                    }
                                    else
                                    {
                                        client.QuizInfo.Time += (ushort)Now;
                                        client.QuizInfo.Score += (ushort)((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points);
                                        uint exp = 1000;
                                        exp = (uint)(exp * ((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points));
                                        client.IncreaseExperience((ulong)exp, false);
                                        client.Send(new Message("Ops Wrong Answer try Google if you dont know www.Google.com!!", System.Drawing.Color.Red, Message.TopLeft));

                                    }
                                    if (client.QuizInfo.Score >= 0)
                                    {
                                        /* int MyPlace = 0;
                                         for (int i = 0; i < 499; i++)
                                         {
                                             if (client.QuizInfo.Score < PhoenixProject.Game.ConquerStructures.QuizShow.Scores[i].Score)
                                             {
                                                 MyPlace++;
                                             }
                                             else
                                             {
                                                 if (client.Entity.UID == PhoenixProject.Game.ConquerStructures.QuizShow.Scores[i].EntityID)
                                                 {
                                                 }
                                                 else
                                                 {
                                                     if (client.QuizInfo.Score == PhoenixProject.Game.ConquerStructures.QuizShow.Scores[i].Score)
                                                     {
                                                         MyPlace++;
                                                     }
                                                 }
                                             }
                                         }*/
                                        if (client.QuizInfo.Score >= Kernel.MainQuiz.Score[0])
                                        {
                                            Kernel.MainQuiz.Name[0] = client.Entity.Name;
                                            Kernel.MainQuiz.Score[0] = client.QuizInfo.Score;
                                            Kernel.MainQuiz.Time[0] = client.QuizInfo.Time;
                                        }
                                        client.Send(new GamePackets.QuizInfo().InfoBuffer(client.QuizInfo.Score, client.QuizInfo.Time, client.QuizInfo.Rank));

                                    }

                                }
                                catch { }
                                break;
                            }
                        #endregion
                        #region NPC Dialog (2031 + 2032)
                        case 2031:
                        case 2032:
                            {
                                if (client.Action != 2)
                                    return;
                                NpcRequest req = new NpcRequest();
                                req.Deserialize(packet);
                                #region CaptureFlag
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 234 && client.Map.BaseID != 700)//CaptureFlag
                                {
                                    client.Entity.Teleport(1002, 384, 348);
                                }
                                #endregion
                                #region DemonCave
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 235 && client.Map.BaseID != 700)//DemonCave
                                {
                                    if (DateTime.Now.Hour == Game.KimoEvents.DemonHour && DateTime.Now.Minute < 5)
                                    {
                                        if (!client.DemonCave)
                                        {
                                            client.DemonCave = true;
                                            client.Entity.Teleport(1, 77, 69);
                                            client.Entity.DemonCave1 = 0;
                                            client.Entity.DemonCave2 = 0;
                                            client.Entity.DemonCave3 = 0;
                                            Data data = new Data(true);
                                            data.ID = Data.OpenCustom;
                                            data.UID = client.Entity.UID;
                                            data.TimeStamp = Time32.Now;
                                            data.dwParam = 3378;
                                            data.wParam1 = client.Entity.X;
                                            data.wParam2 = client.Entity.Y;
                                            client.Send(data);
                                        }
                                    }
                                }
                                #endregion
                                #region SkillTeam
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 236 && client.Map.BaseID != 700)//SkillTeamPK
                                {
                                    client.Entity.Teleport(1002, 460, 367);
                                }
                                #endregion
                                #region DonationWar
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 237 && client.Map.BaseID != 700)//dONATION
                                {
                                    client.Entity.Teleport(1002, 428, 392);
                                }
                                #endregion
                                #region ElitePk
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 249 && client.Map.BaseID != 700)//ElitePk
                                {
                                    if (DateTime.Now.Hour == Game.KimoEvents.EBHour && DateTime.Now.Minute >= 5 && DateTime.Now.Minute < 20)
                                    {
                                        if (!Game.Tournaments.EliteTournament.Top8.ContainsKey(client.Entity.UID))
                                        {
                                            Game.Tournaments.EliteTournament.AddMap(client);
                                            Data data = new Data(true);
                                            data.ID = Data.OpenCustom;
                                            data.UID = client.Entity.UID;
                                            data.TimeStamp = Time32.Now;
                                            data.dwParam = 3378;
                                            data.wParam1 = client.Entity.X;
                                            data.wParam2 = client.Entity.Y;
                                            client.Send(data);
                                        }
                                    }
                                }
                                #endregion
                                #region classpk
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 248 && client.Map.BaseID != 700)//ClassPk
                                {
                                    if (DateTime.Now.Hour == Game.KimoEvents.ClassHour && DateTime.Now.Minute < 05)
                                    {
                                        if (client.Entity.Class >= 10 && client.Entity.Class <= 15)
                                        {
                                            client.Entity.Teleport(7001, 25, 40);
                                        }
                                        if (client.Entity.Class >= 20 && client.Entity.Class <= 25)
                                        {
                                            client.Entity.Teleport(4500, 25, 40);
                                        }
                                        if (client.Entity.Class >= 40 && client.Entity.Class <= 45)
                                        {
                                            client.Entity.Teleport(4501, 25, 40);
                                        }
                                        if (client.Entity.Class >= 50 && client.Entity.Class <= 55)
                                        {
                                            client.Entity.Teleport(4502, 25, 40);
                                        }
                                        if (client.Entity.Class >= 60 && client.Entity.Class <= 65)
                                        {
                                            client.Entity.Teleport(4503, 25, 40);
                                        }
                                        if (client.Entity.Class >= 70 && client.Entity.Class <= 75)
                                        {
                                            client.Entity.Teleport(4504, 25, 40);
                                        }
                                        if (client.Entity.Class >= 132 && client.Entity.Class <= 135)
                                        {
                                            client.Entity.Teleport(4505, 25, 40);
                                        }
                                        if (client.Entity.Class >= 142 && client.Entity.Class <= 145)
                                        {
                                            client.Entity.Teleport(4506, 25, 40);
                                        }
                                        Data data = new Data(true);
                                        data.ID = Data.OpenCustom;
                                        data.UID = client.Entity.UID;
                                        data.TimeStamp = Time32.Now;
                                        data.dwParam = 3378;
                                        data.wParam1 = client.Entity.X;
                                        data.wParam2 = client.Entity.Y;
                                        client.Send(data);

                                    }
                                }
                                #endregion
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 247 && client.Map.BaseID != 700 && client.Entity.invite)//WeeklyPk
                                {
                                    client.Entity.Teleport(1002, 453, 294);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 246 && client.Map.BaseID != 700)//MonthlyPk
                                {
                                    client.Entity.Teleport(1002, 428, 243);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 245 && client.Map.BaseID != 700)//DisCity
                                {
                                    client.Entity.Teleport(1020, 534, 484);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 244 && client.Map.BaseID != 700)//GuildWar
                                {
                                    client.Disconnect();
                                    return;
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 233 && client.Map.BaseID != 700)//ClanWar
                                {
                                    client.Entity.Teleport(1002, 413, 246);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 198 && client.Map.BaseID != 700)//ClanWar
                                {
                                    client.Entity.Teleport(1002, 450, 372);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 196 && client.Map.BaseID != 700)//ClanWar
                                {
                                    client.Entity.Teleport(1002, 425, 385);
                                }
                                #region DailyPk
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 243 && client.Map.BaseID != 700)//DailyPk
                                {
                                    if (DateTime.Now.Minute >= 00 && DateTime.Now.Minute < 05)
                                    {
                                        client.Entity.Teleport(8877, 52, 44);
                                        Data data = new Data(true);
                                        data.ID = Data.OpenCustom;
                                        data.UID = client.Entity.UID;
                                        data.TimeStamp = Time32.Now;
                                        data.dwParam = 3378;
                                        data.wParam1 = client.Entity.X;
                                        data.wParam2 = client.Entity.Y;
                                        client.Send(data);
                                    }
                                }
                                #endregion
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 242 && client.Map.BaseID != 700)//SteedRace
                                {
                                    client.Entity.Teleport(1002, 423, 245);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 241 && client.Map.BaseID != 700)//SpouseWar
                                {
                                    client.Entity.Teleport(1002, 421, 292);
                                }
                                #region LastMan
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 240 && client.Map.BaseID != 700)//LastMan
                                {
                                    if (DateTime.Now.Minute >= 30 && DateTime.Now.Minute <= 32)
                                    {
                                        Random R = new Random();
                                        int Nr = R.Next(1, 10);
                                        if (Nr == 1) client.Entity.Teleport(3333, 51, 73);
                                        if (Nr == 2) client.Entity.Teleport(3333, 33, 34);
                                        if (Nr == 3) client.Entity.Teleport(3333, 67, 34);
                                        if (Nr == 4) client.Entity.Teleport(3333, 51, 73);
                                        if (Nr == 5) client.Entity.Teleport(3333, 33, 34);
                                        if (Nr == 6) client.Entity.Teleport(3333, 67, 34);
                                        if (Nr == 7) client.Entity.Teleport(3333, 51, 73);
                                        if (Nr == 8) client.Entity.Teleport(3333, 33, 34);
                                        if (Nr == 9) client.Entity.Teleport(3333, 67, 34);
                                        if (Nr == 10) client.Entity.Teleport(3333, 68, 57);

                                        Data data = new Data(true);
                                        data.ID = Data.OpenCustom;
                                        data.UID = client.Entity.UID;
                                        data.TimeStamp = Time32.Now;
                                        data.dwParam = 3378;
                                        data.wParam1 = client.Entity.X;
                                        data.wParam2 = client.Entity.Y;
                                        client.Send(data);
                                    }
                                }
                                #endregion
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 239 && client.Map.BaseID != 700)//EliteGW
                                {
                                    client.Entity.Teleport(1002, 414, 259);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 238 && client.Map.BaseID != 700)//TreasueBox
                                {
                                    client.Entity.Teleport(1002, 441, 352);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 233 && client.Map.BaseID != 700)//LordsWar
                                {
                                    client.Entity.Teleport(1002, 382, 394);
                                }
                                if (req.InteractType == NpcReply.MessageBox)
                                {
                                    if (client.Entity.ActivePOPUP == 99995)
                                    {
                                        client.Entity.ActivePOPUP = 0;
                                        break;
                                    }
                                    if (req.OptionID == 255)
                                    {
                                        if (client.OnMessageBoxOK != null)
                                        {
                                            client.OnMessageBoxOK.Invoke();
                                            client.OnMessageBoxOK = null;
                                        }
                                    }
                                    else
                                    {
                                        if (client.OnMessageBoxCANCEL != null)
                                        {
                                            client.OnMessageBoxCANCEL.Invoke();
                                            client.OnMessageBoxCANCEL = null;
                                        }
                                    }
                                }
                                else
                                {
                                    if (ID == 2031)
                                        client.ActiveNpc = req.NpcID;
                                    if (req.NpcID == 12)
                                    {
                                        if (client.Entity.VIPLevel > 0)
                                        {
                                            Data data = new Data(true);
                                            data.ID = Data.OpenWindow;
                                            data.UID = client.Entity.UID;
                                            data.TimeStamp = Time32.Now;
                                            data.dwParam = Data.WindowCommands.VIPWarehouse;
                                            data.wParam1 = client.Entity.X;
                                            data.wParam2 = client.Entity.Y;
                                            client.Send(data);
                                            break;
                                        }
                                    }
                                    Interfaces.INpc npc = null;
                                    if (req.InteractType == 102)
                                    {
                                        if (client.Guild != null)
                                        {
                                            if (client.AsMember.Rank == PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                            {
                                                client.Guild.ExpelMember(req.Input, false);
                                            }
                                        }
                                        return;
                                    }
                                    if (client.Map.Npcs.TryGetValue(client.ActiveNpc, out npc))
                                    {
                                        if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, npc.X, npc.Y) > 17)
                                            return;
                                        if (req.OptionID == 255 || (req.OptionID == 0 && ID == 2032))
                                            return;
                                        if (client.Entity.Dead)
                                            return;
                                        req.NpcID = client.ActiveNpc;
                                        //NpcDialogs.Dialogs.GetDialog(req, client);
                                        Dialogs.GetDialog(req, client);
                                    }
                                }
                                break;
                            }
                        #endregion
                        #region Compose (2036)
                        case 2036:
                            {
                                Compose compose = new Compose(false);
                                compose.Deserialize(packet);
                                ComposePlus(compose, client);
                                break;
                            }
                        #endregion
                        #region Offline TG (2044)
                        case 2044:
                            {
                                OfflineTGRequest otgr = new OfflineTGRequest(false);
                                otgr.Deserialize(packet);
                                switch (otgr.ID)
                                {
                                    case OfflineTGRequest.OnTrainingTimeRequested:
                                        {
                                            otgr.Minutes = 900;
                                            client.Send(otgr);
                                            break;
                                        }
                                    case OfflineTGRequest.OnConfirmation:
                                        {
                                            if (client.Map.BaseID == 6000 || client.Map.BaseID == 6001 || client.Entity.Dead)
                                            {
                                                return;
                                            }
                                            if (client.Entity.MapID == 1036 || client.Entity.MapID == 1039 || ServerBase.Constants.OfflineTG.Contains(client.Entity.MapID))
                                            {
                                                switch (client.Entity.PreviousMapID)
                                                {

                                                    case 1000:
                                                        {
                                                            client.Entity.PreviousMapID = 1000;
                                                            client.Entity.PrevX = 500;
                                                            client.Entity.PrevY = 560;
                                                            break;
                                                        }
                                                    case 1020:
                                                        {
                                                            client.Entity.PreviousMapID = 1020;
                                                            client.Entity.PrevX = 565;
                                                            client.Entity.PrevY = 562;
                                                            //client.Entity.Teleport(1020, 565, 562);
                                                            break;
                                                        }
                                                    case 1011:
                                                        {
                                                            client.Entity.PreviousMapID = 1011;
                                                            client.Entity.PrevX = 188;
                                                            client.Entity.PrevY = 264;
                                                            //client.Entity.Teleport(1011, 188, 264);
                                                            break;
                                                        }
                                                    case 1015:
                                                        {
                                                            client.Entity.PreviousMapID = 1015;
                                                            client.Entity.PrevX = 717;
                                                            client.Entity.PrevY = 571;
                                                            // client.Entity.Teleport(1015, 717, 571);
                                                            break;
                                                        }
                                                    default:
                                                        {
                                                            client.Entity.PreviousMapID = 1002;
                                                            client.Entity.PrevX = 429;
                                                            client.Entity.PrevY = 378;
                                                            //client.Entity.Teleport(1002, 429, 378);
                                                            break;
                                                        }
                                                }
                                                client.Entity.PreviousMapID = client.Entity.PreviousMapID;
                                                //client.Entity.PrevX = client.Entity.PrevX;
                                                //client.Entity.PrevY = client.Entity.PrevY;
                                            }
                                            else
                                            {
                                                client.Entity.PreviousMapID = client.Entity.MapID;
                                                client.Entity.PrevX = client.Entity.X;
                                                client.Entity.PrevY = client.Entity.Y;
                                            }

                                            client.Entity.MapID = 601;
                                            client.Entity.X = 64;
                                            client.Entity.Y = 56;
                                            client.OfflineTGEnterTime = DateTime.Now;
                                            client.Disconnect();
                                            break;
                                        }
                                    case OfflineTGRequest.ClaimExperience:
                                        {
                                            var T1 = new TimeSpan(DateTime.Now.Ticks);
                                            var T2 = new TimeSpan(client.OfflineTGEnterTime.Ticks);
                                            ushort minutes = (ushort)(T1.TotalMinutes - T2.TotalMinutes);
                                            minutes = (ushort)Math.Min((ushort)900, minutes);
                                            double expballGain = (double)300 * (double)minutes / (double)900;
                                            while (expballGain >= 100)
                                            {
                                                expballGain -= 100;
                                                client.IncreaseExperience(client.ExpBall, false);
                                            }
                                            if (expballGain != 0)
                                                client.IncreaseExperience((uint)(client.ExpBall * (expballGain / 100)), false);

                                            client.Entity.SetLocation(client.Entity.PreviousMapID, client.Entity.PrevX, client.Entity.PrevY);
                                            if (client.Entity.PreviousMapID == 1036 || client.Entity.PreviousMapID == 1039)
                                                switch (client.Entity.PreviousMapID)
                                                {

                                                    case 1000:
                                                        {
                                                            client.Entity.Teleport(1000, 500, 650);
                                                            break;
                                                        }
                                                    case 1020:
                                                        {
                                                            client.Entity.Teleport(1020, 565, 562);
                                                            break;
                                                        }
                                                    case 1011:
                                                        {
                                                            client.Entity.Teleport(1011, 188, 264);
                                                            break;
                                                        }
                                                    case 1015:
                                                        {
                                                            client.Entity.Teleport(1015, 717, 571);
                                                            break;
                                                        }
                                                    default:
                                                        {
                                                            client.Entity.Teleport(1002, 429, 378);
                                                            break;
                                                        }
                                                }
                                            else
                                            {
                                                client.Entity.Teleport(client.Entity.PreviousMapID, client.Entity.PrevX, client.Entity.PrevY);
                                            }
                                            client.OfflineTGEnterTime = DateTime.Now;
                                            break;
                                        }
                                    default:
                                        client.Send(otgr);
                                        break;
                                }
                                break;
                            }
                        #endregion
                        #region Trade partner (2046)
                        case 2046:
                            {
                                TradePartner partner = new TradePartner(false);
                                partner.Deserialize(packet);
                                switch (partner.Type)
                                {
                                    case TradePartner.RequestPartnership:
                                        RequestTradePartnership(partner, client);
                                        break;
                                    case TradePartner.RejectRequest:
                                        RejectPartnership(partner, client);
                                        break;
                                    case TradePartner.BreakPartnership:
                                        BreakPartnership(partner, client);
                                        break;
                                }
                                break;
                            }
                        #endregion
                        #region ItemLock (2048)
                        case 2048:
                            {
                                if (client.Action != 2)
                                    return;
                                ItemLock itemlock = new ItemLock(false);
                                itemlock.Deserialize(packet);
                                switch (itemlock.ID)
                                {
                                    case ItemLock.RequestLock:
                                        LockItem(itemlock, client);
                                        break;
                                    case ItemLock.RequestUnlock:
                                        UnlockItem(itemlock, client);
                                        break;
                                }
                                break;
                            }
                        #endregion
                        #region Broadcast (2050)
                        case 2050:
                            {
                                Broadcast cast = new Broadcast(false);
                                cast.Deserialize(packet);
                                switch (cast.Type)
                                {
                                    case Broadcast.ReleaseSoonMessages:
                                        {
                                            BroadcastInfoAwaiting(cast, client);
                                            break;
                                        }
                                    case Broadcast.MyMessages:
                                        {
                                            BroadcastClientMessages(cast, client);
                                            break;
                                        }
                                    case Broadcast.BroadcastMessage:
                                        {
                                            if (client.Trade.InTrade)
                                            {
                                                client.Send(new Message("You cannot send any broadcasts While you inTrade.", System.Drawing.Color.Red, Message.TopLeft));
                                                break;
                                            }
                                            if (client.Entity.MapID == 3031)
                                            {
                                                client.Send(new Message("You cannot send any broadcasts while you in LordsWar Tourment.", System.Drawing.Color.Red, Message.TopLeft));
                                                break;
                                            }
                                            if (Game.ConquerStructures.Broadcast.Broadcasts.Count == ServerBase.Constants.MaxBroadcasts)
                                            {
                                                client.Send(new Message("You cannot send any broadcasts for now. The limit has been reached. Wait until a broadcast is chopped down.", System.Drawing.Color.Red, Message.TopLeft));
                                                break;
                                            }
                                            if (client.Entity.ConquerPoints >= 5)
                                            {
                                                client.Entity.ConquerPoints -= 5;
                                                Game.ConquerStructures.Broadcast.BroadcastStr broadcast = new PhoenixProject.Game.ConquerStructures.Broadcast.BroadcastStr();
                                                broadcast.EntityID = client.Entity.UID;
                                                broadcast.EntityName = client.Entity.Name;
                                                broadcast.ID = Game.ConquerStructures.Broadcast.BroadcastCounter.Next;
                                                if (cast.List[0].Length > 80)
                                                    cast.List[0] = cast.List[0].Remove(80);
                                                broadcast.Message = cast.List[0];
                                                if (Game.ConquerStructures.Broadcast.Broadcasts.Count == 0)
                                                {
                                                    if (Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityID == 1)
                                                    {
                                                        Game.ConquerStructures.Broadcast.CurrentBroadcast = broadcast;
                                                        Game.ConquerStructures.Broadcast.LastBroadcast = DateTime.Now;
                                                        ServerBase.Kernel.SendWorldMessage(new Message(cast.List[0], "ALLUSERS", client.Entity.Name, System.Drawing.Color.Red, Message.BroadcastMessage), ServerBase.Kernel.GamePool.Values);
                                                        client.Send(cast);
                                                        break;
                                                    }
                                                }
                                                Game.ConquerStructures.Broadcast.Broadcasts.Add(broadcast);
                                                cast.dwParam = (uint)Game.ConquerStructures.Broadcast.Broadcasts.Count;
                                                client.Send(cast);
                                                break;
                                            }
                                            break;
                                        }
                                    case Broadcast.Urgen5CPs:
                                        {
                                            for (int c = 0; c < Game.ConquerStructures.Broadcast.Broadcasts.Count; c++)
                                            {
                                                var broadcast = Game.ConquerStructures.Broadcast.Broadcasts[c];
                                                if (broadcast.ID == cast.dwParam)
                                                {
                                                    if (c != 0)
                                                    {
                                                        if (client.Entity.ConquerPoints > 5)
                                                        {
                                                            broadcast.SpentCPs += 5;
                                                            client.Entity.ConquerPoints -= 5;
                                                            if (Game.ConquerStructures.Broadcast.Broadcasts[c - 1].SpentCPs <= broadcast.SpentCPs)
                                                            {

                                                                Game.ConquerStructures.Broadcast.Broadcasts[c] = Game.ConquerStructures.Broadcast.Broadcasts[c - 1];
                                                                Game.ConquerStructures.Broadcast.Broadcasts[c - 1] = broadcast;
                                                            }
                                                            else
                                                            {
                                                                Game.ConquerStructures.Broadcast.Broadcasts[c] = broadcast;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            break;
                                        }
                                    case Broadcast.Urgen15CPs:
                                        {
                                            for (int c = 0; c < Game.ConquerStructures.Broadcast.Broadcasts.Count; c++)
                                            {
                                                var broadcast = Game.ConquerStructures.Broadcast.Broadcasts[c];
                                                if (broadcast.ID == cast.dwParam)
                                                {
                                                    if (c != 0)
                                                    {
                                                        if (client.Entity.ConquerPoints > 15)
                                                        {
                                                            broadcast.SpentCPs += 15;
                                                            client.Entity.ConquerPoints -= 15;
                                                            for (int b = c - 1; b > 0; b--)
                                                                Game.ConquerStructures.Broadcast.Broadcasts[b] = Game.ConquerStructures.Broadcast.Broadcasts[b - 1];

                                                            Game.ConquerStructures.Broadcast.Broadcasts[0] = broadcast;
                                                        }
                                                    }
                                                }
                                            }
                                            break;
                                        }
                                }
                                break;
                            }
                        #endregion
                        #region Nobility (2064)
                        case 2064:
                            {
                                NobilityInfo nobility = new NobilityInfo(false);
                                nobility.Deserialize(packet);
                                Game.ConquerStructures.Nobility.Handle(nobility, client);
                                break;
                            }
                        #endregion
                        #region TopGuilds
                        case 1058:
                            {
                                if (client.Guild != null && client.AsMember != null)
                                {
                                    if (client.AsMember != null)
                                    {
                                        Writer.WriteUInt32((uint)client.AsMember.SilverDonation, 8, packet);
                                        if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                            if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                if (client.AsMember.SilverDonation > client.Guild.SilverFund)
                                                {
                                                    client.Guild.SilverFund = (uint)client.AsMember.SilverDonation;
                                                    client.Entity.GuildRank = (ushort)PhoenixProject.Game.Enums.GuildMemberRank.OSupervisor;
                                                    client.AsMember.Rank = (PhoenixProject.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                                }

                                        Writer.WriteUInt32((uint)client.AsMember.ConquerPointDonation, 20, packet);
                                        if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                            if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                if (client.AsMember.ConquerPointDonation > client.Guild.ConquerPointFund)
                                                {
                                                    client.Guild.ConquerPointFund = (uint)client.AsMember.ConquerPointDonation;
                                                    client.Entity.GuildRank = (ushort)PhoenixProject.Game.Enums.GuildMemberRank.CPSupervisor;
                                                    client.AsMember.Rank = (PhoenixProject.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                                }

                                    }
                                    Writer.WriteUInt32(client.Entity.PKPoints, 12, packet);
                                    if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                        if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                            if (client.Entity.PKPoints > client.Guild.pkp_donation)
                                            {
                                                client.Guild.pkp_donation = (uint)client.Entity.PKPoints;
                                                client.Entity.GuildRank = (ushort)PhoenixProject.Game.Enums.GuildMemberRank.PKSupervisor;
                                                client.AsMember.Rank = (PhoenixProject.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                            }

                                    if (client.ArenaStatistic != null)
                                    {
                                        Writer.WriteUInt32(client.ArenaStatistic.CurrentHonor, 24, packet);
                                        if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                            if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                if (client.ArenaStatistic.CurrentHonor > client.Guild.honor_donation)
                                                {
                                                    client.Guild.honor_donation = (uint)client.ArenaStatistic.CurrentHonor;
                                                    client.Entity.GuildRank = (ushort)PhoenixProject.Game.Enums.GuildMemberRank.HonoraryManager;
                                                    client.AsMember.Rank = (PhoenixProject.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                                }
                                    }
                                    Writer.WriteUInt32(0, 16, packet);
                                    if (client.Entity != null)
                                        if (client.Entity.Flowers != null)
                                        {
                                            Writer.WriteUInt32((uint)client.Entity.Flowers.RedRoses, 28, packet);
                                            if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                                if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                    if (client.Entity.Flowers.RedRoses > client.Guild.rose_donation)
                                                    {
                                                        client.Guild.rose_donation = (uint)client.Entity.Flowers.RedRoses;
                                                        client.Entity.GuildRank = (ushort)PhoenixProject.Game.Enums.GuildMemberRank.RoseSupervisor;
                                                        client.AsMember.Rank = (PhoenixProject.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                                    }

                                            Writer.WriteUInt32((uint)client.Entity.Flowers.Tulips, 32, packet);
                                            if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                                if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                    if (client.Entity.Flowers.Tulips > client.Guild.tuil_donation)
                                                    {
                                                        client.Guild.tuil_donation = (uint)client.Entity.Flowers.Tulips;
                                                        client.Entity.GuildRank = (ushort)PhoenixProject.Game.Enums.GuildMemberRank.TulipFollower;
                                                        client.AsMember.Rank = (PhoenixProject.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                                    }

                                            Writer.WriteUInt32((uint)client.Entity.Flowers.Lilies, 36, packet);
                                            if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                                if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                    if (client.Entity.Flowers.Lilies > client.Guild.lilies_donation)
                                                    {
                                                        client.Guild.lilies_donation = (uint)client.Entity.Flowers.Lilies;
                                                        client.Entity.GuildRank = (ushort)PhoenixProject.Game.Enums.GuildMemberRank.LilySupervisor;
                                                        client.AsMember.Rank = (PhoenixProject.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                                    }

                                            Writer.WriteUInt32((uint)client.Entity.Flowers.Orchads, 40, packet);
                                            if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                                if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                    if (client.Entity.Flowers.Orchads > client.Guild.orchid_donation)
                                                    {
                                                        client.Guild.orchid_donation = (uint)client.Entity.Flowers.Orchads;
                                                        client.Entity.GuildRank = (ushort)PhoenixProject.Game.Enums.GuildMemberRank.OrchidFollower;
                                                        client.AsMember.Rank = (PhoenixProject.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                                    }
                                            Writer.WriteUInt32((uint)(client.Entity.Flowers.Orchads
                                                + (uint)client.Entity.Flowers.RedRoses
                                                + (uint)client.Entity.Flowers.Tulips
                                                + (uint)client.Entity.Flowers.Lilies), 44, packet);
                                        }
                                    if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                        if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            if (client.Entity.Name == client.Guild.LeaderName)
                                            {
                                                client.Entity.GuildRank = (ushort)PhoenixProject.Game.Enums.GuildMemberRank.LeaderSpouse;
                                                client.AsMember.Rank = (PhoenixProject.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                            }
                                        }
                                    if (client.Guild != null)
                                        client.Guild.SendGuild(client);
                                    client.Send(packet);
                                }
                                break;
                            }
                        #endregion
                        #region Flowers (1150 & 1151)
                        case 1150:
                            {
                                new Game.Features.Flowers.FlowerSystem(packet, client);
                                break;
                            }
                        #endregion
                        #region Flowers (1150 & 1151)
                        case 1151:
                            {
                                int subtype = packet[4];
                                AddFlowers(client, packet);

                                break;
                            }
                        #endregion
                        #region Mentor prize (2067)
                        case 2067:
                            {
                                MentorPrize prize = new MentorPrize(false);
                                prize.Deserialize(packet);
                                switch (prize.Prize_Type)
                                {
                                    case MentorPrize.ClaimExperience:
                                        {
                                            client.IncreaseExperience((ulong)(((double)client.PrizeExperience / 606) * client.ExpBall), false);
                                            client.PrizeExperience = 0;
                                            foreach (var appr in client.Apprentices.Values)
                                            {
                                                appr.Actual_Experience = 0;
                                                Database.KnownPersons.SaveApprenticeInfo(appr);
                                            }
                                            prize.Mentor_ID = client.Entity.UID;
                                            prize.Prize_Type = MentorPrize.Show;
                                            prize.Prize_Experience = client.PrizeExperience;
                                            prize.Prize_HeavensBlessing = client.PrizeHeavenBlessing;
                                            prize.Prize_PlusStone = client.PrizePlusStone;
                                            client.Send(prize);
                                            break;
                                        }
                                    case MentorPrize.ClaimHeavenBlessing:
                                        {
                                            client.AddBless(client.PrizeHeavenBlessing);
                                            client.PrizeHeavenBlessing = 0;
                                            foreach (var appr in client.Apprentices.Values)
                                            {
                                                appr.Actual_HeavenBlessing = 0;
                                                Database.KnownPersons.SaveApprenticeInfo(appr);
                                            }
                                            prize.Mentor_ID = client.Entity.UID;
                                            prize.Prize_Type = MentorPrize.Show;
                                            prize.Prize_Experience = client.PrizeExperience;
                                            prize.Prize_HeavensBlessing = client.PrizeHeavenBlessing;
                                            prize.Prize_PlusStone = client.PrizePlusStone;
                                            client.Send(prize);
                                            break;
                                        }
                                    case MentorPrize.ClaimPlus:
                                        {
                                            int stones = client.PrizePlusStone / 100;
                                            int totake = stones;
                                            if (stones > 0)
                                            {
                                                for (; stones > 0; stones--)
                                                {
                                                    client.PrizePlusStone -= 100;
                                                    if (!client.Inventory.Add(730001, 1, 1))
                                                        break;
                                                }
                                            }
                                            foreach (var appr in client.Apprentices.Values)
                                            {
                                                if (appr.Actual_Plus >= totake)
                                                {
                                                    appr.Actual_Plus -= (ushort)totake;
                                                    totake = 0;
                                                }
                                                else
                                                {
                                                    totake -= appr.Actual_Plus;
                                                    appr.Actual_Plus = 0;
                                                }
                                                Database.KnownPersons.SaveApprenticeInfo(appr);
                                            }
                                            prize.Mentor_ID = client.Entity.UID;
                                            prize.Prize_Type = MentorPrize.Show;
                                            prize.Prize_Experience = client.PrizeExperience;
                                            prize.Prize_HeavensBlessing = client.PrizeHeavenBlessing;
                                            prize.Prize_PlusStone = client.PrizePlusStone;
                                            client.Send(prize);
                                            break;
                                        }
                                    case MentorPrize.Show:
                                        {
                                            prize.Mentor_ID = client.Entity.UID;
                                            prize.Prize_Type = MentorPrize.Show;
                                            prize.Prize_Experience = client.PrizeExperience;
                                            prize.Prize_HeavensBlessing = client.PrizeHeavenBlessing;
                                            prize.Prize_PlusStone = client.PrizePlusStone;
                                            client.Send(prize);
                                            break;
                                        }
                                }
                                break;
                            }
                        #endregion
                        #region ElitePk Tournament 2223 | 2219
                        case 2223:
                            {
                                if (client.Entity.MapID == 6002)
                                    break;

                                if (Game.Tournaments.EliteTournament.Start)
                                    break;

                                GamePackets.Elite_Pk pk = new Elite_Pk(client.Entity.UID);
                                pk.Send(client);
                                break;
                            }
                        case 2219:
                            {
                                if (client.Entity.MapID == 6002)
                                    break;
                                byte[] sed = new byte[36]
                        {
                        0x1C ,0x00 ,0xAB ,0x08 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x03 ,0x00    //  ; «         
            ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x54 ,0x51 ,0x53 ,0x65     // ;            TQSe
            ,0x72 ,0x76 ,0x65 ,0x72                                         // ;rver
                        };
                                client.Send(sed);
                                break;

                            }
                        case 1063:
                            {
                                GamePackets.Guild_Pk pk = new Guild_Pk(client.Entity.UID);
                                pk.Send(client);
                                break;
                            }
                        /* case 2224:
                             {
                                 client.Send(packet);
                                 break;
                             }
                         case 2232:
                             {
                                 client.Send(packet);
                                 break;
                             }
                         case 2242:
                             {
                                 client.Send(packet);
                                 break;
                             }
                         case 2243:
                             {
                                 client.Send(packet);
                                 break;
                             }*/
                        /*case 2242://Request Arena ranking List 2245 2242 2244
                            {
                                //Code snippet that belongs to Ultimation
                                Game.ConquerStructures.TeamArena.Statistics.ShowWiners(client);
                                break;
                            }
                        case 2245:
                            {
                                client.TeamArenaStatistic.Send(client);
                                break;
                            }*/
                        /*case 2245:
                            {
                                client.Send(packet);
                                break;
                            }*/
                        /* case 2233:
                             {
                                 GamePackets.Team_Pk pk = new Team_Pk(client.Entity.UID);
                                 pk.Send(client);
                                 break;
                             }*/
                        /* case 2252:
                             {
                                 client.Send(packet);
                                 break;
                             }*/
                        /* case 2253:
                             {
                                 GamePackets.Team_PkComun pk = new Team_PkComun(client.Entity.UID);
                                 pk.Send(client);
                                 break;
                             }*/
                        case 1130:
                            {
                                if (client.Entity.TitlePacket != null)
                                {
                                    if (packet[9] == 4)
                                    {
                                        if (client.Entity.TitlePacket.dwParam2 != 0)
                                            client.Entity.TitlePacket.Send(client);
                                    }
                                    if (packet[9] == 3)
                                    {
                                        client.Entity.TitleActivated = packet[8];
                                        client.Send(packet);
                                        client.SendScreen(client.Entity.SpawnPacket, false);
                                    }
                                }
                                break;
                            }
                        #endregion

                        #region vipteleport
                        case 1128:
                            {
                                p1128 vp = new p1128(false);
                                vp.Deserialize(packet);
                                if (ServerBase.Constants.VipNo.Contains(client.Entity.MapID))
                                    return;
                                if (client.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Ghost))
                                    return;
                                switch (vp.UID)
                                {
                                    case 0://player city teleport
                                        {
                                            switch (vp.UID2)
                                            {
                                                ////////////////////////////////////////////////////////////////////////////////////////////////////
                                                case 1://tc
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1002, 429, 378);
                                                    break;
                                                case 2://pc
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1011, 188, 264);
                                                    break;
                                                case 3://ac
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1020, 565, 562);
                                                    break;
                                                case 4://dc
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1000, 500, 650);
                                                    break;
                                                case 5://bc
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1015, 717, 571);
                                                    break;
                                                    ////////////////////////////////////////////////////////////////////////////////////////
                                                    {

                                                    }
                                                default: Console.WriteLine("Unknown 1128 portal subtype 1 : " + vp.UID2); break;
                                            }
                                            break;
                                        }
                                    case 1://Team city teleport
                                        {
                                            switch (vp.UID2)
                                            {
                                                ////////////////////////////////////////////////////////////////////////////////////////////////////
                                                case 1://tc
                                                    foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                                    {
                                                        if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                        {
                                                            if (client.Map.BaseID != 700)
                                                            {
                                                                teammate.Entity.Teleport(1002, 429, 378);
                                                            }
                                                        }
                                                    }
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1002, 429, 378);
                                                    break;
                                                case 2://pc
                                                    foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                                    {
                                                        if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                        {
                                                            if (client.Map.BaseID != 700)
                                                            {
                                                                teammate.Entity.Teleport(1011, 188, 264);
                                                            }
                                                        }
                                                    }
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1011, 188, 264);
                                                    break;
                                                case 3://ac
                                                    foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                                    {
                                                        if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                        {
                                                            if (client.Map.BaseID != 700)
                                                            {
                                                                teammate.Entity.Teleport(1020, 565, 562);
                                                            }
                                                        }
                                                    }
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1020, 565, 562);
                                                    break;
                                                case 4://dc
                                                    foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                                    {
                                                        if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                        {
                                                            if (client.Map.BaseID != 700)
                                                            {
                                                                teammate.Entity.Teleport(1000, 500, 650);
                                                            }
                                                        }
                                                    }
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1000, 500, 650);
                                                    break;
                                                case 5://bc
                                                    foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                                    {
                                                        if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                        {
                                                            if (client.Map.BaseID != 700)
                                                            {
                                                                teammate.Entity.Teleport(1015, 717, 571);
                                                            }
                                                        }
                                                    }
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1015, 717, 571);
                                                    break;
                                                    ////////////////////////////////////////////////////////////////////////////////////////
                                                    {

                                                    }
                                                default: Console.WriteLine("Unknown 1128 portal subtype 2 : " + vp.UID2); break;
                                            }
                                            break;
                                        }

                                    default:
                                        Console.WriteLine("Unknown 1128 subtype: " + vp.UID); break;
                                }
                                break;
                            }
                        #endregion
                        #region MentorApprentice (2065)
                        case 2065:
                            {
                                MentorApprentice ma = new MentorApprentice(false);
                                ma.Deserialize(packet);
                                switch (ma.Type)
                                {
                                    case MentorApprentice.LeaveMentor:
                                        {
                                            LeaveMentor(ma, client);
                                            break;
                                        }
                                    case MentorApprentice.ExpellApprentice:
                                        {
                                            ExpelApprentice(ma, client);
                                            break;
                                        }
                                    case MentorApprentice.RequestApprentice:
                                        {
                                            AddApprentice(ma, client);
                                            break;
                                        }
                                    case MentorApprentice.RequestMentor:
                                        {
                                            AddMentor(ma, client);
                                            break;
                                        }
                                    case MentorApprentice.AcceptRequestApprentice:
                                        {
                                            AcceptRequestApprentice(ma, client);
                                            break;
                                        }
                                    case MentorApprentice.AcceptRequestMentor:
                                        {
                                            AcceptRequestMentor(ma, client);
                                            break;
                                        }
                                }
                                break;
                            }
                        case 2066:
                            {
                                MentorInformation info = new MentorInformation(false);
                                info.Deserialize(packet);
                                if (info.Mentor_Type == 1)
                                {
                                    client.ReviewMentor();
                                }
                                break;
                            }
                        #endregion
                        #region Guild members (2102)
                        case 2102:
                            {
                                ushort Page = BitConverter.ToUInt16(packet, 8);
                                if (client.Guild != null)
                                {
                                    if (client.AsMember != null)
                                        client.Guild.SendMembers(client, Page);
                                }
                                break;
                            }
                        #endregion
                        #region Arena (2207<->2211)
                        case 2207://Request Arena ranking List 2245 2242 2244
                            {
                                //Code snippet that belongs to Ultimation
                                ushort PageIndex = BitConverter.ToUInt16(packet, 6);
                                Game.ConquerStructures.Arena.Statistics.ShowRankingPage(packet[4], PageIndex, client);
                                break;
                            }
                        case 2206:
                            {
                                //Code snippet that belongs to Ultimation
                                ushort PageIndex = BitConverter.ToUInt16(packet, 4);
                                Game.ConquerStructures.Arena.QualifyEngine.RequestGroupList(client, PageIndex);
                                break;
                            }
                        case 2205://Arena Signup!
                            {
                                //Code snippet that belongs to Ultimation
                                uint DialogID = BitConverter.ToUInt32(packet, 4);
                                uint ButtonID = BitConverter.ToUInt32(packet, 8);
                                switch (DialogID)
                                {
                                    case 4:
                                        {
                                            switch (ButtonID)
                                            {
                                                case 0:
                                                    {
                                                        Game.ConquerStructures.Arena.QualifyEngine.DoQuit(client);
                                                        break;
                                                    }
                                            }
                                            break;
                                        }
                                    case 0: Game.ConquerStructures.Arena.QualifyEngine.DoSignup(client); client.Send(packet); break;
                                    case 1: Game.ConquerStructures.Arena.QualifyEngine.DoQuit(client); client.Send(packet); break;
                                    case 3:
                                        {
                                            switch (ButtonID)
                                            {
                                                case 2: Game.ConquerStructures.Arena.QualifyEngine.DoGiveUp(client); break;
                                                case 1: Game.ConquerStructures.Arena.QualifyEngine.DoAccept(client); break;
                                            }
                                            break;
                                        }
                                    case 5:
                                        {
                                            if (client.ArenaStatistic.ArenaPoints <= 1500)
                                                if (client.Entity.Money >= 9000000)
                                                {
                                                    client.Entity.Money -= 9000000;
                                                    client.ArenaStatistic.ArenaPoints += 1500;
                                                    client.Send(client.ArenaStatistic);
                                                }
                                            break;
                                        }
                                    case 11://Win/Lose Dialog
                                        {
                                            switch (ButtonID)
                                            {
                                                case 0: Game.ConquerStructures.Arena.QualifyEngine.DoSignup(client); break;
                                            }
                                            break;
                                        }

                                }
                                break;
                            }
                        case 2208://Request Arena Winner List
                            {
                                //Code snippet that belongs to Ultimation
                                Game.ConquerStructures.Arena.Statistics.ShowWiners(client);
                                break;
                            }
                        case 2209:
                            {//bug in console
                                client.ArenaStatistic.Send(client);
                                break;
                            }
                        case 2211:
                            {
                                if (client.Map.BaseID == 6001 || client.Map.BaseID == 6000)
                                    return;
                                ushort Type = BitConverter.ToUInt16(packet, 4);
                                uint Fighter = BitConverter.ToUInt32(packet, 10);
                                if (Type == 0)
                                {
                                    if (ServerBase.Kernel.GamePool.ContainsKey(Fighter))
                                    {
                                        Client.GameState Client = ServerBase.Kernel.GamePool[Fighter];
                                        if (Client.QualifierGroup != null)
                                        {
                                            if (Client.QualifierGroup.Inside)
                                            {
                                                if (!Client.QualifierGroup.Done)
                                                {
                                                    Client.QualifierGroup.BeginWatching(client);
                                                }
                                            }
                                        }
                                    }
                                }
                                else if (Type == 1)
                                {
                                    Game.ConquerStructures.Arena.QualifyEngine.DoLeave(client);
                                }
                                else if (Type == 4)
                                {
                                    string name = "";
                                    for (int c = 22; c < packet.Length; c++)
                                    {
                                        if (packet[c] != 0)
                                            name += (char)packet[c];
                                        else
                                            break;
                                    }
                                    Game.ConquerStructures.Arena.QualifyEngine.DoCheer(client, name);
                                }
                                break;
                            }
                        #endregion
                        #region Movement/Walk (10005)
                        case 10005:
                            {
                                if (client.Action != 2)
                                    return;
                                GroundMovement groundMovement = new GroundMovement(false);
                                groundMovement.Deserialize(packet);
                                PlayerGroundMovment(groundMovement, client);

                                break;
                            }
                        #endregion
                        //24 2533 53 152 1 0 0 0 84
                        //60 0 229 9 50 151 152 0 1 0 0 0 0 0 0 0 84 81 83 101 114 118 101 114
                        //3c 00 e5 09 32 97 98 00 01 00 00 00 00 00 00 00 54 51 53 65 72 76 65 72
                        /* case 2533:
                             {
                                 KimoChi prize = new KimoChi(false);
                                 prize.Deserialize(packet);
                                 client.Send(packet);
                                 client.Send(prize);
                                 break;

                             }*/
                        #region Lottery2
                        case 1314://1314
                            {

                                Game.Lottery.Handle(packet, client);
                                break;
                            }
                        #endregion
                        #region New AutoInvite
                        case 1126://1314
                            {

                                EventAlert2.Handle(packet, client);
                                break;
                            }
                        #endregion
                        #region ClanWar inv (1313)
                        case 1313://1313
                            {
                                if (packet[4] == 8)
                                {
                                    client.Entity.Teleport(1002, 413, 246);
                                }

                                return;
                            }
                        #endregion //packet[8] = 1;

                        #region ChangeName (2080)
                        case 2080:
                            {
                                NameChange prize = new NameChange(false);
                                //prize.EditAllowed = 1;
                                //prize.EditCount = 1;
                                prize.Deserialize(packet);

                                switch (prize.Action)//string name = System.Text.Encoding.UTF7.GetString(packet, 26, packet[25]);
                                {

                                    case PhoenixProject.Network.GamePackets.NameChange.NameChangeAction.Request:
                                        {
                                            string newname = System.Text.Encoding.UTF7.GetString(packet, 10, 16).TrimEnd('\0');

                                            packet[6] = (byte)client.Entity.EditeName;
                                            packet[8] = (byte)(5 - client.Entity.EditeName);
                                            prize.Send(client);
                                            client.Send(prize);
                                            if (newname != "")
                                            {
                                                if (newname == "")
                                                    return;
                                                if (newname.Contains("[") && newname.Contains("]"))
                                                    return;
                                                if (Dialogs.InvalidCharacters(newname) && Dialogs.InvalidCharacters3(newname) && !newname.Contains("[") && !newname.Contains("]"))
                                                {
                                                    PhoenixProject.Database.MySqlCommand cmd2 = new PhoenixProject.Database.MySqlCommand(PhoenixProject.Database.MySqlCommandType.SELECT).Select("entities").Where("name", newname);//debug and test!
                                                    PhoenixProject.Database.MySqlReader r = new PhoenixProject.Database.MySqlReader(cmd2);
                                                    if (!r.Read())//wait
                                                    {
                                                        if (client.Entity.ConquerPoints >= PhoenixProject.Database.rates.ChangeName)
                                                        {
                                                            client.Entity.ConquerPoints -= PhoenixProject.Database.rates.ChangeName;

                                                            // PhoenixProject.Database.MySqlCommand cmd = new PhoenixProject.Database.MySqlCommand(PhoenixProject.Database.MySqlCommandType.UPDATE);
                                                            //  cmd.Update("entities").Set("namechange", newname).Where("UID", client.Entity.UID).Execute();
                                                            r.Close();
                                                            r.Dispose();
                                                            client.Entity.NewName = newname;

                                                            // Console.WriteLine(client.Entity.Name + ", Changed hes Name to : " + newname);
                                                            ServerBase.Kernel.SendWorldMessage(new Message(client.Entity.Name + ", Changed He's/Hers Name to " + newname + ", Will be affected after  Relogin.",
                                                                System.Drawing.Color.Red, Message.Talk), ServerBase.Kernel.GamePool.Values);

                                                            // client.Edita = 0;
                                                            // client.Edite = 1;
                                                            client.Entity.EditeName += 1;
                                                            packet[4] = 1;
                                                            prize.Send(client);
                                                            client.Send(prize);
                                                            Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Your new name is : " + newname + ", After relog You will get your new name, Want to Relog?");
                                                            npc.OptionID = 244;
                                                            client.Send(npc.ToArray());
                                                        }
                                                        else
                                                        {
                                                            Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Come back when you have " + PhoenixProject.Database.rates.ChangeName + " CPS.");
                                                            npc.OptionID = 255;
                                                            client.Send(npc.ToArray());
                                                            r.Close();
                                                            r.Dispose();

                                                        }
                                                    }
                                                    else
                                                    {
                                                        packet[4] = 2;
                                                        prize.Send(client);
                                                        client.Send(prize);
                                                        r.Close();
                                                        r.Dispose();

                                                    }
                                                }
                                                else
                                                {
                                                    Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "im sorry not allowed now close the dialog and try again");
                                                    npc.OptionID = 255;
                                                    client.Send(npc.ToArray());
                                                    //r.Close();
                                                    //r.Dispose();

                                                }
                                            }
                                            break;
                                        }
                                }
                                //packet[8] = 1;
                                //byte NewClass = packet[4];
                                //ushort NewBody = packet[8];

                                break;
                            }
                        #endregion

                        #region Reincarnation (1066)
                        case 1066:
                            {
                                if (client.Entity.Reborn != 2) return;
                                if (ServerBase.Kernel.ReincarnatedCharacters.ContainsKey(client.Entity.UID))
                                    return;
                                byte NewClass = packet[4];
                                ushort NewBody = packet[8];
                                if (client.Entity.Body.ToString().EndsWith("1") || client.Entity.Body.ToString().EndsWith("2"))
                                    NewBody += 2000;
                                else NewBody += 1000;

                                if (client.Inventory.Contains(711083, 1) && client.Entity.ConquerPoints >= PhoenixProject.Database.rates.Riencration)
                                {
                                    client.Entity.Body = NewBody;
                                    new PacketHandler.Reincarnation(client, NewClass);
                                    client.Inventory.Remove(711083, 1);
                                    client.Entity.ConquerPoints -= PhoenixProject.Database.rates.Riencration;
                                }
                                break;
                            }
                        #endregion
                        #region PurifyItem (2076)
                        case 2076:
                            {
                                Purification ps = new Purification(false);
                                ps.Deserialize(packet);
                                switch (ps.Mode)
                                {
                                    case Purification.Purify:
                                        PurifyItem(ps, client); break;
                                    case Purification.ItemArtifact:
                                        PurifyRefinery(ps, client); break;
                                    //case Purification.Stabilaze:
                                    //new Game.Features.Refinery.Handle(packet, client); break;
                                }
                                break;
                            }
                        #endregion
                        #region KimoClans
                        case 1312:
                            {
                                //GameState targets;
                                switch (packet[4])
                                {
                                    case 21:
                                        {

                                            if (client.Entity.Myclan != null)
                                            {
                                                try
                                                {
                                                    uint lider = 0;
                                                    string name_receive = System.Text.Encoding.UTF7.GetString(packet, 18, packet[17]);

                                                    foreach (Client.GameState clien in ServerBase.Kernel.GamePool.Values)
                                                    {

                                                        if (clien.Entity.Name == name_receive)
                                                        {
                                                            lider = clien.Entity.UID;
                                                        }
                                                    }

                                                    if (lider == client.Entity.UID) return;
                                                    Client.GameState aClient = null;
                                                    if (PhoenixProject.ServerBase.Kernel.GamePool.TryGetValue(lider, out aClient))
                                                    {

                                                        if (PhoenixProject.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                                        {
                                                            if (PhoenixProject.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].Members.ContainsKey(aClient.Entity.UID))
                                                            {
                                                                PhoenixProject.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanLider = aClient.Entity.Name;
                                                                aClient.Entity.ClanRank = 100;
                                                                aClient.Entity.Myclan.Members[aClient.Entity.UID].Rank = 100;
                                                                //if (aClient.Entity.Myclan.Members.ContainsKey(client.Entity.UID))
                                                                //aClient.Entity.Myclan.Members[client.Entity.UID].Rank = 0;
                                                                client.Entity.ClanRank = 10;
                                                                client.Entity.Myclan.Members[client.Entity.UID].Rank = 10;
                                                                Database.Clans.SaveClan(aClient.Entity.Myclan);
                                                                //Database.Clans.JoinClan(client);
                                                                Network.GamePackets.Clan cl = new PhoenixProject.Network.GamePackets.Clan(client, 1);
                                                                client.Send(cl.ToArray());
                                                                ClanMembers clan = new ClanMembers(client);
                                                                client.Send(clan.ToArray());
                                                                Network.GamePackets.Clan cls = new PhoenixProject.Network.GamePackets.Clan(aClient, 1);
                                                                aClient.Send(cls.ToArray());
                                                                ClanMembers clans = new ClanMembers(aClient);
                                                                aClient.Send(clans.ToArray());
                                                                ServerBase.Kernel.GamePool[aClient.Entity.UID].Screen.FullWipe();
                                                                ServerBase.Kernel.GamePool[aClient.Entity.UID].Screen.Reload(null);
                                                                ServerBase.Kernel.GamePool[client.Entity.UID].Screen.FullWipe();
                                                                ServerBase.Kernel.GamePool[client.Entity.UID].Screen.Reload(null);
                                                            }
                                                        }

                                                    }
                                                    else
                                                    {
                                                        PhoenixProject.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanLider = name_receive;
                                                        client.Entity.ClanRank = 10;
                                                        client.Entity.Myclan.Members[client.Entity.UID].Rank = 10;
                                                        Database.Clans.SaveClan(client.Entity.Myclan);
                                                        Database.Clans.TransferClan(name_receive);
                                                        Network.GamePackets.Clan cl = new PhoenixProject.Network.GamePackets.Clan(client, 1);
                                                        client.Send(cl.ToArray());
                                                        ClanMembers clan = new ClanMembers(client);
                                                        client.Send(clan.ToArray());
                                                        ServerBase.Kernel.GamePool[client.Entity.UID].Screen.FullWipe();
                                                        ServerBase.Kernel.GamePool[client.Entity.UID].Screen.Reload(null);
                                                        //Console.WriteLine("gggf");

                                                    }
                                                }
                                                catch (Exception e)
                                                {
                                                    Program.SaveException(e);
                                                }
                                            }
                                            break;
                                        }

                                    case (byte)Game.Clan_Typ.Quit:
                                        {
                                            if (client.Entity.Myclan != null)
                                            {
                                                if (client.Entity.ClanRank != 100)
                                                {
                                                    client.Entity.Myclan.ExpelMember(client.Entity.Name, true);
                                                }
                                            }

                                            break;
                                        }
                                    case 25:
                                        {
                                            if (client.Entity.Myclan == null) return;
                                            string buletin = System.Text.Encoding.UTF7.GetString(packet, 18, packet[17]);
                                            if (PhoenixProject.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                                PhoenixProject.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanBuletion = buletin;
                                            Database.Clans.SaveClan(PhoenixProject.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId]);
                                            client.Send(packet);
                                            break;
                                        }
                                    case 22:
                                        {
                                            if (client.Entity.Myclan != null)
                                            {
                                                if (client.Entity.ClanRank == 100)
                                                {
                                                    string name = System.Text.Encoding.UTF7.GetString(packet, 18, packet[17]);
                                                    if (client.Entity.Myclan != null)
                                                    {
                                                        if (client.Entity.ClanRank == 100)
                                                        {
                                                            client.Entity.Myclan.ExpelMember(name, false);
                                                            Database.Clans.KickClan(name);
                                                        }
                                                    }

                                                }
                                            }

                                            break;
                                        }

                                    case 26:
                                        {
                                            uint money = BitConverter.ToUInt32(packet, 8);
                                            if (client.Entity.Money >= money && client.Entity.Myclan != null)
                                            {
                                                client.Entity.Myclan.Members[client.Entity.UID].Donation += money;
                                                client.Entity.Money -= money;
                                                if (PhoenixProject.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                                    PhoenixProject.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanDonation += money;
                                                Network.GamePackets.Clan cl = new PhoenixProject.Network.GamePackets.Clan(client, 1);
                                                client.Send(cl.ToArray());
                                                Database.Clans.SaveClientDonation(client);
                                                Database.Clans.SaveClan(PhoenixProject.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId]);
                                            }
                                            break;
                                        }
                                    case 11:
                                        {

                                            uint lider = BitConverter.ToUInt32(packet, 8);
                                            if (PhoenixProject.ServerBase.Kernel.GamePool.ContainsKey(lider))
                                            {
                                                packet[4] = 11;
                                                Network.Writer.WriteUInt32(client.Entity.UID, 8, packet);
                                                packet[16] = 1;
                                                packet[17] = (byte)client.Entity.Name.Length;
                                                for (int i = 0; i < client.Entity.Name.Length; i++)
                                                {
                                                    try
                                                    {
                                                        packet[18 + i] = Convert.ToByte(client.Entity.Name[i]);

                                                    }
                                                    catch { }
                                                }
                                                if (PhoenixProject.ServerBase.Kernel.GamePool[lider].Entity.Myclan != null)
                                                    PhoenixProject.ServerBase.Kernel.GamePool[lider].Send(packet);
                                            }
                                            break;
                                        }
                                    case 12:
                                        {
                                            if (packet[16] == 1)
                                            {
                                                if (client.Entity.Myclan != null)
                                                    if (client.Entity.Myclan.Members[client.Entity.UID].Rank == 100)
                                                    {
                                                        {
                                                            if (client.Entity.Myclan.Members.Count < 7)
                                                            {

                                                                uint memeber = BitConverter.ToUInt32(packet, 8);
                                                                if (ServerBase.Kernel.GamePool.ContainsKey(memeber))
                                                                {
                                                                    Game.ClanMembers member = new PhoenixProject.Game.ClanMembers();
                                                                    member.UID = ServerBase.Kernel.GamePool[memeber].Entity.UID;
                                                                    member.Donation = 0;
                                                                    member.Rank = 10;
                                                                    member.Class = ServerBase.Kernel.GamePool[memeber].Entity.Class;
                                                                    member.Level = ServerBase.Kernel.GamePool[memeber].Entity.Level;
                                                                    member.Name = ServerBase.Kernel.GamePool[memeber].Entity.Name;
                                                                    if (!client.Entity.Myclan.Members.ContainsKey(memeber))
                                                                        client.Entity.Myclan.Members.Add(member.UID, member);

                                                                    ServerBase.Kernel.GamePool[memeber].Entity.ClanRank = 10;
                                                                    ServerBase.Kernel.GamePool[memeber].Entity.ClanId = client.Entity.ClanId;
                                                                    ServerBase.Kernel.GamePool[memeber].Entity.Myclan = client.Entity.Myclan;
                                                                    ServerBase.Kernel.GamePool[memeber].Entity.ClanName = client.Entity.ClanName;
                                                                    Database.Clans.JoinClan(ServerBase.Kernel.GamePool[memeber]);
                                                                    ServerBase.Kernel.GamePool[memeber].Screen.FullWipe();
                                                                    ServerBase.Kernel.GamePool[memeber].Screen.Reload(null);
                                                                    Network.GamePackets.Clan cl = new PhoenixProject.Network.GamePackets.Clan(client, 1);
                                                                    client.Send(cl.ToArray());
                                                                    ClanMembers clan = new ClanMembers(client);
                                                                    client.Send(clan.ToArray());
                                                                }
                                                            }
                                                        }
                                                    }
                                            }
                                            break;
                                        }
                                    case 4:
                                        {
                                            ClanMembers clan = new ClanMembers(client);
                                            client.Send(clan.ToArray());
                                            break;
                                        }
                                    case 0x1d:
                                        {
                                            if (client.Entity.Myclan != null)
                                            {
                                                Network.Writer.WriteUInt32(client.Entity.Myclan.ClanId, 8, packet);
                                                Network.Writer.WriteByte(1, 16, packet);
                                                Network.Writer.WriteByte(0x0d, 17, packet);
                                                Network.Writer.WriteString("0 0 0 0 0 0 0", 18, packet);
                                                client.Send(packet);
                                                Network.GamePackets.Clan cl = new PhoenixProject.Network.GamePackets.Clan(client, 1);
                                                client.Send(cl.ToArray());
                                                client.Send(packet);

                                                if (client.Entity.Myclan.ClanBuletion != "")
                                                    client.Send(cl.UpgradeBuletin(client.Entity.Myclan.ClanBuletion));
                                            }
                                            else
                                            {
                                                client.Send(packet);
                                                packet[4] = 23;
                                            }

                                            break;
                                        }
                                    case 0x18:
                                        {
                                            client.Send(packet);
                                            break;
                                        }
                                    case (byte)Game.Clan_Typ.AddAlly:
                                        {
                                            Game.Clans clan = client.Entity.Myclan;
                                            if (clan != null)
                                            {
                                                Client.GameState target;
                                                UInt32 Identifier = BitConverter.ToUInt32(packet, 8);

                                                if (client.Entity.ClanRank == 100)
                                                {
                                                    if (clan.Allies.Count >= 5)
                                                    { client.Send(new Message("The Amount of Allies You can Have is exceeded", System.Drawing.Color.Red, Message.TopLeft)); break; }

                                                    if (ServerBase.Kernel.GamePool.TryGetValue(Identifier, out target))
                                                    {
                                                        Game.Clans tclan = target.Entity.Myclan;
                                                        if (tclan != null)
                                                        {
                                                            if (target.Entity.ClanRank == 100)
                                                            {
                                                                if (tclan.Allies.Count >= 5)
                                                                { client.Send(new Message("The Amount of Allies the Target Clan can Have is exceeded", System.Drawing.Color.Red, Message.TopLeft)); break; }

                                                                if (!clan.Allies.ContainsKey(tclan.ClanId))
                                                                {
                                                                    if (!clan.Enemies.ContainsKey(tclan.ClanId))
                                                                    {
                                                                        String clanName = client.Entity.ClanName;

                                                                        Clan2 clanp = new Clan2();

                                                                        clanp.Deserialize(packet);

                                                                        clanp.Offset16 = 2;
                                                                        clanp.Identifier = client.Entity.UID;

                                                                        Writer.WriteByte((Byte)clanName.Length, 17, clanp.ToArray());
                                                                        Writer.WriteString(clanName, 18, clanp.ToArray());

                                                                        tclan.AllyRequest = clan.ClanId;

                                                                        target.Send(clanp);
                                                                    }
                                                                    else client.Send(new Message("The clan is Your Enemy.", System.Drawing.Color.Red, Message.TopLeft));
                                                                }
                                                            }
                                                            else client.Send(new Message("This target is not the clan leader.", System.Drawing.Color.Red, Message.TopLeft));
                                                        }
                                                    }
                                                    else client.Send(new Message("Can not find target.", System.Drawing.Color.Red, Message.TopLeft));
                                                }
                                                else client.Send(new Message("You are not the clan leader.", System.Drawing.Color.Red, Message.TopLeft));
                                            }
                                            break;
                                        }
                                    case (byte)Game.Clan_Typ.AcceptAlliance:
                                        {
                                            Game.Clans clan = client.Entity.Myclan;
                                            if (clan != null)
                                            {
                                                if (client.Entity.ClanRank == 100)
                                                {
                                                    Game.Clans tclan;
                                                    if (ServerBase.Kernel.ServerClans.TryGetValue(clan.AllyRequest, out tclan))
                                                    {
                                                        if (tclan != null)
                                                        {
                                                            if (!tclan.Enemies.ContainsKey(clan.ClanId))
                                                            {
                                                                if (!clan.Enemies.ContainsKey(tclan.ClanId))
                                                                {
                                                                    if (!clan.Allies.ContainsKey(tclan.ClanId))
                                                                        clan.Allies.Add(tclan.ClanId, tclan);

                                                                    tclan.Allies.Add(clan.ClanId, clan);

                                                                    clan.SendMessage(new ClanRelations(clan, ClanRelations.RelationTypes.Allies));
                                                                    tclan.SendMessage(new ClanRelations(tclan, ClanRelations.RelationTypes.Allies));

                                                                    clan.SendMessage(new Message(String.Format("Our Clan has Allianced with {0}", tclan.ClanName), System.Drawing.Color.Red, Message.Clan));
                                                                    tclan.SendMessage(new Message(String.Format("Our Clan has Allianced with {0}", clan.ClanName), System.Drawing.Color.Red, Message.Clan));

                                                                    clan.AddRelation(tclan.ClanId, ClanRelations.RelationTypes.Allies);
                                                                    tclan.AddRelation(clan.ClanId, ClanRelations.RelationTypes.Allies);

                                                                    clan.AllyRequest = tclan.AllyRequest = 0;
                                                                }
                                                                else client.Send(new Message("This Clan is Your Enemy.", System.Drawing.Color.Red, Message.TopLeft));
                                                            }
                                                            client.Send(new Message("This Clan Has Enemied You!.", System.Drawing.Color.Red, Message.TopLeft));
                                                        }
                                                    }
                                                    else client.Send(new Message("Can not find target", System.Drawing.Color.Red, Message.TopLeft));
                                                }
                                                else client.Send(new Message("You are not the clan leader.", System.Drawing.Color.Red, Message.TopLeft));
                                            }
                                            break;
                                        }
                                    case (byte)Game.Clan_Typ.DeleteEnemy:
                                        {
                                            Game.Clans clan = client.Entity.Myclan;
                                            if (clan != null)
                                            {
                                                if (client.Entity.ClanRank == 100)
                                                {
                                                    Clan2 clanp = new Clan2();
                                                    clanp.Deserialize(packet);

                                                    String EnemyTarget = clanp.Offset18String;
                                                    UInt32 ClanId = clanp.GetClanId(EnemyTarget);

                                                    Game.Clans tclan;
                                                    if (ServerBase.Kernel.ServerClans.TryGetValue(ClanId, out tclan))
                                                    {
                                                        clan.Enemies.Remove(ClanId);

                                                        clan.DeleteRelation(ClanId, ClanRelations.RelationTypes.Enemies);

                                                        clan.SendMessage(new ClanRelations(clan, ClanRelations.RelationTypes.Enemies));

                                                        clan.SendMessage(new Message(String.Format("We are no longer Enemies With {0}", clan.ClanId), System.Drawing.Color.Red, Message.Clan));

                                                        client.Send(clanp);
                                                    }
                                                }
                                                else client.Send(new Message("You are not authorized to continue with this action", System.Drawing.Color.Red, Message.TopLeft));
                                            }
                                            break;
                                        }
                                    case (byte)Game.Clan_Typ.DeleteAlly:
                                        {
                                            Game.Clans clan = client.Entity.Myclan;
                                            if (clan != null)
                                            {
                                                if (client.Entity.ClanRank == 100)
                                                {
                                                    Clan2 clanp = new Clan2();
                                                    clanp.Deserialize(packet);

                                                    String AlliedTarget = clanp.Offset18String;
                                                    UInt32 ClanId = clanp.GetClanId(AlliedTarget);

                                                    Game.Clans tclan;
                                                    if (clan.Allies.TryGetValue(ClanId, out tclan))
                                                    {
                                                        clan.Allies.Remove(ClanId);
                                                        tclan.Allies.Remove(clan.ClanId);

                                                        clan.DeleteRelation(ClanId, ClanRelations.RelationTypes.Allies);
                                                        tclan.DeleteRelation(clan.ClanId, ClanRelations.RelationTypes.Allies);

                                                        clan.SendMessage(new ClanRelations(clan, ClanRelations.RelationTypes.Allies));
                                                        tclan.SendMessage(new ClanRelations(tclan, ClanRelations.RelationTypes.Allies));

                                                        clan.SendMessage(new Message(String.Format("We are no longer allied with {0}", tclan.ClanName), System.Drawing.Color.Red, Message.Clan));
                                                        tclan.SendMessage(new Message(String.Format("We are no longer allied with {0}", clan.ClanName), System.Drawing.Color.Red, Message.Clan));

                                                        client.Send(clanp);
                                                    }
                                                }
                                                else client.Send(new Message("You are not authorized to continue with this action", System.Drawing.Color.Red, Message.TopLeft));
                                            }
                                            break;
                                        }
                                    case (byte)Game.Clan_Typ.AddEnemy:
                                        {
                                            Game.Clans clan = client.Entity.Myclan;
                                            if (clan != null)
                                            {
                                                if (client.Entity.ClanRank == 100)
                                                {
                                                    String Enemy = System.Text.Encoding.UTF7.GetString(packet, 18, packet[17]).Trim(new Char[] { '\0' });
                                                    UInt32 ClanId = 0;
                                                    var AllCland = ServerBase.Kernel.ServerClans.Values.ToArray();
                                                    foreach (Game.Clans c_clan in AllCland)
                                                    {
                                                        if (Enemy == c_clan.ClanName)
                                                        {
                                                            ClanId = c_clan.ClanId;
                                                            break;
                                                        }
                                                    }
                                                    if (ClanId == 0) break;
                                                    if (!clan.Enemies.ContainsKey(ClanId))
                                                    {
                                                        if (!clan.Allies.ContainsKey(ClanId))
                                                        {
                                                            if (clan.Enemies.Count >= 5)
                                                            { client.Send(new Message("The Ammount of Enemies You can Have is exceeded", System.Drawing.Color.Red, Message.TopLeft)); break; }

                                                            Game.Clans tclan;
                                                            if (ServerBase.Kernel.ServerClans.TryGetValue(ClanId, out tclan))
                                                            {
                                                                if (!clan.Enemies.ContainsKey(tclan.ClanId))
                                                                    clan.Enemies.Add(tclan.ClanId, tclan);

                                                                clan.AddRelation(ClanId, ClanRelations.RelationTypes.Enemies);

                                                                clan.SendMessage(new ClanRelations(clan, ClanRelations.RelationTypes.Enemies));

                                                                clan.SendMessage(new Message(String.Format("We Have Enemied the clan {0}", tclan.ClanName), System.Drawing.Color.Red, Message.Clan));
                                                                tclan.SendMessage(new Message(String.Format("The Clan {0} Has Made us their Enemy!", clan.ClanName), System.Drawing.Color.Red, Message.Clan));
                                                            }
                                                        }
                                                        else client.Send(new Message("This clan is one of your alliance, What has gone wrong?", System.Drawing.Color.Red, Message.TopLeft));
                                                    }
                                                    else client.Send(new Message("This clan is Already One of Your Enemies", System.Drawing.Color.Red, Message.TopLeft));
                                                }
                                            }
                                            break;
                                        }
                                    default:
                                        Console.WriteLine("Clan Type " + packet[4]);
                                        break;

                                }
                                break;
                            }
                        #endregion
                        #region SubClass (2320)
                        case 2320:
                            {
                                byte[] Packet = null;
                                switch (packet[4])
                                {
                                    //9 = learn 10= upgrade pro
                                    #region [Restore/Switch]
                                    case 0:
                                        byte To = packet[6];
                                        Packet = new byte[0];
                                        client.Send(packet);
                                        if (To > 0)//Switch
                                        {
                                            /*switch ((Game.ClassID)To)
                                            {
                                                case Game.ClassID.Wrangler:
                                                    {
                                                        switch (client.Entity.SubClasses.Classes[To].Level)
                                                        {
                                                            case 9:
                                                                {
                                                                    //client.Entity.Hitpoints += 1200;
                                                                    //client.Entity.MaxHitpoints += 1200;
                                                                    break;
                                                                }
                                                        }
                                                        break;
                                                    }
                                            }*/
                                            Packet = new byte[0];
                                            Packet = new SubClassShowFull(true) { ID = 1, Class = To, Level = client.Entity.SubClasses.Classes[To].Phase }.ToArray();//client.Entity.SubClasses.Classes[To].Phase
                                            client.Send(Packet);
                                            //Packet = new SubClass(client.Entity).ToArray();
                                            //client.Send(Packet);
                                            client.Entity.SubClass = To;
                                            /// client.Entity.SubClassLevel = client.Entity.SubClasses.Classes[To].Level;
                                            client.Entity.SubClasses.Active = To;
                                            client.Entity.SubClassesActive = To;
                                            // Console.WriteLine("s " + To + "");
                                        }
                                        else//Restore
                                        {
                                            client.Entity.SubClass = 0;
                                            //client.Entity.SubClassLevel = 0;
                                            client.Entity.SubClasses.Active = 0;
                                            client.Entity.SubClassesActive = 0;
                                            Packet = new SubClassShowFull(true) { ID = 1 }.ToArray();
                                            client.Send(Packet);
                                        }
                                        client.SendScreen(client.Entity.SpawnPacket, false);
                                        break;
                                    #endregion
                                    #region [Upgrade]
                                    case 2:
                                        {
                                            byte Class = packet[6];
                                            ushort Required = 0;
                                            Statement.SubClass Sc = client.Entity.SubClasses.Classes[Class];
                                            #region [Set Required]
                                            switch ((Statement.ClassID)Sc.ID)
                                            {
                                                case Statement.ClassID.MartialArtist:
                                                    switch (Sc.Level)
                                                    {
                                                        case 1: Required = 300; break;
                                                        case 2: Required = 900; break;
                                                        case 3: Required = 1800; break;
                                                        case 4: Required = 2700; break;
                                                        case 5: Required = 3600; break;
                                                        case 6: Required = 5100; break;
                                                        case 7: Required = 6900; break;
                                                        case 8: Required = 8700; break;
                                                        case 9: Required = ushort.MaxValue; break;
                                                    }
                                                    break;
                                                case Statement.ClassID.Warlock:
                                                    switch (Sc.Level)
                                                    {
                                                        case 1: Required = 300; break;
                                                        case 2: Required = 900; break;
                                                        case 3: Required = 1800; break;
                                                        case 4: Required = 2700; break;
                                                        case 5: Required = 3600; break;
                                                        case 6: Required = 5100; break;
                                                        case 7: Required = 6900; break;
                                                        case 8: Required = 8700; break;
                                                        case 9: Required = ushort.MaxValue; break;
                                                    }
                                                    break;
                                                case Statement.ClassID.ChiMaster:
                                                    switch (Sc.Level)
                                                    {
                                                        case 1: Required = 600; break;
                                                        case 2: Required = 1800; break;
                                                        case 3: Required = 3600; break;
                                                        case 4: Required = 5400; break;
                                                        case 5: Required = 7200; break;
                                                        case 6: Required = 10200; break;
                                                        case 7: Required = 13800; break;
                                                        case 8: Required = 17400; break;
                                                        case 9: Required = ushort.MaxValue; break;
                                                    }
                                                    break;
                                                case Statement.ClassID.Sage:
                                                    switch (Sc.Level)
                                                    {
                                                        case 1: Required = 400; break;
                                                        case 2: Required = 1200; break;
                                                        case 3: Required = 2400; break;
                                                        case 4: Required = 3600; break;
                                                        case 5: Required = 4800; break;
                                                        case 6: Required = 6800; break;
                                                        case 7: Required = 9200; break;
                                                        case 8: Required = 11600; break;
                                                        case 9: Required = ushort.MaxValue; break;
                                                    }
                                                    break;
                                                case Statement.ClassID.Apothecary:
                                                    switch (Sc.Level)
                                                    {
                                                        case 1: Required = 100; break;
                                                        case 2: Required = 200; break;
                                                        case 3: Required = 300; break;
                                                        case 4: Required = 400; break;
                                                        case 5: Required = 500; break;
                                                        case 6: Required = 1000; break;
                                                        case 7: Required = 4000; break;
                                                        case 8: Required = 9000; break;
                                                        case 9: Required = ushort.MaxValue; break;
                                                    }
                                                    break;
                                                case Statement.ClassID.Wrangler:
                                                case Statement.ClassID.Performer:
                                                    switch (Sc.Level)
                                                    {
                                                        case 1: Required = 400; break;
                                                        case 2: Required = 1200; break;
                                                        case 3: Required = 2400; break;
                                                        case 4: Required = 3600; break;
                                                        case 5: Required = 4800; break;
                                                        case 6: Required = 6800; break;
                                                        case 7: Required = 9200; break;
                                                        case 8: Required = 11600; break;
                                                        case 9: Required = ushort.MaxValue; break;
                                                    }
                                                    break;
                                            }
                                            #endregion
                                            if (client.Entity.SubClasses.StudyPoints >= Required)
                                            {
                                                client.Entity.SubClasses.StudyPoints -= Required;
                                                client.Entity.SubClasses.Classes[Class].Level++;
                                                Packet = new byte[0];
                                                Packet = new SubClassShowFull(true) { ID = 1, Class = Class, Level = client.Entity.SubClasses.Classes[Class].Level }.ToArray();
                                                client.Send(Packet);
                                                Packet = new SubClass(client.Entity).ToArray();
                                                client.Send(Packet);
                                                Database.SubClassTable.Update(client.Entity, client.Entity.SubClasses.Classes[Class]);
                                                //Database.SubClassTable.Update(client);
                                            }
                                            break;
                                        }
                                    #endregion
                                    #region [Info]
                                    case 6:
                                        Game.Entity Owner = client.Entity;
                                        if (Owner.SubClasses.Classes.Count > 0)
                                        {
                                            Statement.SubClass[] Classes = new Statement.SubClass[Owner.SubClasses.Classes.Count];
                                            Owner.SubClasses.Classes.Values.CopyTo(Classes, 0);
                                            foreach (Statement.SubClass Class in Classes)
                                            {
                                                if (Class.ID == 9)
                                                {
                                                    for (byte i = 0; i < Class.Phase; i++)
                                                    {
                                                        Packet = new byte[0];
                                                        Packet = new SubClassShowFull(true) { ID = 4, Class = Class.ID, Level = Class.Level }.ToArray();
                                                        client.Send(Packet);
                                                    }
                                                    continue;
                                                }
                                                Packet = new byte[0];
                                                Packet = new SubClassShowFull(true) { ID = 4, Class = Class.ID, Level = Class.Level }.ToArray();
                                                client.Send(Packet);
                                            }
                                        }
                                        Packet = new SubClass(client.Entity).ToArray();
                                        client.Send(Packet);
                                        break;
                                    #endregion
                                    #region [Learn]
                                    case 9://class type packet6
                                        byte Class1 = packet[6];
                                        if (PacketHandler.PassLearn((byte)packet[6], client.Entity))
                                        {
                                            if (!client.Entity.SubClasses.Classes.ContainsKey((byte)packet[6]))
                                            {
                                                {
                                                    client.Entity.SubClasses.Classes.Add((byte)packet[6], new PhoenixProject.Statement.SubClass() { ID = (byte)packet[6], Level = 1, Phase = 1 });
                                                    PhoenixProject.Database.SubClassTable.Insert(client.Entity, (byte)packet[6]);
                                                    Packet = new byte[0];
                                                    Packet = new SubClassShowFull(true) { ID = 1, Class = Class1, Level = client.Entity.SubClasses.Classes[Class1].Level }.ToArray();
                                                    client.Send(Packet);
                                                    Packet = new SubClass(client.Entity).ToArray();
                                                    client.Send(Packet);
                                                }
                                            }
                                        }

                                        break;
                                    #endregion
                                    #region [UpgradePro]
                                    case 10:
                                        byte Class2 = packet[6];

                                        if (client.Entity.SubClasses.Classes[(byte)Class2].Phase < client.Entity.SubClasses.Classes[(byte)Class2].Level)
                                        {
                                            client.Entity.SubClasses.Classes[(byte)Class2].Phase++;
                                            Database.SubClassTable.Update(client.Entity, client.Entity.SubClasses.Classes[(byte)Class2]);
                                            Packet = new byte[0];
                                            Packet = new SubClassShowFull(true) { ID = 1, Class = Class2, Level = client.Entity.SubClasses.Classes[Class2].Level }.ToArray();
                                            client.Send(Packet);
                                            Packet = new SubClass(client.Entity).ToArray();
                                            client.Send(Packet);
                                        }

                                        break;
                                    #endregion
                                    default:
                                        Console.WriteLine("Unknown 2320 packet type " + packet[4]);
                                        break;
                                }
                                break;
                            }
                        #endregion
                        #region ItemAdding Stabilization
                        case 1038:
                            {
                                ItemAddingStabilization stabilization = new ItemAddingStabilization(false);
                                stabilization.Deserialize(packet);
                                StabilazeArtifact(stabilization, client);
                                break;
                            }
                        #endregion
                        #region Data (10010)
                        case 10010:
                            {

                                if (client.Action != 2)
                                    return;
                                Data gData = new Data(false);
                                gData.Deserialize(packet);
                                if (client.Account.State == PhoenixProject.Database.AccountTable.AccountState.Coder)
                                {
                                    client.Send(new Message("Data ID: " + gData.ID, System.Drawing.Color.CadetBlue, Message.Talk));
                                }
                                switch (gData.ID)
                                {
                                    /*case Data.AllowAnimation:
                                        {
                                            LoginMessages(client);
                                            client.Send(new FlowerPacket(client.Entity.Flowers));
                                            //Database.SubClassTable.Load(client.Entity);
                                            ClientEquip equips = new ClientEquip();
                                            equips.DoEquips(client);
                                            client.Send(equips);
                                            client.Send(packet);
                                        }
                                        break;*/
                                    #region Appearance
                                    case 0xb2:
                                        {
                                            byte appearance = (byte)gData.dwParam;
                                            Data app = new Data(true)
                                            {
                                                ID = 0xb2,
                                                UID = client.Entity.UID,
                                                dwParam = appearance,
                                                wParam1 = client.Entity.X,
                                                wParam2 = client.Entity.Y
                                            };
                                            client.Send(gData);
                                            client.Send(app);
                                            client.SendScreen(gData, true);
                                            client.SendScreen(app, true);
                                            return;
                                        }
                                    #endregion
                                    case 132:
                                        {
                                            // Console.WriteLine(" this ");
                                            client.Disconnect();
                                            break;
                                        }
                                    /* case Data.KimoGearDis:
                                         {
                                             Console.WriteLine("data " + gData.dwParam + "");
                                             break;
                                         }*/
                                    case Data.UpdateProf:
                                        if (client != null)
                                        {
                                            ushort UplevelProficiency;
                                            UplevelProficiency = (ushort)gData.dwParam;

                                            var prof = client.Proficiencies[UplevelProficiency];

                                            if ((prof.Level >= 1) && (prof.Level <= 19))
                                            {
                                                if (prof.Level == 19 && client.Entity.ConquerPoints >= 1420)
                                                {
                                                    client.Entity.ConquerPoints -= 1420;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 18 && client.Entity.ConquerPoints >= 1154)
                                                {
                                                    client.Entity.ConquerPoints -= 1154;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 17 && client.Entity.ConquerPoints >= 799)
                                                {
                                                    client.Entity.ConquerPoints -= 799;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 16 && client.Entity.ConquerPoints >= 548)
                                                {
                                                    client.Entity.ConquerPoints -= 548;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 15 && client.Entity.ConquerPoints >= 375)
                                                {
                                                    client.Entity.ConquerPoints -= 375;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level >= 11 && prof.Level <= 14 && client.Entity.ConquerPoints >= 324)
                                                {
                                                    client.Entity.ConquerPoints -= 324;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 10 && client.Entity.ConquerPoints >= 270)
                                                {
                                                    client.Entity.ConquerPoints -= 270;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 9 && client.Entity.ConquerPoints >= 162)
                                                {
                                                    client.Entity.ConquerPoints -= 162;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 8 && client.Entity.ConquerPoints >= 135)
                                                {
                                                    client.Entity.ConquerPoints -= 135;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 7 && client.Entity.ConquerPoints >= 81)
                                                {
                                                    client.Entity.ConquerPoints -= 81;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 6 && client.Entity.ConquerPoints >= 54)
                                                {
                                                    client.Entity.ConquerPoints -= 54;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level >= 2 && prof.Level <= 5 && client.Entity.ConquerPoints >= 27)
                                                {
                                                    client.Entity.ConquerPoints -= 27;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 1)
                                                {
                                                    client.Entity.ConquerPoints -= 22;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            //break;
                                        }
                                        break;
                                    case Data.UpdateSpell:
                                        if (client != null)
                                        {
                                            ushort UplevelProficiency;
                                            UplevelProficiency = (ushort)gData.dwParam;
                                            if (client.Spells.ContainsKey(UplevelProficiency))
                                            {
                                                var prof = client.Spells[UplevelProficiency];
                                                if (prof != null)
                                                {
                                                    int num2 = (int)Database.SpellTable.SpellInformations[UplevelProficiency][prof.Level].CPUpgradeRatio;
                                                    int num3 = Math.Max((int)prof.Experience, 1);
                                                    int num4 = 100 - ((int)(((ulong)num3) / ((ulong)Math.Max((uint)(Database.SpellTable.SpellInformations[UplevelProficiency][prof.Level].NeedExperience / 100), (uint)1))));
                                                    uint num = (uint)(((double)((num2 * num4) / 100)) / 22.2);
                                                    if (client.Entity.ConquerPoints >= num)
                                                    {

                                                        client.Entity.ConquerPoints -= num;
                                                        // Console.WriteLine(" " + num + "");
                                                        prof.Level++;
                                                        prof.Experience = 0;
                                                        prof.Send(client);
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Sorry you dont have " + num + " cps i cant help you!");
                                                        npc.OptionID = 255;
                                                        client.Send(npc.ToArray());
                                                        break;
                                                        //sorry you dont have 100 cps
                                                    }
                                                }
                                            }
                                            break;
                                        }
                                        else
                                        {
                                            //break;
                                        }
                                        break;
                                    case Data.SwingPickaxe:
                                        client.Mining = true;
                                        break;
                                    case Data.Revive:
                                        Revive(gData, client);
                                        break;
                                    case Data.UsePortal:
                                        UsePortal(gData, client);
                                        break;
                                    case Data.ChangePKMode:
                                        ChangePKMode(gData, client);
                                        break;
                                    case Data.ChangeAction:
                                        ChangeAction(gData, client);
                                        break;
                                    case Data.ChangeDirection:
                                        ChangeDirection(gData, client);
                                        break;
                                    case Data.Hotkeys:
                                        client.Send(packet);
                                        break;
                                    case Data.ConfirmSpells:
                                        if (client.Spells != null)
                                            foreach (Interfaces.ISkill spell in client.Spells.Values)
                                                if (spell.ID != 3060)
                                                    spell.Send(client);
                                        client.Send(packet);
                                        break;
                                    case Data.ConfirmProficiencies:
                                        if (client.Proficiencies != null)
                                            foreach (Interfaces.IProf proficiency in client.Proficiencies.Values)
                                                proficiency.Send(client);
                                        client.Send(packet);
                                        break;
                                    case Data.ConfirmGuild:
                                        client.Send(packet);
                                        break;
                                    case Data.ConfirmFriends:
                                        #region Friends/Enemy/TradePartners/Apprentices
                                        Message msg2 = new Message("Your friend, " + client.Entity.Name + ", has logged on.", System.Drawing.Color.Red, Message.TopLeft);

                                        foreach (Game.ConquerStructures.Society.Friend friend in client.Friends.Values)
                                        {
                                            if (friend.IsOnline)
                                            {
                                                var pckt = new KnownPersons(true)
                                                {
                                                    UID = client.Entity.UID,
                                                    Type = KnownPersons.RemovePerson,
                                                    Name = client.Entity.Name,
                                                    Online = true
                                                };
                                                friend.Client.Send(pckt);
                                                pckt.Type = KnownPersons.AddFriend;
                                                friend.Client.Send(pckt);
                                                friend.Client.Send(msg2);
                                            }
                                            client.Send(new KnownPersons(true)
                                            {
                                                UID = friend.ID,
                                                Type = KnownPersons.AddFriend,
                                                Name = friend.Name,
                                                Online = friend.IsOnline
                                            });
                                            if (friend.Message != "")
                                            {
                                                client.Send(new Message(friend.Message, client.Entity.Name, friend.Name, System.Drawing.Color.Red, Message.Whisper));
                                                Database.KnownPersons.UpdateMessageOnFriend(friend.ID, client.Entity.UID, "");
                                            }
                                        }

                                        foreach (Game.ConquerStructures.Society.Enemy enemy in client.Enemy.Values)
                                        {
                                            client.Send(new KnownPersons(true)
                                            {
                                                UID = enemy.ID,
                                                Type = KnownPersons.AddEnemy,
                                                Name = enemy.Name,
                                                Online = enemy.IsOnline
                                            });
                                        }
                                        Message msg3 = new Message("Your partner, " + client.Entity.Name + ", has logged in.", System.Drawing.Color.Red, Message.TopLeft);

                                        foreach (Game.ConquerStructures.Society.TradePartner partner in client.Partners.Values)
                                        {
                                            if (partner.IsOnline)
                                            {
                                                var packet3 = new TradePartner(true)
                                                {
                                                    UID = client.Entity.UID,
                                                    Type = TradePartner.BreakPartnership,
                                                    Name = client.Entity.Name,
                                                    HoursLeft = (int)(new TimeSpan(partner.ProbationStartedOn.AddDays(3).Ticks).TotalHours - new TimeSpan(DateTime.Now.Ticks).TotalHours),
                                                    Online = true
                                                };
                                                partner.Client.Send(packet3);
                                                packet3.Type = TradePartner.AddPartner;
                                                partner.Client.Send(packet3);
                                                partner.Client.Send(msg3);
                                            }
                                            var packet4 = new TradePartner(true)
                                            {
                                                UID = partner.ID,
                                                Type = TradePartner.AddPartner,
                                                Name = partner.Name,
                                                HoursLeft = (int)(new TimeSpan(partner.ProbationStartedOn.AddDays(3).Ticks).TotalHours - new TimeSpan(DateTime.Now.Ticks).TotalHours),
                                                Online = partner.IsOnline
                                            };
                                            client.Send(packet4);
                                        }

                                        foreach (Game.ConquerStructures.Society.Apprentice appr in client.Apprentices.Values)
                                        {
                                            if (appr.IsOnline)
                                            {
                                                ApprenticeInformation AppInfo = new ApprenticeInformation();
                                                AppInfo.Apprentice_ID = appr.ID;
                                                AppInfo.Apprentice_Level = appr.Client.Entity.Level;
                                                AppInfo.Apprentice_Class = appr.Client.Entity.Class;
                                                AppInfo.Apprentice_PkPoints = appr.Client.Entity.PKPoints;
                                                AppInfo.Apprentice_Experience = appr.Actual_Experience;
                                                AppInfo.Apprentice_Composing = appr.Actual_Plus;
                                                AppInfo.Apprentice_Blessing = appr.Actual_HeavenBlessing;
                                                AppInfo.Apprentice_Name = appr.Name;
                                                AppInfo.Apprentice_Online = true;
                                                AppInfo.Apprentice_Spouse_Name = appr.Client.Entity.Spouse;
                                                AppInfo.Enrole_date = appr.EnroleDate;
                                                AppInfo.Mentor_ID = client.Entity.UID;
                                                AppInfo.Mentor_Mesh = client.Entity.Mesh;
                                                AppInfo.Mentor_Name = client.Entity.Name;
                                                AppInfo.Type = 2;
                                                client.Send(AppInfo);

                                                MentorInformation Information = new MentorInformation(true);
                                                Information.Mentor_Type = 1;
                                                Information.Mentor_ID = client.Entity.UID;
                                                Information.Apprentice_ID = appr.ID;
                                                Information.Enrole_Date = appr.EnroleDate;
                                                Information.Mentor_Level = client.Entity.Level;
                                                Information.Mentor_Class = client.Entity.Class;
                                                Information.Mentor_PkPoints = client.Entity.PKPoints;
                                                Information.Mentor_Mesh = client.Entity.Mesh;
                                                Information.Mentor_Online = true;
                                                Information.Shared_Battle_Power = (uint)(((client.Entity.BattlePower - client.Entity.ExtraBattlePower) - (appr.Client.Entity.BattlePower - appr.Client.Entity.ExtraBattlePower)) / 3.3F);
                                                Information.String_Count = 3;
                                                Information.Mentor_Name = client.Entity.Name;
                                                Information.Apprentice_Name = appr.Name;
                                                Information.Mentor_Spouse_Name = client.Entity.Spouse;
                                                appr.Client.ReviewMentor();
                                                appr.Client.Send(Information);
                                            }
                                            else
                                            {
                                                ApprenticeInformation AppInfo = new ApprenticeInformation();
                                                AppInfo.Apprentice_ID = appr.ID;
                                                AppInfo.Apprentice_Name = appr.Name;
                                                AppInfo.Apprentice_Online = false;
                                                AppInfo.Enrole_date = appr.EnroleDate;
                                                AppInfo.Mentor_ID = client.Entity.UID;
                                                AppInfo.Mentor_Mesh = client.Entity.Mesh;
                                                AppInfo.Mentor_Name = client.Entity.Name;
                                                AppInfo.Type = 2;
                                                client.Send(AppInfo);
                                            }
                                        }
                                        #endregion
                                        client.Send(packet);
                                        break;
                                    case Data.EndTeleport:
                                        break;
                                    case Data.GetSurroundings:
                                        if (client.Booth != null)
                                        {
                                            client.Entity.TransformationID = 0;
                                            client.Booth.Remove();
                                            client.Booth = null;
                                        }
                                        GetSurroundings(client);
                                        client.Send(new MapStatus() { BaseID = (ushort)client.Map.BaseID, ID = (uint)client.Map.ID, Status = Database.MapsTable.MapInformations[client.Map.ID].Status });
                                        Game.Weather.CurrentWeatherBase.Send(client);
                                        client.Send(gData);
                                        break;
                                    case Data.SetLocation:
                                        SetLocation(gData, client);
                                        client.Entity.MapRegion = Region.Region.FindRegion((uint)client.Map.BaseID, client.Entity.X, client.Entity.Y);
                                        break;
                                    case Data.Jump:
                                        {
                                            PlayerJump(gData, client);

                                            break;
                                        }
                                    case Data.BlueCountdown:
                                        {
                                            // PlayerJump(gData, client);

                                            break;
                                        }
                                    case Data.UnknownEntity:
                                        {
                                            #region UnknownEntity
                                            Client.GameState pClient = null;
                                            if (ServerBase.Kernel.GamePool.TryGetValue(gData.dwParam, out pClient))
                                            {
                                                if (ServerBase.Kernel.GetDistance(pClient.Entity.X, pClient.Entity.Y, client.Entity.X, client.Entity.Y) <= ServerBase.Constants.pScreenDistance && client.Map.ID == pClient.Map.ID)
                                                {
                                                    if (pClient.Guild != null)
                                                        pClient.Guild.SendName(client);
                                                    if (client.Guild != null)
                                                        client.Guild.SendName(pClient);
                                                    if (pClient.Entity.UID != client.Entity.UID)
                                                    {
                                                        if (pClient.Map.ID == client.Map.ID)
                                                        {
                                                            if (pClient.Map.BaseID == 700)
                                                            {
                                                                if (client.QualifierGroup != null)
                                                                {
                                                                    if (pClient.QualifierGroup != null)
                                                                    {
                                                                        client.Entity.SendSpawn(pClient, false);
                                                                        pClient.Entity.SendSpawn(client, false);
                                                                    }
                                                                    else
                                                                    {
                                                                        client.Entity.SendSpawn(pClient, false);
                                                                        client.Screen.Add(pClient.Entity);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (pClient.QualifierGroup != null)
                                                                    {
                                                                        pClient.Entity.SendSpawn(client, false);
                                                                        pClient.Screen.Add(client.Entity);
                                                                    }
                                                                    else
                                                                    {
                                                                        client.Entity.SendSpawn(pClient, false);
                                                                        pClient.Entity.SendSpawn(client, false);
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                client.Entity.SendSpawn(pClient, false);
                                                                pClient.Entity.SendSpawn(client, false);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                Game.Entity monster = null;
                                                for (int x = 0; x < client.Map.Entities.Count; x++)
                                                {
                                                    if (x >= client.Map.Entities.Count)
                                                        break;
                                                    if (client.Map.Entities[x] != null)
                                                    {
                                                        if (client.Map.Entities[x].UID == gData.dwParam)
                                                        {
                                                            monster = client.Map.Entities[x];
                                                            break;
                                                        }
                                                    }
                                                }
                                                if (monster != null)
                                                {
                                                    if (ServerBase.Kernel.GetDistance(monster.X, monster.Y, client.Entity.X, client.Entity.Y) <= ServerBase.Constants.pScreenDistance)
                                                    {
                                                        monster.SendSpawn(client, false);
                                                    }
                                                }
                                                for (int x = 0; x < client.Map.Companions.Count; x++)
                                                {
                                                    if (x >= client.Map.Companions.Count)
                                                        break;
                                                    if (client.Map.Companions[x] != null)
                                                    {
                                                        if (client.Map.Companions[x].UID == gData.dwParam)
                                                        {
                                                            monster = client.Map.Companions[x];
                                                            break;
                                                        }
                                                    }
                                                }
                                                if (monster != null)
                                                {
                                                    if (ServerBase.Kernel.GetDistance(monster.X, monster.Y, client.Entity.X, client.Entity.Y) <= ServerBase.Constants.pScreenDistance)
                                                    {
                                                        monster.SendSpawn(client, false);
                                                    }
                                                }
                                            }
                                            #endregion
                                            break;
                                        }
                                    case Data.CompleteLogin:
                                        {
                                            client.MonsterHunterStats = new MonsterHunterStats(client);
                                            //client.MonsterHunterStats.Kills = (ushort)client.Entity.Status4;
                                            // client.MonsterHunterStats.Load(client);
                                            LoginMessages(client);
                                            Network.GamePackets.Weather weather = new Network.GamePackets.Weather(true);
                                            weather.WeatherType = (uint)Program.WeatherType;
                                            weather.Intensity = 100;
                                            weather.Appearence = 2;
                                            weather.Direction = 4;

                                            client.Send(new FlowerPacket(client.Entity.Flowers));
                                            client.Send(new FlowerPacket3(client));
                                            /*ClientEquip equips = new ClientEquip();
                                            equips.DoEquips(client);
                                            client.Send(equips);*/
                                            client.Send(packet);
                                            client.Send(weather);
                                            break;
                                        }
                                    case Data.ChangeFace:
                                        ChangeFace(gData, client);
                                        break;
                                    case Data.ObserveEquipment:
                                        ObserveEquipment2(gData, client);
                                        break;
                                    case Data.ObserveEquipment2:
                                        ObserveEquipment(gData, client);
                                        break;
                                    case 408:
                                        {
                                            /* if (!client.ChangeGear)
                                             {
                                                 Game.KimoChangeGear.Load(client);
                                             }
                                             else
                                             {

                                                 Game.KimoChangeGear.Load2(client);
                                             }
                                             client.ChangeGear = true;*/
                                            break;
                                        }

                                    case Data.ObserveKnownPerson:
                                        ObserveEquipment(gData, client);
                                        break;
                                    case Data.ViewEnemyInfo:
                                        {
                                            if (client.Enemy.ContainsKey(gData.dwParam))
                                            {
                                                if (client.Enemy[gData.dwParam].IsOnline)
                                                {
                                                    KnownPersonInfo info = new KnownPersonInfo(true);
                                                    info.Fill(client.Enemy[gData.dwParam], true, false);
                                                    if (client.Enemy[gData.dwParam].Client.Guild != null)
                                                        client.Enemy[gData.dwParam].Client.Guild.SendName(client);
                                                    client.Send(info);
                                                }
                                            }
                                            break;
                                        }
                                    case Data.ViewFriendInfo:
                                        {
                                            if (client.Friends.ContainsKey(gData.dwParam))
                                            {
                                                if (client.Friends[gData.dwParam].IsOnline)
                                                {
                                                    KnownPersonInfo info = new KnownPersonInfo(true);
                                                    info.Fill(client.Friends[gData.dwParam], false, false);
                                                    if (client.Friends[gData.dwParam].Client.Guild != null)
                                                        client.Friends[gData.dwParam].Client.Guild.SendName(client);
                                                    client.Send(info);
                                                }
                                            }
                                            break;
                                        }
                                    case Data.ViewPartnerInfo:
                                        {
                                            if (client.Partners.ContainsKey(gData.dwParam))
                                            {
                                                if (client.Partners[gData.dwParam].IsOnline)
                                                {
                                                    TradePartnerInfo info = new TradePartnerInfo(true);
                                                    info.Fill(client.Partners[gData.dwParam]);
                                                    if (client.Partners[gData.dwParam].Client.Guild != null)
                                                        client.Partners[gData.dwParam].Client.Guild.SendName(client);
                                                    client.Send(info);
                                                }
                                            }
                                            break;
                                        }
                                    case Data.EndFly:
                                        client.Entity.RemoveFlag(Update.Flags.Fly);
                                        break;
                                    case Data.EndTransformation:
                                        client.Entity.Untransform();
                                        break;
                                    case Data.XPListEnd:
                                    case Data.Die:
                                        break;
                                    case Data.Confiscator:
                                        client.Send(packet);
                                        break;
                                    case Data.OwnBooth:
                                        {
                                            client.Booth = new PhoenixProject.Game.ConquerStructures.Booth(client, gData);
                                            client.Send(new Data(true) { ID = Data.ChangeAction, UID = client.Entity.UID, dwParam = 0 });
                                            break;
                                        }

                                    case Data.Away:
                                        {
                                            if (client.Entity.Away == 0)
                                                client.Entity.Away = 1;
                                            else
                                                client.Entity.Away = 0;
                                            client.SendScreenSpawn(client.Entity, false);
                                            break;
                                        }
                                    case Data.DeleteCharacter:
                                        {
                                            if ((client.WarehousePW == null || client.WarehousePW == "" || client.WarehousePW == "0" && gData.dwParam == 0) || (client.WarehousePW == gData.dwParam.ToString()))
                                            {
                                                client.Account.TempID = 400;

                                                client.Disconnect();
                                            }
                                            break;
                                        }

                                    case Data.TeamSearchForMember:
                                        {
                                            if (client.Team != null)
                                            {
                                                Client.GameState Client = null;
                                                if (!client.Team.IsTeammate(gData.UID))
                                                    return;
                                                if (Kernel.GamePool.TryGetValue(gData.UID, out Client))
                                                {
                                                    // Console.WriteLine(" " + gData.dwParam + "");
                                                    gData.wParam1 = Client.Entity.X;
                                                    gData.wParam2 = Client.Entity.Y;
                                                    gData.Send(client);
                                                }
                                            }
                                            break;
                                        }
                                    default:
                                        if (client.Account.State == PhoenixProject.Database.AccountTable.AccountState.ProjectManager || client.Account.State == PhoenixProject.Database.AccountTable.AccountState.Coder)
                                            client.Send(new Message("Unknown generaldata id: " + gData.ID, System.Drawing.Color.CadetBlue, Message.Talk));
                                        break;
                                }
                                break;
                            }
                        #endregion
                        #region TimePacket (1033)
                        case 1033:
                            {
                                ServerTime time = new ServerTime();
                                time.Year = (uint)DateTime.Now.Year;
                                time.Month = (uint)DateTime.Now.Month;
                                time.DayOfYear = (uint)DateTime.Now.DayOfYear;
                                time.DayOfMonth = (uint)DateTime.Now.Day;
                                time.Hour = (uint)DateTime.Now.Hour;
                                time.Minute = (uint)DateTime.Now.Minute;
                                time.Second = (uint)DateTime.Now.Second;
                                client.Send(time);
                                break;
                            }
                        #endregion
                        #region MemoryAgate
                        case 2110:
                            {
                                uint ItemUID = BitConverter.ToUInt32(packet, 8);
                                switch (packet[4])
                                {
                                    case 1:
                                        {
                                            if (client.Map.IsDynamic()) return;
                                            if (ServerBase.Constants.revnomap.Contains(client.Entity.MapID))
                                                return;
                                            Interfaces.IConquerItem Item = null;

                                            if (client.Inventory.TryGetItem(ItemUID, out Item))
                                            {
                                                if (Item.Agate_map.ContainsKey(packet[12]))
                                                {
                                                    Item.Agate_map[(uint)packet[12]] = client.Entity.MapID
                                                       + "~" + client.Entity.X
                                                       + "~" + client.Entity.Y;
                                                    Database.ConquerItemTable.UpdateItemAgate(Item);
                                                    Item.SendAgate(client);
                                                    break;
                                                }
                                                if (packet[12] > Item.Agate_map.Count)
                                                {
                                                    Item.Agate_map.Add((byte)(Item.Agate_map.Count), client.Entity.MapID
                                                       + "~" + client.Entity.X
                                                       + "~" + client.Entity.Y);
                                                    Database.ConquerItemTable.UpdateItemAgate(Item);
                                                    Item.SendAgate(client);
                                                    break;
                                                }
                                                else
                                                {
                                                    if (!Item.Agate_map.ContainsKey(packet[12]))
                                                    {

                                                        Item.Agate_map.Add(packet[12], client.Entity.MapID
                                                            + "~" + client.Entity.X

                                                           + "~" + client.Entity.Y);
                                                        Database.ConquerItemTable.UpdateItemAgate(Item);
                                                        Item.SendAgate(client);
                                                    }
                                                    break;
                                                }
                                            }
                                            break;
                                        }
                                    case 3:
                                        {
                                            if (client.Map.IsDynamic()) return;
                                            if (ServerBase.Constants.revnomap.Contains(client.Entity.MapID))
                                                return;
                                            Interfaces.IConquerItem Item = null;
                                            if (client.Inventory.TryGetItem(ItemUID, out Item))
                                            {

                                                if (Item.Agate_map.ContainsKey(packet[12]))
                                                {
                                                    if (ServerBase.Constants.MemoryAgateNotAllowedMap.Contains(ushort.Parse(Item.Agate_map[packet[12]].Split('~')[0].ToString())))
                                                    {
                                                        return;
                                                    }
                                                    /*if (ushort.Parse(Item.Agate_map[packet[12]].Split('~')[0].ToString()) == 1038)
                                                        return;
                                                    if (ushort.Parse(Item.Agate_map[packet[12]].Split('~')[0].ToString()) == 6001)
                                                        return;*/
                                                    client.Entity.Teleport(ushort.Parse(Item.Agate_map[packet[12]].Split('~')[0].ToString())
                                                        , ushort.Parse(Item.Agate_map[packet[12]].Split('~')[1].ToString())
                                                        , ushort.Parse(Item.Agate_map[packet[12]].Split('~')[2].ToString()));
                                                    Item.Durability--;
                                                    Item.SendAgate(client);
                                                    Database.ConquerItemTable.UpdateItemAgate(Item);
                                                }
                                            }
                                            break;
                                        }
                                    case 4:
                                        {
                                            if (ServerBase.Constants.MemoryAgateNotAllowedMap.Contains(client.Entity.MapID))
                                                return;
                                            Interfaces.IConquerItem Item = null;
                                            if (client.Inventory.TryGetItem(ItemUID, out Item))
                                            {
                                                uint cost = (uint)(Item.MaximDurability - Item.Durability) / 2;
                                                if (cost == 0)
                                                    cost = 1;
                                                if (client.Entity.ConquerPoints > cost)
                                                {
                                                    client.Entity.ConquerPoints -= cost;
                                                    Item.Durability = Item.MaximDurability;
                                                    Item.SendAgate(client);
                                                    Database.ConquerItemTable.UpdateItemAgate(Item);
                                                }
                                            }
                                            break;
                                        }
                                }
                                break;
                            }
                        #endregion
                        #region Ayudante
                        case 1321:
                        case 1322:
                        case 1136:
                        case 1320:

                            client.Send(packet);
                            break;
                        case 2261:
                            {
                                client.Send(packet);
                            }
                            break;
                        #endregion
                        #region Advertise
                        case 2226:
                            {
                                byte[] firstpacket = new byte[724]{0xCC,0x02,0xB2,0x08,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00//;̲0x,0x0x0x
            ,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x67,0x01,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x,0xg0x0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x75,0x83,0x83,0x50//;0x0x0x,0x,0xPuƒƒP
            ,0x75,0x83,0x83,0x50,0x61,0x24,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;uƒƒPa$$0x0x0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44//;0x0x0x0x0xD
            ,0x65,0x76,0x69,0x6C,0x5F,0x44,0x6F,0x67,0x67,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;evil_Dogg0x0x,0x
            ,0x01,0x00,0x00,0x00,0x83,0x00,0x00,0x00,0x81,0xC3,0x15,0x00,0x00,0x00,0x00,0x00//;0xƒ0xÃ0x,0x,0x
            ,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;,0x0x0x0x0x,0x
            ,0x7E,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;~0x0x0x0x,0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x41,0x4F,0x57,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0xAOW0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x73,0x61,0x61,0x6E,0x00,0x00,0x00,0x00,0x00//;0x0x,0xsaan0x,0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0D,0x00,0x00,0x00//;0x0x,0x,0x0x0x
            ,0xA5,0x0C,0x0E,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00//;¥0x,0x,0x,0x0x,0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x51,0x53,0x65//;0x0x0x0xTQSe
            ,0x72,0x76,0x65,0x72};//;rver
                                client.Send(firstpacket);
                                byte[] secondpacket = new byte[724]{0xCC,0x02,0xB2,0x08,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00//;̲//////,0x//,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x16,0x01,0x00,0x00,0x00,0x00,0x00,0x00//;//////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x2A,0x41,0x75,0x74//;//////,0x`*Aut
            ,0x68,0x65,0x6E,0x74,0x69,0x63,0x2A,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;hentic*`////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4E//;//////,0xN
            ,0x61,0x72,0x72,0x63,0x6F,0x74,0x69,0x63,0x7A,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;arrcoticz//,0x
            ,0x01,0x00,0x00,0x00,0x59,0x00,0x00,0x00,0xDF,0xA3,0x59,0x00,0x00,0x00,0x00,0x00//;//,0xY//,0xߣY////,0x
            ,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;,0x////,0x
            ,0x7B,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;{//////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x7E,0x2A,0x44,0x65,0x5F,0x41,0x5F,0x74,0x68,0x2A,0x7E,0x00,0x00//;//,0x~*De_A_th*~//
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5E,0x5E,0x5E,0x5E,0x5E,0x32,0x5E,0x5E,0x5E//;//,0x^^^^^2^^^
            ,0x5E,0x5E,0x5E,0x5E,0x5E,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00//;^^^^^//,0x//,0x//,0x
            ,0x10,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00//;'//,0x////,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x51,0x53,0x65//;////TQSe
            ,0x72,0x76,0x65,0x72};//////////////;rver
                                client.Send(secondpacket);
                                break;
                            }
                        #endregion
                        #region OneArmedBandit 1351 AboRagab/Kimo/Amro kan bys2f
                        case 1351:
                            {
                                if (packet[4] == 0)
                                {
                                    if (client.Entity.ConquerPoints >= 100 * packet[5])
                                    {
                                        client.Send(packet);
                                        Sendonearmed(client);
                                        //PrintPacket(packet);
                                        client.Entity.ConquerPoints -= (uint)(100 * packet[5]);
                                        //Console.WriteLine("cps " +(uint)(100 * packet[5]));
                                    }
                                }
                                else
                                {
                                    Sendonearmed2(client);
                                    Prize3X(client);
                                    client.Entity.ConquerPoints += client.Entity.CPSS * packet[5];
                                    //Console.WriteLine("Win " + (uint)(client.Entity.CPSS * packet[5]));
                                    //PrintPacket(packet);
                                }
                                break;
                            }

                        #endregion
                        /*case 1044:
                            PrintPacket(packet);
                            client.Send(packet);
                            break;*/
                        /*#region PK Explorer (2220)
                         case 2220:
                             {
                                 PkExplorer pk = new PkExplorer(packet, client);
                                 pk.SubType = 1;
                                 client.Send(pk.Build());
                                 break;
                             }
                         #endregion*/
                        /* #region Cases de Packs
                         case 1034:
                         case 1037:
                             {
                                 client.Send(packet);
                                 break;
                             }
                         case 1135:
                             client.Send(packet);
                             break;
                         case 1134:
                             {
                                 switch (ID2)
                                 {
                                     case 1:
                                         client.Send(packet);
                                         break;
                                     case 2:
                                         client.Send(packet);
                                         break;
                                     case 3:
                                         client.Send(packet);
                                         break;
                                     case 4:
                                         client.Send(packet);
                                         break;
                                     case 5:
                                         client.Send(packet);
                                         break;
                                     case 6:
                                         client.Send(packet);
                                         break;
                                     case 7:
                                         client.Send(packet);
                                         break;
                                     case 8:
                                         client.Send(packet);
                                         break;
                                     case 9:
                                         client.Send(packet);
                                         break;
                                     case 10:
                                         client.Send(packet);
                                         break;
                                 }
                                 break;
                             }
                         #endregion*/
                        /*case 1134:
                            {
                                PhoenixProject.Network.GamePackets.Quest.QuestInfo.Handle(packet, client);
                                break;
                            }
                        case 1135:
                            {
                                PhoenixProject.Network.GamePackets.Quest.QuestQuery2.Handle(packet, client);
                                break;
                            }*/
                        /* case 1136:
                             {
                                 //PrintPacket(packet);
                                 client.Send(packet);
                                // PrintPacket(packet);
                                 break;
                             }*/
                        default:
                            {
                                if (client.Account.State == PhoenixProject.Database.AccountTable.AccountState.Coder)
                                {
                                    ushort key = BitConverter.ToUInt16(packet, 2);
                                    //PrintPacket(packet);
                                    Console.WriteLine("[Kimo]=> Unknown Packet: " + key + "");
                                    // Console.WriteLine("[Kimo]=> Unknown Packet: " + key + " " + PacketConstructor.Dump(packet) + "");

                                }

                                break;
                            }
                    }
                }
            }
            catch (Exception e)
            {
                Program.SaveException(e);
            }
        }
        public static void EquipItem(ItemUsage itemUsage, Client.GameState client)
        {
            if (!client.AlternateEquipment)
            {
                if (itemUsage.dwParam < 20)
                {

                    Interfaces.IConquerItem item = null;
                    client.Entity.AttackPacket = null;

                    if (client.Inventory.TryGetItem(itemUsage.UID, out item) && client.Booth == null)
                    {
                        if (item.Suspicious)
                            return;

                        Positions pos = GetPositionFromID(item.ID);
                        if (client.Entity.MapID == 2060)
                        {
                            if (pos == Positions.Garment)
                            {
                                return;
                            }
                        }
                        if (client.Entity.MapID == 7009)
                        {
                            if (pos == Positions.Garment)
                            {
                                return;
                            }
                        }
                        if (pos == Positions.Inventory)
                        {
                            UseItem(item, client);
                            return;
                        }
                        #region Sanity checks

                        bool can2hand = false;
                        bool can2wpn = false;
                        if (client.Entity.Class >= 11 && client.Entity.Class <= 75)
                            can2hand = true;
                        if (client.Entity.Class >= 11 && client.Entity.Class <= 15 || client.Entity.Class >= 51 && client.Entity.Class <= 55 || client.Entity.Class >= 61 && client.Entity.Class <= 65 || client.Entity.Class >= 71 && client.Entity.Class <= 75)
                            can2wpn = true;
                        if (client.Entity.Class >= 71 && client.Entity.Class <= 75)
                            can2wpn = true;
                        if (!Equipable(item, client))
                            return;
                        if (ItemPosition(item.ID) == 5)
                        {
                            itemUsage.dwParam = 5;
                            if (!can2hand && !can2wpn)
                                return;
                            if (client.Equipment.Free(4) || (client.Equipment.TryGetItem(4).ID / 1000 != 500 && IsArrow(item.ID)))
                                return;
                        }
                        if (ItemPosition(item.ID) == 4)
                        {
                            if (itemUsage.dwParam == 5)
                                if (!can2hand || !can2wpn)
                                    return;
                        }
                        if (!((itemUsage.dwParam == 4 || itemUsage.dwParam == 5) && (ItemPosition(item.ID) == 4 || ItemPosition(item.ID) == 5)))
                        {
                            if (!IsAccessory(item.ID))
                                itemUsage.dwParam = ItemPosition(item.ID);
                        }
                        bool twohand = IsTwoHand(item.ID);

                        if (!twohand && itemUsage.dwParam == 4)
                            if (!client.Equipment.Free(5))
                                if (client.Inventory.Count < 40)
                                {
                                    if (IsArrow(client.Equipment.TryGetItem(5).ID))
                                        client.Equipment.Remove(5);
                                    else
                                    {
                                        if (client.Equipment.TryGetItem(4) != null)
                                        {
                                            if (IsTwoHand(client.Equipment.TryGetItem(4).ID))
                                                client.Equipment.Remove(4);
                                        }
                                    }
                                }
                        #endregion

                        if (client.Map.ID == 1039)
                            client.Entity.AttackPacket = null;

                        item.Position = (ushort)itemUsage.dwParam;
                        if (ItemPosition(item.ID) == 5 && !IsArrow(item.ID))
                        {
                            if (IsTwoHand(client.Equipment.TryGetItem(4).ID))
                            {
                                if (!client.Spells.ContainsKey(10311))//Perseverance
                                {
                                    client.Send(new Message("You need to know Perseverance (Warrior Pure skill) to be able to wear 2-handed weapon and shield.", System.Drawing.Color.Red, Message.Talk));
                                    return;
                                }
                            }
                        }

                        //Database.ConquerItemTable.ClearPosition(client.Entity.UID, (byte)itemUsage.dwParam);
                        client.Inventory.Remove(item, Game.Enums.ItemUse.Move, true);
                        if (client.Equipment.Free((byte)itemUsage.dwParam))
                        {
                            if (twohand)
                                client.Equipment.Remove(5);
                            item.Position = (byte)itemUsage.dwParam;
                            if (!client.AlternateEquipment)
                            {
                                client.Equipment.Add(item);
                            }
                            else
                            {
                                client.Equipment.Add505(item);
                            }
                            item.Mode = Game.Enums.ItemMode.Update;
                            item.Send(client);
                        }
                        else
                        {
                            if (twohand)
                                client.Equipment.Remove(5);
                            client.Equipment.Remove((byte)itemUsage.dwParam);
                            item.Position = (byte)itemUsage.dwParam;
                            if (!client.AlternateEquipment)
                            {
                                client.Equipment.Add(item);
                            }
                            else
                            {
                                client.Equipment.Add505(item);
                            }
                        }

                        if (!client.AlternateEquipment)
                        {
                            client.LoadItemStats(client.Entity);
                            client.CalculateStatBonus();
                            client.CalculateHPBonus();
                            ClientEquip equips = new ClientEquip();
                            equips.DoEquips(client);
                            client.Send(equips);
                            client.Equipment.UpdateEntityPacket();
                        }
                        else
                        {
                            ClientEquip equips = new ClientEquip(client);
                            //equips.DoEquips(client);
                            client.Send(equips);
                            client.Equipment.UpdateEntityPacket2();
                        }

                        Database.ConquerItemTable.UpdateLocation(item, client);
                    }
                }
                else
                {
                    Interfaces.IConquerItem item = null;
                    client.Entity.AttackPacket = null;

                    if (client.Inventory.TryGetItem(itemUsage.UID, out item) && client.Booth == null)
                    {
                        if (item.Suspicious)
                            return;

                        Positions pos = GetPositionFromID2(item.ID);
                        if (client.Entity.MapID == 2060)
                        {
                            if (pos == Positions.AltGarment)
                            {
                                return;
                            }
                        }
                        if (client.Entity.MapID == 7009)
                        {
                            if (pos == Positions.AltGarment)
                            {
                                return;
                            }
                        }
                        if (pos == Positions.Inventory)
                        {
                            UseItem(item, client);
                            return;
                        }
                        #region Sanity checks

                        bool can2hand = false;
                        bool can2wpn = false;
                        if (client.Entity.Class >= 11 && client.Entity.Class <= 75)
                            can2hand = true;
                        if (client.Entity.Class >= 11 && client.Entity.Class <= 15 || client.Entity.Class >= 51 && client.Entity.Class <= 55 || client.Entity.Class >= 61 && client.Entity.Class <= 65 || client.Entity.Class >= 71 && client.Entity.Class <= 75)
                            can2wpn = true;
                        if (client.Entity.Class >= 71 && client.Entity.Class <= 75)
                            can2wpn = true;
                        if (!Equipable(item, client))
                            return;
                        if (ItemPosition2(item.ID) == 25)
                        {
                            itemUsage.dwParam = 25;
                            if (!can2hand && !can2wpn)
                                return;
                            if (client.Equipment.Free(24) || (client.Equipment.TryGetItem(24).ID / 1000 != 500 && IsArrow(item.ID)))
                                return;
                        }
                        if (ItemPosition2(item.ID) == 24)
                        {
                            if (itemUsage.dwParam == 25)
                                if (!can2hand || !can2wpn)
                                    return;
                        }
                        if (!((itemUsage.dwParam == 24 || itemUsage.dwParam == 25) && (ItemPosition2(item.ID) == 24 || ItemPosition2(item.ID) == 25)))
                        {
                            if (!IsAccessory(item.ID))
                                itemUsage.dwParam = ItemPosition2(item.ID);
                        }
                        bool twohand = IsTwoHand(item.ID);
                        if (!twohand && itemUsage.dwParam == 24)
                            if (!client.Equipment.Free(25))
                                if (client.Inventory.Count < 40)
                                {
                                    if (IsArrow(client.Equipment.TryGetItem(25).ID))
                                        client.Equipment.Remove(25);
                                    else
                                    {
                                        if (client.Equipment.TryGetItem(24) != null)
                                        {
                                            if (IsTwoHand(client.Equipment.TryGetItem(24).ID))
                                                client.Equipment.Remove(24);
                                        }
                                    }
                                }
                        #endregion

                        if (client.Map.ID == 1039)
                            client.Entity.AttackPacket = null;

                        item.Position = (ushort)itemUsage.dwParam;
                        if (ItemPosition2(item.ID) == 25 && !IsArrow(item.ID))
                        {
                            if (IsTwoHand(client.Equipment.TryGetItem(24).ID))
                            {
                                if (!client.Spells.ContainsKey(10311))//Perseverance
                                {
                                    client.Send(new Message("You need to know Perseverance (Warrior Pure skill) to be able to wear 2-handed weapon and shield.", System.Drawing.Color.Red, Message.Talk));
                                    return;
                                }
                            }
                        }

                        //Database.ConquerItemTable.ClearPosition(client.Entity.UID, (byte)itemUsage.dwParam);
                        client.Inventory.Remove(item, Game.Enums.ItemUse.Move, true);
                        if (client.Equipment.Free((byte)itemUsage.dwParam))
                        {
                            if (twohand)
                                client.Equipment.Remove(25);
                            item.Position = (byte)itemUsage.dwParam;
                            if (!client.AlternateEquipment)
                            {
                                client.Equipment.Add(item);
                            }
                            else
                            {
                                client.Equipment.Add600(item);
                            }
                            item.Mode = Game.Enums.ItemMode.Update;
                            item.Send(client);
                        }
                        else
                        {
                            if (twohand)
                                client.Equipment.Remove(25);
                            client.Equipment.Remove((byte)itemUsage.dwParam);
                            item.Position = (byte)itemUsage.dwParam;
                            if (!client.AlternateEquipment)
                            {
                                client.Equipment.Add(item);
                            }
                            else
                            {
                                client.Equipment.Add600(item);
                            }
                        }
                        if (client.AlternateEquipment)
                        {
                            client.LoadItemStats2(client.Entity);
                            client.CalculateStatBonus();
                            client.CalculateHPBonus();

                            ClientEquip equips = new ClientEquip(client);
                            client.Send(equips);
                            client.Equipment.UpdateEntityPacket2();
                        }
                        else
                        {

                        }
                        Database.ConquerItemTable.UpdateLocation(item, client);
                    }
                }
                client.LoadItemStats(client.Entity);
                client.CalculateStatBonus();
                client.CalculateHPBonus();
            }
            else
            {
                if (itemUsage.dwParam < 20)
                {

                    Interfaces.IConquerItem item = null;
                    client.Entity.AttackPacket = null;

                    if (client.Inventory.TryGetItem(itemUsage.UID, out item) && client.Booth == null)
                    {
                        if (item.Suspicious)
                            return;

                        Positions pos = GetPositionFromID(item.ID);
                        if (client.Entity.MapID == 2060)
                        {
                            if (pos == Positions.Garment)
                            {
                                return;
                            }
                        }
                        if (client.Entity.MapID == 7009)
                        {
                            if (pos == Positions.Garment)
                            {
                                return;
                            }
                        }
                        if (pos == Positions.Inventory)
                        {
                            UseItem(item, client);
                            return;
                        }
                        #region Sanity checks

                        bool can2hand = false;
                        bool can2wpn = false;
                        if (client.Entity.Class >= 11 && client.Entity.Class <= 75)
                            can2hand = true;
                        if (client.Entity.Class >= 11 && client.Entity.Class <= 15 || client.Entity.Class >= 51 && client.Entity.Class <= 55 || client.Entity.Class >= 61 && client.Entity.Class <= 65 || client.Entity.Class >= 71 && client.Entity.Class <= 75)
                            can2wpn = true;
                        if (client.Entity.Class >= 71 && client.Entity.Class <= 75)
                            can2wpn = true;
                        if (!Equipable(item, client))
                            return;
                        if (ItemPosition(item.ID) == 5)
                        {
                            itemUsage.dwParam = 5;
                            if (!can2hand && !can2wpn)
                                return;
                            if (client.Equipment.Free(4) || (client.Equipment.TryGetItem(4).ID / 1000 != 500 && IsArrow(item.ID)))
                                return;
                        }
                        if (ItemPosition(item.ID) == 4)
                        {
                            if (itemUsage.dwParam == 5)
                                if (!can2hand || !can2wpn)
                                    return;
                        }
                        if (!((itemUsage.dwParam == 4 || itemUsage.dwParam == 5) && (ItemPosition(item.ID) == 4 || ItemPosition(item.ID) == 5)))
                        {
                            if (!IsAccessory(item.ID))
                                itemUsage.dwParam = ItemPosition(item.ID);
                        }
                        bool twohand = IsTwoHand(item.ID);
                        if (!twohand && itemUsage.dwParam == 4)
                            if (!client.Equipment.Free(5))
                                if (client.Inventory.Count < 40)
                                {
                                    if (IsArrow(client.Equipment.TryGetItem(5).ID))
                                        client.Equipment.Remove(5);
                                    else
                                    {
                                        if (client.Equipment.TryGetItem(4) != null)
                                        {
                                            if (IsTwoHand(client.Equipment.TryGetItem(4).ID))
                                                client.Equipment.Remove(4);
                                        }
                                    }
                                }
                        #endregion

                        if (client.Map.ID == 1039)
                            client.Entity.AttackPacket = null;

                        item.Position = (ushort)itemUsage.dwParam;
                        if (ItemPosition(item.ID) == 5 && !IsArrow(item.ID))
                        {
                            if (IsTwoHand(client.Equipment.TryGetItem(4).ID))
                            {
                                if (!client.Spells.ContainsKey(10311))//Perseverance
                                {
                                    client.Send(new Message("You need to know Perseverance (Warrior Pure skill) to be able to wear 2-handed weapon and shield.", System.Drawing.Color.Red, Message.Talk));
                                    return;
                                }
                            }
                        }

                        //Database.ConquerItemTable.ClearPosition(client.Entity.UID, (byte)itemUsage.dwParam);
                        client.Inventory.Remove(item, Game.Enums.ItemUse.Move, true);
                        if (client.Equipment.Free((byte)itemUsage.dwParam))
                        {
                            if (twohand)
                                client.Equipment.Remove(5);
                            item.Position = (byte)itemUsage.dwParam;
                            if (!client.AlternateEquipment)
                            {
                                client.Equipment.Add(item);
                            }
                            else
                            {
                                client.Equipment.Add505(item);
                            }
                            item.Mode = Game.Enums.ItemMode.Update;
                            item.Send(client);
                        }
                        else
                        {
                            if (twohand)
                                client.Equipment.Remove(5);
                            client.Equipment.Remove((byte)itemUsage.dwParam);
                            item.Position = (byte)itemUsage.dwParam;
                            if (!client.AlternateEquipment)
                            {
                                client.Equipment.Add(item);
                            }
                            else
                            {
                                client.Equipment.Add505(item);
                            }
                        }

                        if (!client.AlternateEquipment)
                        {
                            client.LoadItemStats(client.Entity);
                            client.CalculateStatBonus();
                            client.CalculateHPBonus();
                            ClientEquip equips = new ClientEquip();
                            equips.DoEquips(client);
                            client.Send(equips);
                            client.Equipment.UpdateEntityPacket();
                        }
                        else
                        {
                            client.LoadItemStats2(client.Entity);
                            client.CalculateStatBonus();
                            client.CalculateHPBonus();
                            ClientEquip equips = new ClientEquip(client);
                            //equips.DoEquips(client);
                            client.Send(equips);
                            client.Equipment.UpdateEntityPacket2();
                        }

                        Database.ConquerItemTable.UpdateLocation(item, client);
                    }
                }
                else
                {
                    Interfaces.IConquerItem item = null;
                    client.Entity.AttackPacket = null;

                    if (client.Inventory.TryGetItem(itemUsage.UID, out item) && client.Booth == null)
                    {
                        if (item.Suspicious)
                            return;

                        Positions pos = GetPositionFromID2(item.ID);
                        if (client.Entity.MapID == 2060)
                        {
                            if (pos == Positions.AltGarment)
                            {
                                return;
                            }
                        }
                        if (client.Entity.MapID == 7009)
                        {
                            if (pos == Positions.AltGarment)
                            {
                                return;
                            }
                        }
                        if (pos == Positions.Inventory)
                        {
                            UseItem(item, client);
                            return;
                        }
                        #region Sanity checks

                        bool can2hand = false;
                        bool can2wpn = false;
                        if (client.Entity.Class >= 11 && client.Entity.Class <= 75)
                            can2hand = true;
                        if (client.Entity.Class >= 11 && client.Entity.Class <= 15 || client.Entity.Class >= 51 && client.Entity.Class <= 55 || client.Entity.Class >= 61 && client.Entity.Class <= 65 || client.Entity.Class >= 71 && client.Entity.Class <= 75)
                            can2wpn = true;
                        if (client.Entity.Class >= 71 && client.Entity.Class <= 75)
                            can2wpn = true;
                        if (!Equipable(item, client))
                            return;
                        if (ItemPosition2(item.ID) == 25)
                        {
                            itemUsage.dwParam = 25;
                            if (!can2hand && !can2wpn)
                                return;
                            if (client.Equipment.Free(24) || (client.Equipment.TryGetItem(24).ID / 1000 != 500 && IsArrow(item.ID)))
                                return;
                        }
                        if (ItemPosition2(item.ID) == 24)
                        {
                            if (itemUsage.dwParam == 25)
                                if (!can2hand || !can2wpn)
                                    return;
                        }
                        if (!((itemUsage.dwParam == 24 || itemUsage.dwParam == 25) && (ItemPosition2(item.ID) == 24 || ItemPosition2(item.ID) == 25)))
                        {
                            if (!IsAccessory(item.ID))
                                itemUsage.dwParam = ItemPosition2(item.ID);
                        }
                        bool twohand = IsTwoHand(item.ID);
                        if (!twohand && itemUsage.dwParam == 24)
                            if (!client.Equipment.Free(25))
                                if (client.Inventory.Count < 40)
                                {
                                    if (IsArrow(client.Equipment.TryGetItem(25).ID))
                                        client.Equipment.Remove(25);
                                    else
                                    {
                                        if (client.Equipment.TryGetItem(24) != null)
                                        {
                                            if (IsTwoHand(client.Equipment.TryGetItem(24).ID))
                                                client.Equipment.Remove(24);
                                        }
                                    }
                                }
                        #endregion

                        if (client.Map.ID == 1039)
                            client.Entity.AttackPacket = null;

                        item.Position = (ushort)itemUsage.dwParam;
                        if (ItemPosition2(item.ID) == 25 && !IsArrow(item.ID))
                        {
                            if (IsTwoHand(client.Equipment.TryGetItem(24).ID))
                            {
                                if (!client.Spells.ContainsKey(10311))//Perseverance
                                {
                                    client.Send(new Message("You need to know Perseverance (Warrior Pure skill) to be able to wear 2-handed weapon and shield.", System.Drawing.Color.Red, Message.Talk));
                                    return;
                                }
                            }
                        }

                        //Database.ConquerItemTable.ClearPosition(client.Entity.UID, (byte)itemUsage.dwParam);
                        client.Inventory.Remove(item, Game.Enums.ItemUse.Move, true);
                        if (client.Equipment.Free((byte)itemUsage.dwParam))
                        {
                            if (twohand)
                                client.Equipment.Remove(25);
                            item.Position = (byte)itemUsage.dwParam;
                            if (!client.AlternateEquipment)
                            {
                                client.Equipment.Add(item);
                            }
                            else
                            {
                                client.Equipment.Add600(item);
                            }
                            item.Mode = Game.Enums.ItemMode.Update;
                            item.Send(client);
                        }
                        else
                        {
                            if (twohand)
                                client.Equipment.Remove(25);
                            client.Equipment.Remove((byte)itemUsage.dwParam);
                            item.Position = (byte)itemUsage.dwParam;
                            if (!client.AlternateEquipment)
                            {
                                client.Equipment.Add(item);
                            }
                            else
                            {
                                client.Equipment.Add600(item);
                            }
                        }
                        if (client.AlternateEquipment)
                        {
                            client.LoadItemStats2(client.Entity);
                            client.CalculateStatBonus();
                            client.CalculateHPBonus();
                            ClientEquip equips = new ClientEquip(client);
                            client.Send(equips);
                            client.Equipment.UpdateEntityPacket2();
                        }
                        else
                        {

                        }
                        Database.ConquerItemTable.UpdateLocation(item, client);
                    }
                }
                client.LoadItemStats2(client.Entity);
                client.CalculateStatBonus();
                client.CalculateHPBonus();
            }
        }
        static bool CheckCommand(Message message, Client.GameState client)
        {
            try
            {
                if (message.__Message.StartsWith("@"))
                {
                    string Message = message.__Message.Substring(1).ToLower();
                    string Mess = message.__Message.Substring(1);
                    string[] Data = Message.Split(' ');
                    #region GMs PMs
                    if (client.Account.State == PhoenixProject.Database.AccountTable.AccountState.ProjectManager || client.Account.State == PhoenixProject.Database.AccountTable.AccountState.Coder)
                    {
                        switch (Data[0])
                        {

                            case "addcps":
                                {
                                    foreach (var pClient in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            if (!Game.PrizeNPC.PrizeNpcInformations.ContainsKey(pClient.Entity.UID))
                                            {
                                                PhoenixProject.Game.PrizeNPC.PrizeNpcInfo info = new PhoenixProject.Game.PrizeNPC.PrizeNpcInfo();
                                                info.Owner = pClient.Entity.UID;
                                                info.type = 1;
                                                info.amount = uint.Parse(Data[2]);
                                                info.itemid = 0;
                                                PhoenixProject.Game.PrizeNPC.PrizeNpcInformations.Add(info.Owner, info);
                                                PhoenixProject.Database.MySqlCommand cmd = new PhoenixProject.Database.MySqlCommand(PhoenixProject.Database.MySqlCommandType.INSERT);
                                                cmd.Insert("prizenpc").Insert("Owner", client.Entity.UID).Insert("type", info.type).Insert("Amount", info.amount).Insert("itemid", info.itemid);
                                                cmd.Execute();
                                                Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Congratulation you have got an Donation Prize " + info.amount + " Cps go to PrizeNpc to Claim It?");
                                                npc.OptionID = 255;
                                                pClient.Send(npc.ToArray());

                                                Network.GamePackets.NpcReply npc2 = new Network.GamePackets.NpcReply(6, "" + pClient.Entity.Name + " has Recived " + info.amount + " Cps");
                                                npc2.OptionID = 255;
                                                client.Send(npc2.ToArray());

                                                Console.WriteLine("" + pClient.Entity.Name + " has got Donation Prize Cps " + info.amount + "");
                                            }
                                            else
                                            {
                                                Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Sorry the player already have prize not claimed yet");
                                                npc.OptionID = 255;
                                                client.Send(npc.ToArray());
                                            }
                                        }
                                    }
                                    break;
                                }
                            case "who":
                                {
                                    var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                    varr.MoveNext();
                                    int COunt = ServerBase.Kernel.GamePool.Count;
                                    for (uint x = 0;
                                        x < COunt;
                                        x++)
                                    {
                                        if (x >= COunt) break;

                                        Client.GameState pClient = (varr.Current as Client.GameState);

                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            client.Send(new Message("[Whois " + pClient.Entity.Name + "]", System.Drawing.Color.Gold, GamePackets.Message.FirstRightCorner));
                                            client.Send(new Message("Username: "******"Password: "******"IP: " + pClient.Account.IP, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("CPs: " + pClient.Entity.ConquerPoints, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("Money: " + pClient.Entity.Money, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("Class: " + pClient.Entity.Class, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("UID: " + pClient.Entity.UID, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("Level: " + pClient.Entity.Level, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("Strength: " + pClient.Entity.Strength, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("Agility: " + pClient.Entity.Agility, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("Vitality: " + pClient.Entity.Vitality, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("Spirit: " + pClient.Entity.Spirit, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("Atributes: " + pClient.Entity.Atributes, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("Hitpoints: " + pClient.Entity.Hitpoints, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("PKPoints: " + pClient.Entity.PKPoints, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("VIPLevel: " + pClient.Entity.VIPLevel, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("Map: [" + pClient.Entity.MapID + "] " + pClient.Entity.X + "," + pClient.Entity.Y, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                        }

                                        varr.MoveNext();
                                    }
                                    break;
                                }
                            case "additem":
                                {
                                    foreach (var pClient in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            if (!Game.PrizeNPC.PrizeNpcInformations.ContainsKey(pClient.Entity.UID))
                                            {
                                                PhoenixProject.Game.PrizeNPC.PrizeNpcInfo info = new PhoenixProject.Game.PrizeNPC.PrizeNpcInfo();
                                                info.Owner = pClient.Entity.UID;
                                                info.type = 2;
                                                info.amount = 0;
                                                info.itemid = uint.Parse(Data[2]);
                                                PhoenixProject.Game.PrizeNPC.PrizeNpcInformations.Add(info.Owner, info);

                                                PhoenixProject.Database.MySqlCommand cmd = new PhoenixProject.Database.MySqlCommand(PhoenixProject.Database.MySqlCommandType.INSERT);
                                                cmd.Insert("prizenpc").Insert("Owner", client.Entity.UID).Insert("type", info.type).Insert("Amount", info.amount).Insert("itemid", info.itemid);
                                                cmd.Execute();
                                                Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Congratulation you have got an Donation item go to PrizeNpc to Claim It?");
                                                npc.OptionID = 255;
                                                pClient.Send(npc.ToArray());

                                                Network.GamePackets.NpcReply npc2 = new Network.GamePackets.NpcReply(6, "" + pClient.Entity.Name + " has Recived item id: " + info.itemid + "");
                                                npc2.OptionID = 255;
                                                client.Send(npc2.ToArray());
                                                Console.WriteLine("" + pClient.Entity.Name + " has got Donation Prize item " + info.itemid + "");
                                            }
                                            else
                                            {
                                                Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Sorry the player already have prize not claimed yet");
                                                npc.OptionID = 255;
                                                client.Send(npc.ToArray());
                                            }
                                        }
                                    }
                                    break;
                                }
                            case "summon":
                                {
                                    foreach (var pClient in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            pClient.Entity.Teleport(client.Entity.MapID, client.Entity.X, client.Entity.Y);
                                        }
                                    }
                                    break;
                                }
                            case "scroll":
                                {
                                    if (client.Entity.MapID == 700)
                                        break;
                                    switch (Data[1].ToLower())
                                    {
                                        case "tc": client.Entity.Teleport(1002, 430, 380); break;
                                        case "pc": client.Entity.Teleport(1011, 195, 260); break;
                                        case "ac":
                                        case "am": client.Entity.Teleport(1020, 566, 563); break;
                                        case "dc": client.Entity.Teleport(1000, 500, 645); break;
                                        case "bi": client.Entity.Teleport(1015, 723, 573); break;
                                        case "pka": client.Entity.Teleport(1005, 050, 050); break;
                                        case "ma": client.Entity.Teleport(1036, 211, 196); break;
                                        case "ja": client.Entity.Teleport(6000, 100, 100); break;
                                    }
                                    break;
                                }

                            case "test":
                                {
                                    byte IDs = byte.Parse(Data[1]);
                                    Data data = new Data(true);
                                    data.UID = client.Entity.UID;
                                    data.dwParam = 2;
                                    data.ID = IDs;//157
                                    data.wParam1 = client.Entity.X;
                                    data.wParam2 = client.Entity.Y;
                                    client.Send(data);
                                    break;
                                }
                            case "jar":
                                {
                                    ConquerItem item2 = new ConquerItem(true);
                                    item2.ID = 750000;
                                    //item2.Color =  PhoenixProject.Game.Enums.Color.Blue;
                                    item2.Durability = 0;
                                    item2.MaximDurability = 2;
                                    client.Inventory.Add(item2, PhoenixProject.Game.Enums.ItemUse.CreateAndAdd);
                                    break;
                                }
                            case "id":
                                {

                                    byte[] data = new byte[24 + 8];
                                    Writer.WriteUInt32(24, 0, data);
                                    Writer.WriteUInt32(1010, 2, data);
                                    Writer.WriteUInt32(client.Entity.UID, 4, data);
                                    Writer.WriteUInt32(1, 7, data);
                                    Writer.WriteUInt32(client.Entity.UID, 8, data);
                                    Writer.WriteUInt32(client.Entity.UID, 12, data);
                                    Writer.WriteUInt32(client.Entity.UID, 16, data);
                                    Writer.WriteUInt32(1, 19, data);
                                    Writer.WriteUInt32(7, 20, data);
                                    Writer.WriteUInt32(121, 22, data);

                                    // Writer.WriteUInt32(9828, 12, data);
                                    client.Send(data);
                                    // client.Entity.CountryFlag = uint.Parse(Data[1]);
                                    break;
                                }
                            case "itemeffect":
                                {
                                    Kernel.boundID = int.Parse(Data[1]);
                                    Kernel.boundIDEnd = int.Parse(Data[2]);
                                    break;
                                }
                            case "kiko":
                                {
                                    string[] Strings = new string[2];

                                    Strings[0] = (Data[1]);
                                    Strings[1] = "1";
                                    _String SoundPacket = new _String(true);
                                    SoundPacket.UID = client.Entity.UID;
                                    SoundPacket.Type = 20;
                                    SoundPacket.TextsCount = 2;
                                    SoundPacket.Texts.Add(Strings[0]);
                                    SoundPacket.Texts.Add(Strings[1]);
                                    client.Send(SoundPacket);
                                    break;
                                    //client.Entity.ActualMyTypeFlower = 30010102;
                                    // break;
                                }
                            case "ss":
                                {

                                    byte[] data = new byte[80 + 8];
                                    Writer.WriteUInt32(80, 0, data);
                                    Writer.WriteUInt32(1151, 2, data);
                                    Writer.WriteUInt32(2, 4, data);
                                    Writer.WriteUInt32(1, 8, data);
                                    Writer.WriteUInt32(1, 16, data);
                                    Writer.WriteUInt32(227, 32, data);
                                    Writer.WriteUInt32(client.Entity.UID, 40, data);
                                    Writer.WriteUInt32(client.Entity.UID, 44, data);
                                    Writer.WriteString(client.Entity.Name, 48, data);
                                    Writer.WriteString(client.Entity.Name, 64, data);
                                    client.Send(data);
                                    byte[] data2 = new byte[80 + 8];
                                    Writer.WriteUInt32(80, 0, data2);
                                    Writer.WriteUInt32(1151, 2, data2);
                                    Writer.WriteUInt32(2, 4, data2);
                                    Writer.WriteUInt32(2, 8, data2);
                                    Writer.WriteUInt32(1, 16, data2);
                                    Writer.WriteUInt32(282, 32, data2);
                                    Writer.WriteUInt32(client.Entity.UID, 40, data2);
                                    Writer.WriteUInt32(client.Entity.UID, 44, data2);
                                    Writer.WriteString(client.Entity.Name, 48, data2);
                                    Writer.WriteString(client.Entity.Name, 64, data2);
                                    client.Send(data2);
                                    // client.Send(new Message("Test Channel Mesaage!", System.Drawing.Color.Red, uint.Parse(Data[1])));
                                    //client.Entity.ClanSharedBp = 4;
                                    // Game.KimoCarnaval.Load();
                                    /*NpcInitial initial = new NpcInitial
                                    {
                                        Identifier = 1,
                                        Lookface = (num != 0x2008) ? ((ushort)0x1a) : ((ushort)3),
                                        Mode = PhoenixProject.Network.GamePackets.NpcInitial.NpcModes.Place,
                                        Furniture = num
                                    };
                                    client.Send((byte[])initial);*/
                                    break;
                                }
                            case "600":
                                {
                                    Game.Map Map = ServerBase.Kernel.Maps[client.Entity.MapID];
                                    Network.GamePackets.FloorItem floorItem = new Network.GamePackets.FloorItem(true);

                                    floorItem.MapObjType = Game.MapObjectType.Item;
                                    floorItem.ItemID = uint.Parse(Data[1]);
                                    floorItem.MapID = client.Entity.MapID;

                                    floorItem.X = ushort.Parse(Data[2]);
                                    floorItem.Y = ushort.Parse(Data[3]);
                                    floorItem.Type = 10;
                                    floorItem.OnFloor = Time32.Now.AddHours(24);
                                    floorItem.UID = Network.GamePackets.FloorItem.FloorUID.Next;
                                    while (Map.Npcs.ContainsKey(floorItem.UID))
                                        floorItem.UID = Network.GamePackets.FloorItem.FloorUID.Next;
                                    Map.AddFloorItem(floorItem);
                                    client.SendScreenSpawn(floorItem, true);
                                    client.Effect = true;
                                    /* _String str = new _String(true);
                                     str.UID = client.Entity.UID;
                                     str.TextsCount = 2;
                                     str.Type = _String.Sound;
                                     str.Texts.Add("sound");
                                     str.Texts.Add("gethp.wav");
                                     client.Send(str);*/

                                    // client.Entity.TitlePacket.dwParam2 = (byte)PhoenixProject.Game.Tournaments.top_typ.GoldenRacer;
                                    break;
                                }
                            case "quiz":
                                {
                                    //PhoenixProject.Game.ConquerStructures.QuizShow.Start();
                                    // client.Send(GamePackets.QuizInfo.tempQuestionBuffer());
                                    //Game.ConquerStructures.QuizShow.Start();
                                    Game.ConquerStructures.QuizShow.Start2();
                                    Program.QuizStamp = Time32.Now;
                                    break;
                                }
                            case "me":
                                {
                                    /* MessageTick m = new MessageTick();
                                     m.Identifier = client.Entity.UID;
                                     m.Response = client.Entity.UID;
                                     client.Send(m);*/

                                    MapStatus mbox = new MapStatus();
                                    mbox.BaseID = 1002;
                                    client.Send(mbox);
                                    break;
                                }
                            case "quiz2":
                                {
                                    //PhoenixProject.Game.ConquerStructures.QuizShow.Start();
                                    // client.Send(GamePackets.QuizInfo.tempQuestionBuffer());
                                    //Game.ConquerStructures.QuizShow.Start();
                                    Game.ConquerStructures.QuizShow.Stop();
                                    break;
                                }
                            case "q":
                                {
                                    //PhoenixProject.Game.ConquerStructures.QuizShow.Start();
                                    // client.Send(GamePackets.QuizInfo.tempQuestionBuffer());
                                    //Game.ConquerStructures.QuizShow.Start();
                                    client.Send(GamePackets.QuizInfo.tempQuestionBuffer());
                                    break;
                                }
                            case "team":
                                {
                                    {
                                        Game.KimoSkillWar.Started = true;
                                        Game.KimoSkillWar.SignUP = true;

                                    }
                                    break;
                                }
                            case "geartest":
                                {
                                    //181315 515black
                                    uint UID = 92000;
                                    PhoenixProject.Interfaces.IConquerItem newItem = new PhoenixProject.Network.GamePackets.ConquerItem(true);
                                    newItem.ID = 181825;
                                    newItem.UID = UID;
                                    newItem.Durability = 1000;
                                    newItem.MaximDurability = 1000;
                                    newItem.Position = 9;
                                    //client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
                                    client.Equipment.Remove(9);
                                    if (client.Equipment.Objects[8] != null)
                                        client.Equipment.Objects[8] = null;
                                    client.Equipment.Add(newItem);
                                    newItem.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                    newItem.Send(client);
                                    ClientEquip equips = new ClientEquip();
                                    equips.DoEquips(client);
                                    client.Send(equips);
                                    client.Equipment.UpdateEntityPacket();
                                    break;

                                }
                            case "quarantine":
                                {
                                    //542363
                                    PhoenixProject.Game.ConquerStructures.Quarantine.Started = true;
                                    break;
                                }
                            case "test2":
                                {
                                    client.Entity.RemoveFlag(ulong.Parse(Data[1]));
                                    break;
                                }
                            case "arrest":
                                {
                                    foreach (var pClient in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            pClient.Entity.Teleport(6004, 30, 74);
                                        }
                                    }
                                    break;
                                }

                            case "pkp":
                                {
                                    client.Entity.PKPoints = ushort.Parse(Data[1]);

                                    break;
                                }
                            case "dropevent":
                                {

                                    Interfaces.IConquerItem Item = null;

                                    #region Get Item
                                    string ItemName = Data[1];
                                    bool SpecialItem = false;
                                    uint SpecialID = 0;
                                    if (ItemName.Contains("cp") || ItemName.Contains("met") || ItemName.Contains("db") || ItemName.Contains("stone") || ItemName.Contains("soul"))
                                    {
                                        if (ItemName.Contains("cp"))
                                            SpecialID = 729911;
                                        else if (ItemName.Contains("db"))
                                            SpecialID = 1088000;
                                        else if (ItemName.Contains("met"))
                                            SpecialID = 1088001;
                                        else if (ItemName.Contains("stone"))
                                            SpecialID = 730008;
                                        else if (ItemName.Contains("Soul"))
                                            SpecialID = 800110;
                                        SpecialItem = true; goto PrepareDrop;
                                    }
                                    if (ItemName.ToLower() == "exp")
                                    {
                                        for (int c = 0; c < client.Screen.Objects.Count; c++)
                                        {
                                            if (c >= client.Screen.Objects.Count)
                                                break;
                                            Interfaces.IMapObject ClientObj = client.Screen.Objects[c];
                                            if (ClientObj != null)
                                            {
                                                if (ClientObj is Game.Entity)
                                                {
                                                    if (ClientObj.MapObjType == PhoenixProject.Game.MapObjectType.Player)
                                                    {
                                                        ClientObj.Owner.IncreaseExperience(ClientObj.Owner.ExpBall, false);
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    }
                                    Game.Enums.ItemQuality Quality = Game.Enums.ItemQuality.NormalV3;
                                    if (Data.Length > 2)
                                    {
                                        switch (Data[3].ToLower())
                                        {
                                            case "fixed": Quality = Game.Enums.ItemQuality.Fixed; break;
                                            case "normal": Quality = Game.Enums.ItemQuality.Normal; break;
                                            case "normalv1": Quality = Game.Enums.ItemQuality.NormalV1; break;
                                            case "normalv2": Quality = Game.Enums.ItemQuality.NormalV2; break;
                                            case "normalv3": Quality = Game.Enums.ItemQuality.NormalV3; break;
                                            case "refined": Quality = Game.Enums.ItemQuality.Refined; break;
                                            case "unique": Quality = Game.Enums.ItemQuality.Unique; break;
                                            case "elite": Quality = Game.Enums.ItemQuality.Elite; break;
                                            case "super": Quality = Game.Enums.ItemQuality.Super; break;
                                            case "other": Quality = Game.Enums.ItemQuality.Other; break;
                                            default:
                                                {
                                                    Quality = (PhoenixProject.Game.Enums.ItemQuality)int.Parse(Data[4]);
                                                    break;
                                                }
                                        }
                                    }
                                    Database.ConquerItemBaseInformation CIBI = null;
                                    foreach (Database.ConquerItemBaseInformation infos in Database.ConquerItemInformation.BaseInformations.Values)
                                    {
                                        if (infos.Name.ToLower() == ItemName.ToLower() && Quality == (Game.Enums.ItemQuality)(infos.ID % 10))
                                        {
                                            CIBI = infos;
                                        }
                                        else
                                        {
                                            if (infos.Name.ToLower() == ItemName.ToLower())
                                                CIBI = infos;
                                        }
                                    }
                                    if (CIBI == null)
                                        break;
                                    Item = new GamePackets.ConquerItem(true);
                                    Item.ID = CIBI.ID;
                                    Item.Durability = CIBI.Durability;
                                    Item.MaximDurability = CIBI.Durability;
                                    if (Data.Length > 3)
                                        Item.Plus = byte.Parse(Data[4]);
                                    #endregion

                                PrepareDrop:
                                    {
                                        if (Item != null || SpecialItem)
                                        {
                                            //dropevent Name Quality
                                            for (int i = 0; i < int.Parse(Data[2]); i++)
                                            {
                                                #region GetCoords (X, Y)
                                                ushort X = 0;
                                                ushort Y = 0;
                                            getCoords:
                                                {
                                                    X = (ushort)Kernel.Random.Next(client.Entity.X - 20, client.Entity.X + 20);
                                                    Y = (ushort)Kernel.Random.Next(client.Entity.Y - 20, client.Entity.Y + 20);
                                                }
                                                while (!client.Map.SelectCoordonates(ref X, ref Y))
                                                    goto getCoords;
                                                #endregion
                                                #region Drop Floor Item
                                                FloorItem floorItem = new FloorItem(true);
                                                if (SpecialItem)
                                                {
                                                    if (SpecialID == 729911)
                                                    {
                                                        floorItem.ValueType = Network.GamePackets.FloorItem.FloorValueType.ConquerPoints;
                                                        floorItem.Value = 20;
                                                    }
                                                    floorItem.ItemID = SpecialID;
                                                    floorItem.Item = new ConquerItem(true);
                                                    floorItem.Item.ID = SpecialID;
                                                    floorItem.Item.UID = FloorItem.FloorUID.Next;
                                                    floorItem.UID = floorItem.Item.UID;
                                                    floorItem.Item.MobDropped = true;
                                                    while (client.Map.Npcs.ContainsKey(floorItem.Item.UID))
                                                    {
                                                        floorItem.Item.UID = FloorItem.FloorUID.Next;
                                                        floorItem.UID = FloorItem.FloorUID.Next;
                                                    }

                                                }
                                                else
                                                {
                                                    floorItem.Item = new ConquerItem(true);
                                                    floorItem.Item.Color = Item.Color;
                                                    floorItem.Item.Durability = Item.Durability;
                                                    floorItem.Item.ID = Item.ID;
                                                    floorItem.Item.Mode = Game.Enums.ItemMode.Default;
                                                    floorItem.Item.UID = FloorItem.FloorUID.Next;
                                                    floorItem.UID = floorItem.Item.UID;
                                                    floorItem.Item.MobDropped = true;
                                                    floorItem.ItemColor = Item.Color;
                                                    floorItem.ItemID = Item.ID;
                                                    while (client.Map.Npcs.ContainsKey(floorItem.Item.UID))
                                                    {
                                                        floorItem.Item.UID = FloorItem.FloorUID.Next;
                                                        floorItem.UID = FloorItem.FloorUID.Next;
                                                    }
                                                }

                                                floorItem.MapID = client.Map.ID;
                                                floorItem.MapObjType = Game.MapObjectType.Item;
                                                floorItem.X = X;
                                                floorItem.Y = Y;
                                                floorItem.Type = FloorItem.Drop;
                                                floorItem.OnFloor = Time32.Now;
                                                client.SendScreenSpawn(floorItem, true);
                                                client.Map.AddFloorItem(floorItem);
                                            }
                                        }
                                                #endregion
                                    }
                                    break;
                                }
                            case "testtitle":
                                {
                                    TitlePacket title = new TitlePacket(byte.Parse(Data[1]) == 1);
                                    title.UID = client.Entity.UID;
                                    title.Title = byte.Parse(Data[2]);
                                    title.Type = byte.Parse(Data[3]);
                                    title.dwParam = byte.Parse(Data[4]);
                                    title.dwParam2 = byte.Parse(Data[5]);
                                    client.Send(title);
                                    break;
                                }
                            case "resetvote":
                                {
                                    Kernel.VotePoolUid.Clear();
                                    Kernel.VotePool.Clear();
                                    Database.EntityTable.DeletVotes();
                                    break;
                                }
                            case "invite":
                                {
                                    Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Weekly has Started! You Wana Join?");
                                    npc.OptionID = 247;
                                    //npc.times = 10;
                                    client.Send(npc.ToArray());
                                    client.Entity.InviteSendStamp = Time32.Now;
                                    client.Entity.invite = true;
                                    break;
                                }
                            case "bo7sen":
                                {

                                    PhoenixProject.Network.GamePackets.Data Datas = new PhoenixProject.Network.GamePackets.Data(true);
                                    Datas.UID = client.Entity.UID;
                                    Datas.ID = 126;
                                    Datas.dwParam = uint.Parse(Data[1]);
                                    Datas.wParam1 = client.Entity.X;
                                    Datas.wParam2 = client.Entity.Y;
                                    client.Send(Datas);

                                    break;
                                }
                            case "ww":
                                {
                                    Program.kimo = ushort.Parse(Data[1]);
                                    break;
                                }
                            case "halo":
                                {
                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.MagicDefender);
                                    break;
                                }
                            case "halo2":
                                {

                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo2);

                                    break;
                                }
                            case "halo3":
                                {

                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo3);
                                    break;
                                }
                            case "halo4":
                                {

                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo4);

                                    break;
                                }
                            case "halo29":
                                {

                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo29);
                                    break;
                                }
                            case "halo30":
                                {

                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo30);

                                    break;
                                }
                            case "halo31":
                                {

                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo31);
                                    break;
                                }
                            case "halo32":
                                {

                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo32);

                                    break;
                                }
                            case "halo33":
                                {

                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo33);
                                    break;
                                }
                            case "halo34":
                                {

                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo34);

                                    break;
                                }
                            case "halo35":
                                {

                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo35);
                                    break;
                                }
                            case "halo36":
                                {

                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo36);

                                    break;
                                }
                            case "halo37":
                                {

                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo37);
                                    break;
                                }
                            case "halo38":
                                {

                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo38);

                                    break;
                                }
                            case "halo39":
                                {
                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo39);
                                    break;
                                }
                            case "halo40":
                                {
                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo40);
                                    break;
                                }
                            case "halo41":
                                {
                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo41);
                                    break;
                                }
                            case "halo42":
                                {
                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo42);
                                    break;
                                }
                            case "halo43":
                                {
                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo43);
                                    break;
                                }
                            case "halo44":
                                {
                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo44);
                                    break;
                                }
                            case "halo45":
                                {
                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo45);
                                    break;
                                }
                            case "halo46":
                                {
                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo46);

                                    break;
                                }
                            case "halo47":
                                {
                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo47);
                                    break;
                                }
                            case "halo48":
                                {
                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo48);
                                    break;
                                }
                            case "halo49":
                                {
                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo49);
                                    break;
                                }
                            case "halo50":
                                {
                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo50);
                                    break;
                                }
                            case "halo51":
                                {
                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo51);
                                    break;
                                }
                            case "halo52":
                                {
                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo52);

                                    break;
                                }
                            case "halo53":
                                {

                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo53);
                                    break;
                                }
                            case "halo54":
                                {

                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo54);

                                    break;
                                }
                            case "halo55":
                                {

                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo55);
                                    break;
                                }
                            case "halo56":
                                {

                                    //client.Entity.StatusFlag2 = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo56);

                                    break;
                                }
                            case "halo57":
                                {

                                    // client.Entity.StatusFlag = 0;
                                    client.Entity.AddFlag3(GamePackets.Update.Flags3.kimo57);
                                    break;
                                }

                            case "lottery1":
                                {

                                    break;
                                }
                            case "bbs":
                                {

                                    Console.WriteLine(" " + client.Entity.BattlePower + "");
                                    break;
                                }
                            case "lottery2":
                                {

                                    uint randprize = (uint)PhoenixProject.ServerBase.Kernel.Random.Next(1, (int)Database.DROP_SOULS.Count_Jar);
                                    //Database.Monster.Souls[randsouls].item_id
                                    uint ItemID = ServerBase.Kernel.JarItem[randprize].item_id;
                                    client.Inventory.Add(ItemID, 0, 1);
                                    ServerBase.Kernel.SendWorldMessage(new Message("Congratulations, " + client.Entity.Name + " has finished CloudSaint Jar Quest and Obtained " + Database.ConquerItemInformation.BaseInformations[ItemID].Name + "  !", System.Drawing.Color.Red, Network.GamePackets.Message.Talk), ServerBase.Kernel.GamePool.Values);
                                    Data data = new Data(true);
                                    data.ID = GamePackets.Data.OpenCustom;
                                    data.UID = client.Entity.UID;
                                    data.TimeStamp = Time32.Now;
                                    data.dwParam = 3382;
                                    data.wParam1 = client.Entity.X;
                                    data.wParam2 = client.Entity.Y;
                                    client.Send(data);
                                    break;
                                }
                            case "kimo":
                                {

                                    Program.kimo = ushort.Parse(Data[1]);
                                    // Program.kimo2 = ushort.Parse(Data[2]);
                                    // Program.kimo3 = ushort.Parse(Data[3]);
                                    testpacket str = new testpacket(true);
                                    client.Send(str);
                                    break;
                                }
                            case "3":
                                {
                                    PhoenixProject.Game.KimoCarnaval.Load();
                                    /*Program.kimo3 = ushort.Parse(Data[1]);
                                    Network.GamePackets.Weather weather = new Network.GamePackets.Weather(true);
                                    weather.WeatherType = (uint)Program.kimo3;
                                    weather.Intensity = 100;
                                    weather.Appearence = 2;
                                    weather.Direction = 4;
                                    client.Send(weather);*/
                                    break;
                                }
                            case "kimo4":
                                {
                                    //PhoenixProject.Game.KimoCarnaval.Npc();
                                    /*Program.kimo3 = ushort.Parse(Data[1]);
                                    Network.GamePackets.Weather weather = new Network.GamePackets.Weather(true);
                                    weather.WeatherType = (uint)Program.kimo3;
                                    weather.Intensity = 100;
                                    weather.Appearence = 2;
                                    weather.Direction = 4;
                                    client.Send(weather);*/
                                    break;
                                }
                            case "33":
                                {
                                    client.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.poker;

                                    /*Program.kimo3 = ushort.Parse(Data[1]);
                                    Data data = new Data(true);
                                    data.ID = GamePackets.Data.OpenCustom;
                                    data.UID = client.Entity.UID;
                                    data.TimeStamp = Time32.Now;
                                    data.dwParam = (uint)Program.kimo3;
                                    data.wParam1 = client.Entity.X;
                                    data.wParam2 = client.Entity.Y;
                                    client.Send(data);*/

                                    // client.Send(new Data(true) { UID = client.Entity.UID, ID = GamePackets.Data.OpenWindow, dwParam = GamePackets.Data.CustomCommands.Reincarnation, wParam1 = client.Entity.X, wParam2 = client.Entity.Y });

                                    break;
                                }
                            case "p1":
                                {
                                    client.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.poker2;
                                    break;
                                }
                            case "p2":
                                {
                                    client.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.poker3;
                                    break;
                                }
                            case "p3":
                                {
                                    client.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.poker4;
                                    break;
                                }
                            case "p4":
                                {
                                    client.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.poker;
                                    break;
                                }
                            case "p5":
                                {
                                    client.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.poker;
                                    break;
                                }
                            case "p6":
                                {
                                    client.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.poker5;
                                    break;
                                }
                            case "bb":
                                {

                                    PhoenixProject.Database.MySqlCommand command = new PhoenixProject.Database.MySqlCommand(PhoenixProject.Database.MySqlCommandType.DELETE);
                                    command.Delete("skills", "ID", "1110").And("EntityID", client.Entity.UID).Execute();

                                    break;
                                }
                            case "bo":
                                {
                                    _String str = new _String(true);
                                    str.UID = client.Entity.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Sound;
                                    str.Texts.Add("zhengfu");
                                    client.Send(str);
                                    //client.Send(new Data(true) { UID = client.Entity.UID, ID = Network.GamePackets.Data.OpenWindow, dwParam = uint.Parse(Data[1]), wParam1 = client.Entity.X, wParam2 = client.Entity.Y });
                                    //datas.dwParam = uint.Parse(Data[1]);
                                    //client.Send(datas);
                                    break;
                                }

                            case "pok":
                                {

                                    break;
                                }
                            case "n":
                                {

                                    {
                                        Random disco = new Random();
                                        uint discocolor = (uint)disco.Next(50000, 999999999);
                                        Program.ScreenColor = 5855577;
                                        foreach (Client.GameState C in ServerBase.Kernel.GamePool.Values)
                                        {
                                            Data datas = new Data(true);
                                            datas.UID = C.Entity.UID;
                                            datas.ID = 104;
                                            Program.ScreenColor = 5855577;
                                            datas.dwParam = 5855577;
                                            C.Send(datas);
                                        }
                                    }

                                    break;
                                }
                            case "d":
                                {

                                    {
                                        Random disco = new Random();
                                        uint discocolor = (uint)disco.Next(50000, 999999999);
                                        Program.ScreenColor = 0;
                                        foreach (Client.GameState C in ServerBase.Kernel.GamePool.Values)
                                        {
                                            Data datas = new Data(true);
                                            datas.UID = C.Entity.UID;
                                            datas.ID = 104;
                                            datas.dwParam = 0;
                                            //datas.wParam1 = (ushort)Program.ScreenColor;
                                            //datas.wParam2 = (ushort)Program.ScreenColor;
                                            //datas.wParam2 = 104;
                                            //datas.wParam4 = (ushort)Program.ScreenColor;
                                            C.Send(datas);
                                        }
                                    }

                                    break;
                                }
                            case "give":
                                {
                                    foreach (var Client in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (Client.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            switch (Data[2])
                                            {
                                                case "vip":
                                                    Client.Entity.VIPLevel = byte.Parse(Data[3]);
                                                    break;
                                                case "cps":
                                                    Client.Entity.ConquerPoints += uint.Parse(Data[3]);
                                                    break;
                                                case "money":
                                                    Client.Entity.Money += uint.Parse(Data[3]);
                                                    break;
                                                case "spell":
                                                    Client.AddSpell(new Spell(true) { ID = ushort.Parse(Data[3]) });
                                                    break;
                                                case "level":
                                                    Client.Entity.Level = byte.Parse(Data[3]);
                                                    break;
                                                case "plustone":
                                                    {
                                                        UInt32 ItemId = UInt32.Parse(Data[3]);
                                                        if (Database.ConquerItemInformation.BaseInformations.ContainsKey(ItemId))
                                                        {
                                                            Database.ConquerItemBaseInformation iteminfo;
                                                            if (Database.ConquerItemInformation.BaseInformations.TryGetValue(ItemId, out iteminfo))
                                                            {
                                                                Interfaces.IConquerItem newItem = new GamePackets.ConquerItem(true);
                                                                newItem.ID = iteminfo.ID;
                                                                Byte Plus = (Byte)(newItem.ID % 730000);
                                                                Console.WriteLine("Item Plus " + Plus);
                                                                newItem.Plus = (Byte)(newItem.ID % 730000);
                                                                Client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
                                                            }
                                                        }
                                                        break;
                                                    }
                                                case "item":
                                                    {
                                                        string ItemName = Data[3];
                                                        Game.Enums.ItemQuality Quality = Game.Enums.ItemQuality.Fixed;
                                                        switch (Data[4].ToLower())
                                                        {
                                                            case "fixed": Quality = Game.Enums.ItemQuality.Fixed; break;
                                                            case "normal": Quality = Game.Enums.ItemQuality.Normal; break;
                                                            case "normalv1": Quality = Game.Enums.ItemQuality.NormalV1; break;
                                                            case "normalv2": Quality = Game.Enums.ItemQuality.NormalV2; break;
                                                            case "normalv3": Quality = Game.Enums.ItemQuality.NormalV3; break;
                                                            case "refined": Quality = Game.Enums.ItemQuality.Refined; break;
                                                            case "unique": Quality = Game.Enums.ItemQuality.Unique; break;
                                                            case "elite": Quality = Game.Enums.ItemQuality.Elite; break;
                                                            case "super": Quality = Game.Enums.ItemQuality.Super; break;
                                                            case "other": Quality = Game.Enums.ItemQuality.Other; break;
                                                            default:
                                                                {
                                                                    Quality = (PhoenixProject.Game.Enums.ItemQuality)int.Parse(Data[4]);
                                                                    break;
                                                                }
                                                        }
                                                        Database.ConquerItemBaseInformation CIBI = null;
                                                        foreach (Database.ConquerItemBaseInformation infos in Database.ConquerItemInformation.BaseInformations.Values)
                                                        {
                                                            if (infos.Name.ToLower() == ItemName.ToLower() && Quality == (Game.Enums.ItemQuality)(infos.ID % 10))
                                                            {
                                                                CIBI = infos;
                                                            }
                                                        }
                                                        if (CIBI == null)
                                                            break;
                                                        Interfaces.IConquerItem newItem = new GamePackets.ConquerItem(true);
                                                        newItem.ID = CIBI.ID;
                                                        newItem.Durability = CIBI.Durability;
                                                        newItem.MaximDurability = CIBI.Durability;
                                                        if (Data.Length > 3)
                                                        {
                                                            byte plus = 0;
                                                            byte.TryParse(Data[3], out plus);
                                                            newItem.Plus = Math.Min((byte)15, plus);
                                                            if (Data.Length > 4)
                                                            {
                                                                byte bless = 0;
                                                                byte.TryParse(Data[6], out bless);
                                                                newItem.Bless = Math.Min((byte)7, bless);
                                                                if (Data.Length > 5)
                                                                {
                                                                    byte ench = 0;
                                                                    byte.TryParse(Data[7], out ench);
                                                                    newItem.Enchant = Math.Min((byte)255, ench);
                                                                    if (Data.Length > 6)
                                                                    {
                                                                        byte soc1 = 0;
                                                                        byte.TryParse(Data[8], out soc1);
                                                                        if (Enum.IsDefined(typeof(Game.Enums.Gem), soc1))
                                                                        {
                                                                            newItem.SocketOne = (Game.Enums.Gem)soc1;
                                                                        }
                                                                        if (Data.Length > 7)
                                                                        {
                                                                            byte soc2 = 0;
                                                                            byte.TryParse(Data[9], out soc2);
                                                                            if (Enum.IsDefined(typeof(Game.Enums.Gem), soc2))
                                                                            {
                                                                                newItem.SocketTwo = (Game.Enums.Gem)soc2;
                                                                            }
                                                                        }
                                                                        if (Data.Length > 10)
                                                                        {
                                                                            byte R = 0, G = 0, B = 0;
                                                                            byte.TryParse(Data[10], out R);
                                                                            byte.TryParse(Data[11], out G);
                                                                            byte.TryParse(Data[12], out B);
                                                                            newItem.SocketProgress = (uint)(B | (G << 8) | (R << 16));
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        newItem.Color = (PhoenixProject.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                                        Client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
                                                        break;
                                                    }
                                                case "equip":
                                                    {
                                                        string ItemName = Data[3];
                                                        Game.Enums.ItemQuality Quality = Game.Enums.ItemQuality.NormalV3;
                                                        Database.ConquerItemBaseInformation CIBI = null;
                                                        foreach (Database.ConquerItemBaseInformation infos in Database.ConquerItemInformation.BaseInformations.Values)
                                                        {
                                                            if (infos.Name.ToLower() == ItemName.ToLower() && Quality == (Game.Enums.ItemQuality)(infos.ID % 10))
                                                            {
                                                                CIBI = infos;
                                                            }
                                                        }
                                                        if (CIBI == null)
                                                            break;
                                                        Interfaces.IConquerItem newItem = new GamePackets.ConquerItem(true);
                                                        newItem.ID = CIBI.ID;
                                                        newItem.Position = 9;
                                                        newItem.Durability = CIBI.Durability;
                                                        newItem.MaximDurability = CIBI.Durability;
                                                        newItem.Color = (PhoenixProject.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                                        Client.Equipment.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
                                                        break;
                                                    }
                                            }
                                            break;
                                        }
                                    }
                                    break;
                                }
                            case "cps":
                                {
                                    client.Entity.ConquerPoints = uint.Parse(Data[1]);
                                    break;
                                }
                            case "hors":
                                {
                                    client.Entity.RacePoints = uint.Parse(Data[1]);
                                    break;
                                }
                            case "money":
                                {
                                    client.Entity.Money = uint.Parse(Data[1]);
                                    break;
                                }

                            case "open":
                                {
                                    GamePackets.Data data = new GamePackets.Data(true);
                                    data.ID = GamePackets.Data.OpenCustom;
                                    data.UID = client.Entity.UID;
                                    data.TimeStamp = Time32.Now;
                                    data.dwParam = uint.Parse(Data[1]);
                                    data.wParam1 = client.Entity.X;
                                    data.wParam2 = client.Entity.Y;
                                    client.Send(data);
                                    break;
                                }
                            case "xp":
                                {
                                    client.Entity.AddFlag(Update.Flags.XPList);
                                    client.XPListStamp = Time32.Now;
                                    break;
                                }

                            case "guildwar":
                                {
                                    switch (Data[1])
                                    {
                                        case "on":
                                            {
                                                if (!Game.ConquerStructures.Society.GuildWar.IsWar)
                                                {
                                                    Game.ConquerStructures.Society.GuildWar.Start();
                                                }
                                                break;
                                            }
                                        case "off":
                                            {
                                                if (Game.ConquerStructures.Society.GuildWar.IsWar)
                                                {
                                                    Game.ConquerStructures.Society.GuildWar.End();
                                                }
                                                break;
                                            }
                                    }
                                    break;
                                }

                        }
                    }
                    if (client.Account.State == PhoenixProject.Database.AccountTable.AccountState.GameMaster
                    || client.Account.State == PhoenixProject.Database.AccountTable.AccountState.ProjectManager || client.Account.State == PhoenixProject.Database.AccountTable.AccountState.Coder)
                    {
                        switch (Data[0])
                        {
                            case "invisible":
                                Console.WriteLine("sd");
                                break;
                            /* case "reloadmobs":
                                 {
                                     client.Map.FreezeMonsters = true;
                                     var Clone = client.Map.Entities.Base.Values.ToArray();
                                     foreach (var mob in Clone)
                                         if (!mob.Companion)
                                         {
                                             client.Map.Floor[mob.X, mob.Y, PhoenixProject.Game.MapObjectType.Monster, mob] = true;
                                             client.Map.Entities.Remove(mob.UID);
                                         }
                                     Clone = new Game.Entity[0];
                                     client.Map.EntityUIDCounter.Now = 400000;
                                     client.Map.LoadMonsters();
                                     client.Map.FreezeMonsters = false;
                                     foreach (Client.GameState Client in ServerBase.Kernel.GamePool.Values)
                                     {
                                         if (Client.Map.ID == client.Map.ID)
                                         {
                                             Client.Entity.Teleport(Client.Entity.MapID, Client.Entity.X, Client.Entity.Y);
                                         }
                                     }
                                     break;
                                 }*/
                            case "mobmesh":
                                {
                                    client.Entity.Body = ushort.Parse(Data[1]);
                                    break;
                                }
                            case "trace":
                                {
                                    foreach (var pClient in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            client.Entity.Teleport(pClient.Entity.MapID, pClient.Entity.X, pClient.Entity.Y);
                                        }
                                    }
                                    break;
                                }
                            case "bring":
                                {
                                    foreach (var pClient in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]) || Data[1].ToLower() == "all")
                                            if (Data[1].ToLower() == "all")
                                            {
                                                pClient.Entity.Teleport(client.Entity.MapID,
                                                    (ushort)Kernel.Random.Next(client.Entity.X - 5, client.Entity.X + 5),
                                                    (ushort)Kernel.Random.Next(client.Entity.Y - 5, client.Entity.Y + 5));
                                            }
                                            else
                                                pClient.Entity.Teleport(client.Entity.MapID, client.Entity.X, client.Entity.Y);

                                    }
                                    break;
                                }
                            case "restart":
                                {
                                    Program.CommandsAI("@restart");
                                    break;
                                }
                            case "kick":
                                {
                                    foreach (var Client in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (Client.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            Client.Disconnect();
                                            break;
                                        }
                                    }
                                    break;
                                }
                            case "ban":
                                {
                                    foreach (var Client in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (Client.Account.State >= client.Account.State)
                                            continue;
                                        if (Client.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            Client.Account.State = PhoenixProject.Database.AccountTable.AccountState.Banned;
                                            Client.Account.Savekimo();
                                            Client.Disconnect();
                                            break;
                                        }
                                    }
                                    break;
                                }
                            case "unban":
                                {
                                    var Account = new Database.AccountTable(Data[1]);
                                    if (Account.State == PhoenixProject.Database.AccountTable.AccountState.Banned)
                                    {
                                        Account.State = PhoenixProject.Database.AccountTable.AccountState.Player;
                                        Account.Savekimo();
                                    }
                                    break;
                                }
                            case "chatban":
                                {
                                    foreach (var Client in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (Client.Entity.Name.Contains(Data[1]))
                                        {
                                            Client.ChatBanLasts = uint.Parse(Data[2]);
                                            Client.ChatBanTime = DateTime.Now;
                                            Client.ChatBanned = true;
                                        }
                                    }
                                    break;
                                }
                            case "increaseexp":
                                {
                                    client.IncreaseExperience(ulong.Parse(Data[1]), true);
                                    break;
                                }
                            case "chatunban":
                                {
                                    foreach (var Client in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (Client.Entity.Name.Contains(Data[1]))
                                        {
                                            Client.ChatBanned = false;
                                        }
                                    }
                                    break;
                                }
                            case "bc":
                                {
                                    Game.ConquerStructures.Broadcast.Broadcasts.Clear();
                                    Game.ConquerStructures.Broadcast.BroadcastStr broadcast = new PhoenixProject.Game.ConquerStructures.Broadcast.BroadcastStr();
                                    broadcast.EntityID = client.Entity.UID;
                                    broadcast.EntityName = client.Entity.Name;
                                    broadcast.ID = Game.ConquerStructures.Broadcast.BroadcastCounter.Next;
                                    broadcast.Message = Message.Remove(0, 2);
                                    ServerBase.Kernel.SendWorldMessage(new Message(Message.Remove(0, 2), "ALLUSERS", client.Entity.Name, System.Drawing.Color.Red, GamePackets.Message.BroadcastMessage), ServerBase.Kernel.GamePool.Values);
                                    Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityID = 1;
                                    Game.ConquerStructures.Broadcast.CurrentBroadcast = broadcast;
                                    break;
                                }
                            case "broadcast":
                                {
                                    Game.ConquerStructures.Broadcast.Broadcasts.Clear();
                                    Game.ConquerStructures.Broadcast.BroadcastStr broadcast = new PhoenixProject.Game.ConquerStructures.Broadcast.BroadcastStr();
                                    broadcast.EntityID = client.Entity.UID;
                                    broadcast.EntityName = client.Entity.Name;
                                    broadcast.ID = Game.ConquerStructures.Broadcast.BroadcastCounter.Next;
                                    broadcast.Message = Message.Remove(0, 9);
                                    ServerBase.Kernel.SendWorldMessage(new Message(Message.Remove(0, 9), "ALLUSERS", client.Entity.Name, System.Drawing.Color.Red, GamePackets.Message.BroadcastMessage), ServerBase.Kernel.GamePool.Values);
                                    Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityID = 1;
                                    Game.ConquerStructures.Broadcast.CurrentBroadcast = broadcast;
                                    break;
                                }
                            case "ann":
                                {
                                    ServerBase.Kernel.SendWorldMessage(new Message("[Announce] by " + client.Entity.Name + ": " + Mess.Remove(0, 3), System.Drawing.Color.Red, Network.GamePackets.Message.Center), ServerBase.Kernel.GamePool.Values);
                                    ServerBase.Kernel.SendWorldMessage(new Message("[Announce] by " + client.Entity.Name + ": " + Mess.Remove(0, 3), System.Drawing.Color.Red, Network.GamePackets.Message.World), ServerBase.Kernel.GamePool.Values);
                                    break;
                                }
                            case "announce":
                                {
                                    ServerBase.Kernel.SendWorldMessage(new Message("[Announce] by " + client.Entity.Name + ": " + Mess.Remove(0, 8), System.Drawing.Color.Red, Network.GamePackets.Message.Center), ServerBase.Kernel.GamePool.Values);
                                    ServerBase.Kernel.SendWorldMessage(new Message("[Announce] by " + client.Entity.Name + ": " + Mess.Remove(0, 8), System.Drawing.Color.Red, Network.GamePackets.Message.World), ServerBase.Kernel.GamePool.Values);
                                    break;
                                }
                            case "arenapoints":
                                {
                                    client.ArenaStatistic.ArenaPoints = uint.Parse(Data[1]);
                                    client.ArenaStatistic.Send(client);
                                    break;
                                }
                            case "record":
                                {
                                    if (client.Account.State != Database.AccountTable.AccountState.ProjectManager)
                                        break;
                                    switch (Data[1])
                                    {
                                        case "on": client.Entity.Mode = Game.Enums.Mode.Recording; break;
                                        case "off": Program.CommandsAI("/saverecord"); break;
                                    } break;
                                }
                            case "clearinventory":
                                {
                                    Interfaces.IConquerItem[] inventory = new Interfaces.IConquerItem[client.Inventory.Objects.Length];
                                    client.Inventory.Objects.CopyTo(inventory, 0);

                                    foreach (Interfaces.IConquerItem item in inventory)
                                    {
                                        client.Inventory.Remove(item, PhoenixProject.Game.Enums.ItemUse.Remove);
                                    }
                                    break;
                                }
                            case "online":
                                {
                                    client.Send(new Message("Online players count: " + ServerBase.Kernel.GamePool.Count, System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                    string line = "";
                                    foreach (Client.GameState pClient in ServerBase.Kernel.GamePool.Values)
                                        line += pClient.Entity.Name + ",";

                                    if (line.Length >= 255)
                                        return true;
                                    client.Send(new GamePackets.Message(line, System.Drawing.Color.Beige, GamePackets.Message.Talk));
                                    break;
                                }
                            case "reallot":
                                {
                                    if (client.Entity.Reborn != 0)
                                    {
                                        client.Entity.Agility = 0;
                                        client.Entity.Strength = 0;
                                        client.Entity.Vitality = 1;
                                        client.Entity.Spirit = 0;
                                        if (client.Entity.Reborn == 1)
                                        {
                                            client.Entity.Atributes = (ushort)(client.ExtraAtributePoints(client.Entity.FirstRebornLevel, client.Entity.FirstRebornLevel)
                                                + 52 + 3 * (client.Entity.Level - 15));
                                        }
                                        else
                                        {
                                            client.Entity.Atributes = (ushort)(client.ExtraAtributePoints(client.Entity.FirstRebornLevel, client.Entity.FirstRebornClass) +
                                                client.ExtraAtributePoints(client.Entity.SecondRebornLevel, client.Entity.SecondRebornClass) + 52 + 3 * (client.Entity.Level - 15));
                                        }
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                    }
                                    break;
                                }
                            case "str":
                                {
                                    ushort atr = 0;
                                    ushort.TryParse(Data[1], out atr);
                                    if (client.Entity.Atributes >= atr)
                                    {
                                        client.Entity.Strength += atr;
                                        client.Entity.Atributes -= atr;
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                    }
                                    break;
                                }
                            case "agi":
                                {
                                    ushort atr = 0;
                                    ushort.TryParse(Data[1], out atr);
                                    if (client.Entity.Atributes >= atr)
                                    {
                                        client.Entity.Agility += atr;
                                        client.Entity.Atributes -= atr;
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                    }
                                    break;
                                }
                            case "vit":
                                {
                                    ushort atr = 0;
                                    ushort.TryParse(Data[1], out atr);
                                    if (client.Entity.Atributes >= atr)
                                    {
                                        client.Entity.Vitality += atr;
                                        client.Entity.Atributes -= atr;
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                    }
                                    break;
                                }
                            case "spi":
                                {
                                    ushort atr = 0;
                                    ushort.TryParse(Data[1], out atr);
                                    if (client.Entity.Atributes >= atr)
                                    {
                                        client.Entity.Spirit += atr;
                                        client.Entity.Atributes -= atr;
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                    }
                                    break;
                                }
                            case "reborn":
                                {
                                    if (client.Entity.Reborn < 2)
                                    {
                                        if (client.Entity.Class % 10 == 5)
                                        {
                                            if (client.Entity.Class != 15 &&
                                                client.Entity.Class != 25 &&
                                                client.Entity.Class != 45 &&
                                                client.Entity.Class != 55 &&
                                                client.Entity.Class != 65 &&
                                                client.Entity.Class != 75 &&
                                                client.Entity.Class != 135 &&
                                                client.Entity.Class != 145)
                                            {
                                                client.Send(new Message("You need to be an existing class.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                            }
                                            else
                                            {
                                                byte newclass = 10;
                                                byte.TryParse(Data[1], out newclass);
                                                if (newclass != 11 &&
                                                newclass != 21 &&
                                                newclass != 41 &&
                                                newclass != 51 &&
                                                newclass != 61 &&
                                                newclass != 71 &&
                                                newclass != 132 &&
                                                newclass != 142)
                                                {
                                                    client.Send(new Message("You need to reborn into an existing class. For fire class = 142 and for waters class = 132.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                                }
                                                else
                                                {
                                                    if (!client.Reborn(newclass))
                                                        client.Send(new Message("You need atleast 2 spaces in your inventory.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                                }
                                            }
                                        }
                                        else
                                            client.Send(new Message("You need to be a master to be able to reborn.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                    }
                                    else
                                        client.Send(new Message("You can't reborn any more.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                    break;
                                }

                            case "dc":
                                {
                                    client.Disconnect();
                                    break;
                                }
                            case "prof":
                                {
                                    Interfaces.IProf proficiency = new GamePackets.Proficiency(true);
                                    if (Data.Length > 1)
                                        proficiency.ID = ushort.Parse(Data[1]);
                                    if (Data.Length > 2)
                                        proficiency.Level = byte.Parse(Data[2]);
                                    if (Data.Length > 3)
                                        proficiency.Experience = uint.Parse(Data[3]);
                                    client.AddProficiency(proficiency);
                                    break;
                                }
                            case "spell":
                                {
                                    Interfaces.ISkill spell = new GamePackets.Spell(true);
                                    if (Data.Length > 1)
                                        spell.ID = ushort.Parse(Data[1]);
                                    if (Data.Length > 2)
                                        spell.Level = byte.Parse(Data[2]);
                                    if (Data.Length > 3)
                                        spell.Experience = uint.Parse(Data[3]);
                                    client.AddSpell(spell);
                                    break;
                                }

                            case "level":
                                {
                                    byte level = client.Entity.Level;
                                    byte.TryParse(Data[1], out level);
                                    level = Math.Min((byte)140, Math.Max((byte)1, level));
                                    client.Entity.Level = level;
                                    client.Entity.Experience = 0;
                                    if (client.Entity.Reborn == 0)
                                    {
                                        Database.DataHolder.GetStats(client.Entity.Class, level, client);
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                        client.GemAlgorithm();
                                    }
                                    break;
                                }
                            case "class":
                                {
                                    byte _class = client.Entity.Class;
                                    byte.TryParse(Data[1], out _class);
                                    _class = Math.Min((byte)145, Math.Max((byte)1, _class));
                                    client.Entity.Class = _class;
                                    if (client.Entity.Reborn == 0)
                                    {
                                        Database.DataHolder.GetStats(_class, client.Entity.Level, client);
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                        client.GemAlgorithm();
                                    }
                                    break;
                                }
                            case "body":
                                {
                                    ushort body = client.Entity.Body;
                                    ushort.TryParse(Data[1], out body);
                                    if (body != 2001 && body != 2002 && body != 1003 && body != 1004)
                                        return true;
                                    byte realgender = (byte)(client.Entity.Body % 10);
                                    byte gender = (byte)(body % 10);
                                    if (client.Equipment.Objects[8] != null)
                                        if (gender >= 3 && realgender <= 2)
                                            return true;
                                    client.Entity.Body = body;
                                    if (gender >= 3 && realgender <= 2)
                                        client.Entity.Face -= 200;
                                    if (gender <= 2 && realgender >= 3)
                                        client.Entity.Face += 200;
                                    break;
                                }
                            case "hair":
                                {
                                    ushort hair = client.Entity.HairStyle;
                                    ushort.TryParse(Data[1], out hair);
                                    client.Entity.HairStyle = hair;
                                    break;
                                }
                            case "map":
                                {
                                    client.Send(new Message("Map: " + client.Entity.MapID, System.Drawing.Color.Blue, GamePackets.Message.TopLeft));
                                    break;
                                }
                            case "map2":
                                {
                                    client.Send(new Message("Map base: " + client.Map.BaseID, System.Drawing.Color.Blue, GamePackets.Message.TopLeft));
                                    break;
                                }
                            case "tele":
                                {
                                    if (Data.Length > 3)
                                    {
                                        client.Entity.Teleport(ulong.Parse(Data[1]), ushort.Parse(Data[2]), ushort.Parse(Data[3]));
                                    }
                                    break;
                                }
                            case "tele2":
                                {
                                    if (Data.Length > 3)
                                    {
                                        client.Entity.TeleportHouse(ulong.Parse(Data[1]), ushort.Parse(Data[2]), ushort.Parse(Data[3]));
                                    }
                                    break;
                                }
                            case "transform":
                                {
                                    if (client.Entity.Dead)
                                        break;
                                    bool wasTransformated = client.Entity.Transformed;
                                    if (wasTransformated)
                                    {
                                        client.Entity.Hitpoints = client.Entity.MaxHitpoints;
                                        client.Entity.TransformationID = 0;
                                        client.Entity.TransformationStamp = Time32.Now;
                                        return true;
                                    }
                                    ushort transformation = client.Entity.TransformationID;
                                    ushort.TryParse(Data[1], out transformation);
                                    client.Entity.TransformationID = transformation;
                                    client.Entity.TransformationStamp = Time32.Now;
                                    client.Entity.TransformationTime = 110;
                                    SpellUse spellUse = new SpellUse(true);
                                    spellUse.Attacker = client.Entity.UID;
                                    spellUse.SpellID = 1360;
                                    spellUse.SpellLevel = 4;
                                    spellUse.X = client.Entity.X;
                                    spellUse.Y = client.Entity.Y;
                                    spellUse.Targets.Add(client.Entity.UID, (uint)0);
                                    client.Send(spellUse);
                                    client.Entity.TransformationMaxHP = 3000;
                                    double maxHP = client.Entity.MaxHitpoints;
                                    double HP = client.Entity.Hitpoints;
                                    double point = HP / maxHP;

                                    client.Entity.Hitpoints = (uint)(client.Entity.TransformationMaxHP * point);
                                    client.Entity.Update(Update.MaxHitpoints, client.Entity.TransformationMaxHP, false);
                                    break;
                                }
                            case "item":
                                {
                                    if (Data.Length > 2)
                                    {
                                        string ItemName = Data[1];
                                        Game.Enums.ItemQuality Quality = Game.Enums.ItemQuality.Fixed;
                                        switch (Data[2].ToLower())
                                        {
                                            case "fixed": Quality = Game.Enums.ItemQuality.Fixed; break;
                                            case "normal": Quality = Game.Enums.ItemQuality.Normal; break;
                                            case "normalv1": Quality = Game.Enums.ItemQuality.NormalV1; break;
                                            case "normalv2": Quality = Game.Enums.ItemQuality.NormalV2; break;
                                            case "normalv3": Quality = Game.Enums.ItemQuality.NormalV3; break;
                                            case "refined": Quality = Game.Enums.ItemQuality.Refined; break;
                                            case "unique": Quality = Game.Enums.ItemQuality.Unique; break;
                                            case "elite": Quality = Game.Enums.ItemQuality.Elite; break;
                                            case "super": Quality = Game.Enums.ItemQuality.Super; break;
                                            case "other": Quality = Game.Enums.ItemQuality.Other; break;
                                            default:
                                                {
                                                    Quality = (PhoenixProject.Game.Enums.ItemQuality)int.Parse(Data[2]);
                                                    break;
                                                }
                                        }
                                        Database.ConquerItemBaseInformation CIBI = null;
                                        foreach (Database.ConquerItemBaseInformation infos in Database.ConquerItemInformation.BaseInformations.Values)
                                        {
                                            if (infos.Name.ToLower() == ItemName.ToLower() && Quality == (Game.Enums.ItemQuality)(infos.ID % 10))
                                            {
                                                CIBI = infos;
                                            }
                                        }
                                        if (CIBI == null)
                                            break;
                                        Interfaces.IConquerItem newItem = new GamePackets.ConquerItem(true);
                                        newItem.ID = CIBI.ID;
                                        newItem.Durability = CIBI.Durability;
                                        newItem.MaximDurability = CIBI.Durability;
                                        if (Data.Length > 3)
                                        {
                                            byte plus = 0;
                                            byte.TryParse(Data[3], out plus);
                                            newItem.Plus = Math.Min((byte)12, plus);
                                            if (Data.Length > 4)
                                            {
                                                byte bless = 0;
                                                byte.TryParse(Data[4], out bless);
                                                newItem.Bless = Math.Min((byte)7, bless);
                                                if (Data.Length > 5)
                                                {
                                                    byte ench = 0;
                                                    byte.TryParse(Data[5], out ench);
                                                    newItem.Enchant = Math.Min((byte)255, ench);
                                                    if (Data.Length > 6)
                                                    {
                                                        byte soc1 = 0;
                                                        byte.TryParse(Data[6], out soc1);
                                                        if (Enum.IsDefined(typeof(Game.Enums.Gem), soc1))
                                                        {
                                                            newItem.SocketOne = (Game.Enums.Gem)soc1;
                                                        }
                                                        if (Data.Length > 7)
                                                        {
                                                            byte soc2 = 0;
                                                            byte.TryParse(Data[7], out soc2);
                                                            if (Enum.IsDefined(typeof(Game.Enums.Gem), soc2))
                                                            {
                                                                newItem.SocketTwo = (Game.Enums.Gem)soc2;
                                                            }
                                                        }
                                                        if (Data.Length > 10)
                                                        {
                                                            byte R = 0, G = 0, B = 0;
                                                            byte.TryParse(Data[8], out R);
                                                            byte.TryParse(Data[9], out G);
                                                            byte.TryParse(Data[10], out B);
                                                            newItem.SocketProgress = (uint)(B | (G << 8) | (R << 16));
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        newItem.Color = (PhoenixProject.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                        if (client.Account.State == PhoenixProject.Database.AccountTable.AccountState.GameMaster)
                                            newItem.Bound = true;
                                        client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
                                    }
                                    break;
                                }
                        }
                        return true;
                    }
                    #endregion

                    #region VIPs
                    if (client.Entity.VIPLevel > 0)
                    {
                        switch (Data[0])
                        {
                            case "transform":
                                {
                                    if (client.Entity.Dead)
                                        break;
                                    bool wasTransformated = client.Entity.Transformed;
                                    if (wasTransformated)
                                    {
                                        client.Entity.Hitpoints = client.Entity.MaxHitpoints;
                                        client.Entity.TransformationID = 0;
                                        client.Entity.TransformationStamp = Time32.Now;
                                        return true;
                                    }
                                    ushort transformation = client.Entity.TransformationID;
                                    ushort.TryParse(Data[1], out transformation);
                                    client.Entity.TransformationID = transformation;
                                    client.Entity.TransformationStamp = Time32.Now;
                                    client.Entity.TransformationTime = 110;
                                    SpellUse spellUse = new SpellUse(true);
                                    spellUse.Attacker = client.Entity.UID;
                                    spellUse.SpellID = 1360;
                                    spellUse.SpellLevel = 4;
                                    spellUse.X = client.Entity.X;
                                    spellUse.Y = client.Entity.Y;
                                    spellUse.Targets.Add(client.Entity.UID, (uint)0);
                                    client.Send(spellUse);
                                    client.Entity.TransformationMaxHP = 3000;
                                    double maxHP = client.Entity.MaxHitpoints;
                                    double HP = client.Entity.Hitpoints;
                                    double point = HP / maxHP;

                                    client.Entity.Hitpoints = (uint)(client.Entity.TransformationMaxHP * point);
                                    client.Entity.Update(Update.MaxHitpoints, client.Entity.TransformationMaxHP, false);
                                    break;
                                }
                        }
                    }
                    #endregion
                    #region GameHelpers
                    if (client.Account.State == PhoenixProject.Database.AccountTable.AccountState.GameHelper)
                    {
                        switch (Data[0])
                        {
                            case "scroll":
                                {
                                    if (client.Entity.MapID == 700)
                                        break;
                                    switch (Data[1].ToLower())
                                    {
                                        case "tc": client.Entity.Teleport(1002, 430, 380); break;
                                        case "pc": client.Entity.Teleport(1011, 195, 260); break;
                                        case "ac":
                                        case "am": client.Entity.Teleport(1020, 566, 563); break;
                                        case "dc": client.Entity.Teleport(1000, 500, 645); break;
                                        case "bi": client.Entity.Teleport(1015, 723, 573); break;
                                        case "pka": client.Entity.Teleport(1005, 050, 050); break;
                                        case "ma": client.Entity.Teleport(1036, 211, 196); break;
                                        case "ja": client.Entity.Teleport(6000, 100, 100); break;
                                    }
                                    break;
                                }

                            case "summon":
                                {
                                    foreach (var pClient in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            pClient.Entity.Teleport(client.Entity.MapID, client.Entity.X, client.Entity.Y);
                                        }
                                    }
                                    break;
                                }
                            case "arrest":
                                {
                                    foreach (var pClient in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            pClient.Entity.Teleport(6004, 30, 74);
                                        }
                                    }
                                    break;
                                }
                            case "pkp":
                                {
                                    client.Entity.PKPoints = ushort.Parse(Data[1]);

                                    break;
                                }

                            case "cps":
                                {
                                    client.Entity.ConquerPoints = uint.Parse(Data[1]);
                                    break;
                                }
                            case "money":
                                {
                                    client.Entity.Money = uint.Parse(Data[1]);
                                    break;
                                }

                            case "xp":
                                {
                                    client.Entity.AddFlag(Update.Flags.XPList);
                                    client.XPListStamp = Time32.Now;
                                    break;
                                }

                        }
                    }
                    if (client.Account.State == PhoenixProject.Database.AccountTable.AccountState.GameHelper)
                    {
                        switch (Data[0])
                        {
                            case "invisible":
                                Console.WriteLine("Hammy");
                                break;
                            case "arrest":
                                {
                                    foreach (var pClient in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            pClient.Entity.Teleport(6004, 30, 74);
                                        }
                                    }
                                    break;
                                }
                            case "trace":
                                {
                                    foreach (var pClient in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            client.Entity.Teleport(pClient.Entity.MapID, pClient.Entity.X, pClient.Entity.Y);
                                        }
                                    }
                                    break;
                                }
                            case "bring":
                                {
                                    foreach (var pClient in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]) || Data[1].ToLower() == "all")
                                            if (Data[1].ToLower() == "all")
                                            {
                                                pClient.Entity.Teleport(client.Entity.MapID,
                                                    (ushort)Kernel.Random.Next(client.Entity.X - 5, client.Entity.X + 5),
                                                    (ushort)Kernel.Random.Next(client.Entity.Y - 5, client.Entity.Y + 5));
                                            }
                                            else
                                                pClient.Entity.Teleport(client.Entity.MapID, client.Entity.X, client.Entity.Y);

                                    }
                                    break;
                                }
                            case "kick":
                                {
                                    foreach (var Client in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (Client.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            Client.Disconnect();
                                            break;
                                        }
                                    }
                                    break;
                                }
                            case "ban":
                                {
                                    foreach (var Client in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (Client.Account.State >= client.Account.State)
                                            continue;
                                        if (Client.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            Client.Account.State = PhoenixProject.Database.AccountTable.AccountState.Banned;
                                            Client.Account.Savekimo();
                                            Client.Disconnect();
                                            break;
                                        }
                                    }
                                    break;
                                }
                            case "unban":
                                {
                                    var Account = new Database.AccountTable(Data[1]);
                                    if (Account.State == PhoenixProject.Database.AccountTable.AccountState.Banned)
                                    {
                                        Account.State = PhoenixProject.Database.AccountTable.AccountState.Player;
                                        Account.Savekimo();
                                    }
                                    break;
                                }
                            case "chatban":
                                {
                                    foreach (var Client in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (Client.Entity.Name.Contains(Data[1]))
                                        {
                                            Client.ChatBanLasts = uint.Parse(Data[2]);
                                            Client.ChatBanTime = DateTime.Now;
                                            Client.ChatBanned = true;
                                        }
                                    }
                                    break;
                                }

                            case "chatunban":
                                {
                                    foreach (var Client in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (Client.Entity.Name.Contains(Data[1]))
                                        {
                                            Client.ChatBanned = false;
                                        }
                                    }
                                    break;
                                }

                            case "ann":
                                {
                                    ServerBase.Kernel.SendWorldMessage(new Message("[Announce] by " + client.Entity.Name + ": " + Mess.Remove(0, 3), System.Drawing.Color.Red, Network.GamePackets.Message.Center), ServerBase.Kernel.GamePool.Values);
                                    ServerBase.Kernel.SendWorldMessage(new Message("[Announce] by " + client.Entity.Name + ": " + Mess.Remove(0, 3), System.Drawing.Color.Red, Network.GamePackets.Message.World), ServerBase.Kernel.GamePool.Values);
                                    break;
                                }
                            case "announce":
                                {
                                    ServerBase.Kernel.SendWorldMessage(new Message("[Announce] by " + client.Entity.Name + ": " + Mess.Remove(0, 8), System.Drawing.Color.Red, Network.GamePackets.Message.Center), ServerBase.Kernel.GamePool.Values);
                                    ServerBase.Kernel.SendWorldMessage(new Message("[Announce] by " + client.Entity.Name + ": " + Mess.Remove(0, 8), System.Drawing.Color.Red, Network.GamePackets.Message.World), ServerBase.Kernel.GamePool.Values);
                                    break;
                                }

                            case "record":
                                {
                                    if (client.Account.State != Database.AccountTable.AccountState.ProjectManager)
                                        break;
                                    switch (Data[1])
                                    {
                                        case "on": client.Entity.Mode = Game.Enums.Mode.Recording; break;
                                        case "off": Program.CommandsAI("/saverecord"); break;
                                    } break;
                                }
                            case "clearinventory":
                                {
                                    Interfaces.IConquerItem[] inventory = new Interfaces.IConquerItem[client.Inventory.Objects.Length];
                                    client.Inventory.Objects.CopyTo(inventory, 0);

                                    foreach (Interfaces.IConquerItem item in inventory)
                                    {
                                        client.Inventory.Remove(item, PhoenixProject.Game.Enums.ItemUse.Remove);
                                    }
                                    break;
                                }
                            case "online":
                                {
                                    client.Send(new Message("Online players count: " + ServerBase.Kernel.GamePool.Count, System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                    string line = "";
                                    foreach (Client.GameState pClient in ServerBase.Kernel.GamePool.Values)
                                        line += pClient.Entity.Name + ",";

                                    if (line.Length >= 255)
                                        return true;
                                    client.Send(new GamePackets.Message(line, System.Drawing.Color.Beige, GamePackets.Message.Talk));
                                    break;
                                }

                            case "reborn":
                                {
                                    if (client.Entity.Reborn < 2)
                                    {
                                        if (client.Entity.Class % 10 == 5)
                                        {
                                            if (client.Entity.Class != 15 &&
                                                client.Entity.Class != 25 &&
                                                client.Entity.Class != 45 &&
                                                client.Entity.Class != 55 &&
                                                client.Entity.Class != 65 &&
                                                client.Entity.Class != 135 &&
                                                client.Entity.Class != 145)
                                            {
                                                client.Send(new Message("You need to be an existing class.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                            }
                                            else
                                            {
                                                byte newclass = 10;
                                                byte.TryParse(Data[1], out newclass);
                                                if (newclass != 11 &&
                                                newclass != 21 &&
                                                newclass != 41 &&
                                                newclass != 51 &&
                                                newclass != 61 &&
                                                newclass != 132 &&
                                                newclass != 142)
                                                {
                                                    client.Send(new Message("You need to reborn into an existing class. For fire class = 142 and for waters class = 132.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                                }
                                                else
                                                {
                                                    if (!client.Reborn(newclass))
                                                        client.Send(new Message("You need atleast 2 spaces in your inventory.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                                }
                                            }
                                        }
                                        else
                                            client.Send(new Message("You need to be a master to be able to reborn.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                    }
                                    else
                                        client.Send(new Message("You can't reborn any more.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                    break;
                                }

                            case "dc":
                                {
                                    client.Disconnect();
                                    break;
                                }
                            case "prof":
                                {
                                    Interfaces.IProf proficiency = new GamePackets.Proficiency(true);
                                    if (Data.Length > 1)
                                        proficiency.ID = ushort.Parse(Data[1]);
                                    if (Data.Length > 2)
                                        proficiency.Level = byte.Parse(Data[2]);
                                    if (Data.Length > 3)
                                        proficiency.Experience = uint.Parse(Data[3]);
                                    client.AddProficiency(proficiency);
                                    break;
                                }
                            case "spell":
                                {
                                    Interfaces.ISkill spell = new GamePackets.Spell(true);
                                    if (Data.Length > 1)
                                        spell.ID = ushort.Parse(Data[1]);
                                    if (Data.Length > 2)
                                        spell.Level = byte.Parse(Data[2]);
                                    if (Data.Length > 3)
                                        spell.Experience = uint.Parse(Data[3]);
                                    client.AddSpell(spell);
                                    break;
                                }

                            case "level":
                                {
                                    byte level = client.Entity.Level;
                                    byte.TryParse(Data[1], out level);
                                    level = Math.Min((byte)140, Math.Max((byte)1, level));
                                    client.Entity.Level = level;
                                    client.Entity.Experience = 0;
                                    if (client.Entity.Reborn == 0)
                                    {
                                        Database.DataHolder.GetStats(client.Entity.Class, level, client);
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                        client.GemAlgorithm();
                                    }
                                    break;
                                }
                            case "class":
                                {
                                    byte _class = client.Entity.Class;
                                    byte.TryParse(Data[1], out _class);
                                    _class = Math.Min((byte)145, Math.Max((byte)1, _class));
                                    client.Entity.Class = _class;
                                    if (client.Entity.Reborn == 0)
                                    {
                                        Database.DataHolder.GetStats(_class, client.Entity.Level, client);
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                        client.GemAlgorithm();
                                    }
                                    break;
                                }
                            case "body":
                                {
                                    ushort body = client.Entity.Body;
                                    ushort.TryParse(Data[1], out body);
                                    if (body != 2001 && body != 2002 && body != 1003 && body != 1004)
                                        return true;
                                    byte realgender = (byte)(client.Entity.Body % 10);
                                    byte gender = (byte)(body % 10);
                                    if (client.Equipment.Objects[8] != null)
                                        if (gender >= 3 && realgender <= 2)
                                            return true;
                                    client.Entity.Body = body;
                                    if (gender >= 3 && realgender <= 2)
                                        client.Entity.Face -= 200;
                                    if (gender <= 2 && realgender >= 3)
                                        client.Entity.Face += 200;
                                    break;
                                }
                            case "hair":
                                {
                                    ushort hair = client.Entity.HairStyle;
                                    ushort.TryParse(Data[1], out hair);
                                    client.Entity.HairStyle = hair;
                                    break;
                                }
                            case "map":
                                {
                                    client.Send(new Message("Map: " + client.Map.ID, System.Drawing.Color.Blue, GamePackets.Message.TopLeft));
                                    break;
                                }
                            case "tele":
                                {
                                    if (Data.Length > 3)
                                    {
                                        client.Entity.Teleport(ushort.Parse(Data[1]), ushort.Parse(Data[2]), ushort.Parse(Data[3]));
                                    }
                                    break;
                                }
                            case "tele2":
                                {
                                    if (Data.Length > 3)
                                    {
                                        client.Entity.TeleportHouse(ushort.Parse(Data[1]), ushort.Parse(Data[2]), ushort.Parse(Data[3]));
                                    }
                                    break;
                                }
                            case "transform":
                                {
                                    if (client.Entity.Dead)
                                        break;
                                    bool wasTransformated = client.Entity.Transformed;
                                    if (wasTransformated)
                                    {
                                        client.Entity.Hitpoints = client.Entity.MaxHitpoints;
                                        client.Entity.TransformationID = 0;
                                        client.Entity.TransformationStamp = Time32.Now;
                                        return true;
                                    }
                                    ushort transformation = client.Entity.TransformationID;
                                    ushort.TryParse(Data[1], out transformation);
                                    client.Entity.TransformationID = transformation;
                                    client.Entity.TransformationStamp = Time32.Now;
                                    client.Entity.TransformationTime = 110;
                                    SpellUse spellUse = new SpellUse(true);
                                    spellUse.Attacker = client.Entity.UID;
                                    spellUse.SpellID = 1360;
                                    spellUse.SpellLevel = 4;
                                    spellUse.X = client.Entity.X;
                                    spellUse.Y = client.Entity.Y;
                                    spellUse.Targets.Add(client.Entity.UID, (uint)0);
                                    client.Send(spellUse);
                                    client.Entity.TransformationMaxHP = 3000;
                                    double maxHP = client.Entity.MaxHitpoints;
                                    double HP = client.Entity.Hitpoints;
                                    double point = HP / maxHP;

                                    client.Entity.Hitpoints = (uint)(client.Entity.TransformationMaxHP * point);
                                    client.Entity.Update(Update.MaxHitpoints, client.Entity.TransformationMaxHP, false);
                                    break;
                                }
                            case "item":
                                {
                                    if (Data.Length > 2)
                                    {
                                        string ItemName = Data[1];
                                        Game.Enums.ItemQuality Quality = Game.Enums.ItemQuality.Fixed;
                                        switch (Data[2].ToLower())
                                        {
                                            case "fixed": Quality = Game.Enums.ItemQuality.Fixed; break;
                                            case "normal": Quality = Game.Enums.ItemQuality.Normal; break;
                                            case "normalv1": Quality = Game.Enums.ItemQuality.NormalV1; break;
                                            case "normalv2": Quality = Game.Enums.ItemQuality.NormalV2; break;
                                            case "normalv3": Quality = Game.Enums.ItemQuality.NormalV3; break;
                                            case "refined": Quality = Game.Enums.ItemQuality.Refined; break;
                                            case "unique": Quality = Game.Enums.ItemQuality.Unique; break;
                                            case "elite": Quality = Game.Enums.ItemQuality.Elite; break;
                                            case "super": Quality = Game.Enums.ItemQuality.Super; break;
                                            case "other": Quality = Game.Enums.ItemQuality.Other; break;
                                            default:
                                                {
                                                    Quality = (PhoenixProject.Game.Enums.ItemQuality)int.Parse(Data[2]);
                                                    break;
                                                }
                                        }
                                        Database.ConquerItemBaseInformation CIBI = null;
                                        foreach (Database.ConquerItemBaseInformation infos in Database.ConquerItemInformation.BaseInformations.Values)
                                        {
                                            if (infos.Name.ToLower() == ItemName.ToLower() && Quality == (Game.Enums.ItemQuality)(infos.ID % 10))
                                            {
                                                CIBI = infos;
                                            }
                                        }
                                        if (CIBI == null)
                                            break;
                                        Interfaces.IConquerItem newItem = new GamePackets.ConquerItem(true);
                                        newItem.ID = CIBI.ID;
                                        newItem.Durability = CIBI.Durability;
                                        newItem.MaximDurability = CIBI.Durability;
                                        if (Data.Length > 3)
                                        {
                                            byte plus = 0;
                                            byte.TryParse(Data[3], out plus);
                                            newItem.Plus = Math.Min((byte)12, plus);
                                            if (Data.Length > 4)
                                            {
                                                byte bless = 0;
                                                byte.TryParse(Data[4], out bless);
                                                newItem.Bless = Math.Min((byte)7, bless);
                                                if (Data.Length > 5)
                                                {
                                                    byte ench = 0;
                                                    byte.TryParse(Data[5], out ench);
                                                    newItem.Enchant = Math.Min((byte)255, ench);
                                                    if (Data.Length > 6)
                                                    {
                                                        byte soc1 = 0;
                                                        byte.TryParse(Data[6], out soc1);
                                                        if (Enum.IsDefined(typeof(Game.Enums.Gem), soc1))
                                                        {
                                                            newItem.SocketOne = (Game.Enums.Gem)soc1;
                                                        }
                                                        if (Data.Length > 7)
                                                        {
                                                            byte soc2 = 0;
                                                            byte.TryParse(Data[7], out soc2);
                                                            if (Enum.IsDefined(typeof(Game.Enums.Gem), soc2))
                                                            {
                                                                newItem.SocketTwo = (Game.Enums.Gem)soc2;
                                                            }
                                                        }
                                                        if (Data.Length > 10)
                                                        {
                                                            byte R = 0, G = 0, B = 0;
                                                            byte.TryParse(Data[8], out R);
                                                            byte.TryParse(Data[9], out G);
                                                            byte.TryParse(Data[10], out B);
                                                            newItem.SocketProgress = (uint)(B | (G << 8) | (R << 16));
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        newItem.Color = (PhoenixProject.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                        if (client.Account.State == PhoenixProject.Database.AccountTable.AccountState.GameMaster)
                                            newItem.Bound = true;
                                        client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
                                    }
                                    break;
                                }
                        }
                        return true;
                    }
                    #endregion

                    return true;
                }
                return false;
            }
            catch { client.Send(new Message("Impossible to handle this command. Check your syntax.", System.Drawing.Color.BurlyWood, Message.TopLeft)); return false; }
        }
        public static void UnequipItem(ItemUsage usage, Client.GameState client)
        {
            Positions pos = GetPositionFromID(usage.UID);
            if (client.Entity.MapID == 2060)
            {
                if (usage.dwParam == 9)
                {
                    return;
                }
            }
            if (client.Entity.MapID == 7009)
            {
                if (usage.dwParam == 9)
                {
                    return;
                }
            }
            if (client.Equipment.Remove((byte)usage.dwParam))
            {
                if (client.Map.ID == 1039)
                    client.Entity.AttackPacket = null;
                if (!client.AlternateEquipment)
                {
                    client.LoadItemStats(client.Entity);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                    ClientEquip equips = new ClientEquip();
                    equips.DoEquips(client);
                    client.Send(equips);
                    client.Equipment.UpdateEntityPacket();
                }
                else
                {
                    client.LoadItemStats2(client.Entity);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();

                    ClientEquip equips = new ClientEquip(client);
                    client.Send(equips);
                    client.Equipment.UpdateEntityPacket2();
                }
            }
        }
            public Reincarnation(Client.GameState client, byte new_class)
            {
                if (client.Entity.Level < 120)
                    return;
                if (ServerBase.Kernel.ReincarnatedCharacters.ContainsKey(client.Entity.UID))
                    return;
                _client = client;
                Database.ReincarnationTable.NewReincarnated(client.Entity);
                Game.Features.Reincarnation.ReincarnateInfo info = new Game.Features.Reincarnation.ReincarnateInfo();
                info.UID = client.Entity.UID;
                info.Level = client.Entity.Level;
                info.Experience = client.Entity.Experience;
                ServerBase.Kernel.ReincarnatedCharacters.Add(info.UID, info);
                client.Entity.FirstRebornClass = client.Entity.SecondRebornClass;
                client.Entity.SecondRebornClass = client.Entity.Class;
                client.Entity.Class = new_class;
                client.Entity.SecondRebornLevel = client.Entity.Level;
                //client.Entity.ReincarnationLev = client.Entity.Level;//kikoz
                client.Entity.Level = 15;
                client.Entity.Experience = 0;
                client.Entity.Atributes =
                 (ushort)(client.ExtraAtributePoints(client.Entity.FirstRebornClass, client.Entity.FirstRebornLevel) +
                  client.ExtraAtributePoints(client.Entity.SecondRebornClass, client.Entity.SecondRebornLevel) + 62);
                #region RemoveAllSpells
                Interfaces.ISkill[] spells = client.Spells.Values.ToArray();
                foreach (Interfaces.ISkill spell in spells)
                {
                    if (!ServerBase.Constants.AvaibleSpells.Contains(spell.ID))
                    {
                        client.RemoveSpell(spell);
                    }
                    //spell.Send(client);
                }
                #endregion
                #region Blessed
                if (client.Entity.Reborn == 2)
                {
                    if (client.Entity.Reborn == 2)
                    {

                        client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                    }
                }
                #endregion

                #region SeconedClassTrojan
                if (client.Entity.SecondRebornClass == 15)
                {
                    if (client.Entity.SecondRebornClass == 15)
                    {
                        client.AddSpell(new Spell(true) { ID = 1190 });//SpiritHealing
                        client.AddSpell(new Spell(true) { ID = 1110 });//Cyclone
                        client.AddSpell(new Spell(true) { ID = 1270 });//Robot
                        client.AddSpell(new Spell(true) { ID = 1015 });//Accury
                    }
                }
                #endregion
                #region SeconedClassWarrior
                if (client.Entity.SecondRebornClass == 25)
                {
                    if (client.Entity.SecondRebornClass == 25)
                    {
                        client.AddSpell(new Spell(true) { ID = 1040 });//Raor
                        client.AddSpell(new Spell(true) { ID = 1051 });//Dash
                        client.AddSpell(new Spell(true) { ID = 1320 });//FlyingMoon
                        client.AddSpell(new Spell(true) { ID = 1025 });//Superman
                    }
                }
                #endregion
                #region SeconedClassArcher
                if (client.Entity.SecondRebornClass == 45)
                {
                    if (client.Entity.SecondRebornClass == 45)
                    {

                    }
                }
                #endregion
                #region SeconedClassNinja
                if (client.Entity.SecondRebornClass == 55)
                {
                    if (client.Entity.SecondRebornClass == 55)
                    {
                        client.AddSpell(new Spell(true) { ID = 6001 });//ToxicFog
                        client.AddSpell(new Spell(true) { ID = 6004 });//ArcherBane
                    }
                }
                #endregion
                #region SeconedClassMonk
                if (client.Entity.SecondRebornClass == 65)
                {
                    if (client.Entity.SecondRebornClass == 65)
                    {
                        client.AddSpell(new Spell(true) { ID = 10400 });//Serenity
                        client.AddSpell(new Spell(true) { ID = 10425 });//Tranquality
                    }
                }
                #endregion
                #region SeconedClassWater
                if (client.Entity.SecondRebornClass == 135)
                {
                    if (client.Entity.SecondRebornClass == 135)
                    {
                        client.AddSpell(new Spell(true) { ID = 1000 });//Thunder
                        client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                        //client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                        client.AddSpell(new Spell(true) { ID = 1195 });//Medation
                        client.AddSpell(new Spell(true) { ID = 1085 });//StarOfAccuracy
                        client.AddSpell(new Spell(true) { ID = 1090 });//MagicShield
                        client.AddSpell(new Spell(true) { ID = 1095 });//Stigma
                        client.AddSpell(new Spell(true) { ID = 1075 });//Invisibility
                        //client.AddSpell(new Spell(true) { ID = 1175 });//AdvancedCure
                        //client.AddSpell(new Spell(true) { ID = 1170 });//Nectar
                    }
                }
                #endregion
                #region SeconedClassFire
                if (client.Entity.SecondRebornClass == 145)
                {
                    if (client.Entity.SecondRebornClass == 145)
                    {
                        client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                        //client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                        client.AddSpell(new Spell(true) { ID = 1195 });//Medation
                    }
                }
                #endregion
                #region SeconedClassPirate
                if (client.Entity.SecondRebornClass == 75)
                {
                    if (client.Entity.SecondRebornClass == 75)
                    {
                        client.AddSpell(new Spell(true) { ID = 11070 });//ScurvyBomb
                    }
                }
                #endregion

                #region FirstClassTrojan
                if (client.Entity.FirstRebornClass == 15)
                {
                    if (client.Entity.FirstRebornClass == 15)
                    {
                        client.AddSpell(new Spell(true) { ID = 1190 });//SpiritHealing
                        client.AddSpell(new Spell(true) { ID = 1110 });//Cyclone
                        client.AddSpell(new Spell(true) { ID = 1270 });//Robot
                        client.AddSpell(new Spell(true) { ID = 1015 });//Accury
                    }
                }
                #endregion
                #region FirstClassWarrior
                if (client.Entity.FirstRebornClass == 25)
                {
                    if (client.Entity.FirstRebornClass == 25)
                    {
                        client.AddSpell(new Spell(true) { ID = 1040 });//Raor
                        client.AddSpell(new Spell(true) { ID = 1051 });//Dash
                        client.AddSpell(new Spell(true) { ID = 1320 });//FlyingMoon
                        client.AddSpell(new Spell(true) { ID = 1025 });//Superman
                    }
                }
                #endregion
                #region FirstClassArcher
                if (client.Entity.FirstRebornClass == 45)
                {
                    if (client.Entity.FirstRebornClass == 45)
                    {

                    }
                }
                #endregion
                #region FirstClassNinja
                if (client.Entity.FirstRebornClass == 55)
                {
                    if (client.Entity.FirstRebornClass == 55)
                    {
                        client.AddSpell(new Spell(true) { ID = 6001 });//ToxicFog
                        client.AddSpell(new Spell(true) { ID = 6004 });//ArcherBane
                    }
                }
                #endregion
                #region FirstClassMonk
                if (client.Entity.FirstRebornClass == 65)
                {
                    if (client.Entity.FirstRebornClass == 65)
                    {
                        client.AddSpell(new Spell(true) { ID = 10400 });//Serenity
                        client.AddSpell(new Spell(true) { ID = 10425 });//Tranquality
                    }
                }
                #endregion
                #region FirstClassWater
                if (client.Entity.FirstRebornClass == 135)
                {
                    if (client.Entity.FirstRebornClass == 135)
                    {
                        client.AddSpell(new Spell(true) { ID = 1000 });//Thunder
                        client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                        //client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                        client.AddSpell(new Spell(true) { ID = 1195 });//Medation
                        client.AddSpell(new Spell(true) { ID = 1085 });//StarOfAccuracy
                        client.AddSpell(new Spell(true) { ID = 1090 });//MagicShield
                        client.AddSpell(new Spell(true) { ID = 1095 });//Stigma
                        client.AddSpell(new Spell(true) { ID = 1075 });//Invisibility
                        //client.AddSpell(new Spell(true) { ID = 1175 });//AdvancedCure
                        //client.AddSpell(new Spell(true) { ID = 1170 });//Nectar
                    }
                }
                #endregion
                #region FirstClassFire
                if (client.Entity.FirstRebornClass == 145)
                {
                    if (client.Entity.FirstRebornClass == 145)
                    {
                        client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                        //client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                        client.AddSpell(new Spell(true) { ID = 1195 });//Medation
                    }
                }
                #endregion
                #region FirstClassPirate
                if (client.Entity.FirstRebornClass == 75)
                {
                    if (client.Entity.FirstRebornClass == 75)
                    {
                        client.AddSpell(new Spell(true) { ID = 11070 });//GaleBomb
                    }
                }
                #endregion

                #region AddPureTrojanSpell
                if (client.Entity.FirstRebornClass == 15 && client.Entity.SecondRebornClass == 15)
                {
                    if (client.Entity.Class == 11)
                    {
                        client.AddSpell(new Spell(true) { ID = 1190 });//SpiritHealing
                        client.AddSpell(new Spell(true) { ID = 1110 });//Cyclone
                        client.AddSpell(new Spell(true) { ID = 1115 });//Hercules
                        client.AddSpell(new Spell(true) { ID = 1015 });//Accury
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        //client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        client.AddSpell(new Spell(true) { ID = 10315 });//DragonWhirl
                        client.AddSpell(new Spell(true) { ID = 3050 });//CruelShade
                    }
                }
                #endregion
                #region AddPureWarSpell
                if (client.Entity.FirstRebornClass == 25 && client.Entity.SecondRebornClass == 25)
                {
                    if (client.Entity.Class == 21)
                    {
                        //client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        client.AddSpell(new Spell(true) { ID = 10311 });//Perseverance
                        client.AddSpell(new Spell(true) { ID = 7020 });//Rage
                        client.AddSpell(new Spell(true) { ID = 1051 });//Dash
                        client.AddSpell(new Spell(true) { ID = 1320 });//FlyingMoon
                        client.AddSpell(new Spell(true) { ID = 1040 });//Roar
                        client.AddSpell(new Spell(true) { ID = 1025 });//SuperMan
                        client.AddSpell(new Spell(true) { ID = 1020 });//Shield
                        client.AddSpell(new Spell(true) { ID = 3060 });//Reflect
                    }
                }
                #endregion
                #region AddPureArcherSpell
                if (client.Entity.FirstRebornClass == 45 && client.Entity.SecondRebornClass == 45)
                {
                    if (client.Entity.Class == 41)
                    {
                        //client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        client.AddSpell(new Spell(true) { ID = 10313 });//StarArrow
                        client.AddSpell(new Spell(true) { ID = 8030 });//ArrowRain
                        client.AddSpell(new Spell(true) { ID = 8002 });//XpFly
                        client.AddSpell(new Spell(true) { ID = 9000 });//INTE
                        client.AddSpell(new Spell(true) { ID = 8003 });//AdvanceFly
                        client.AddSpell(new Spell(true) { ID = 8000 });//RapidFire
                        client.AddSpell(new Spell(true) { ID = 8001 });//Scatter
                        //client.AddSpell(new Spell(true) { ID = 3060 });//Reflect
                    }
                }
                #endregion
                #region AddPureNinjaSpell
                if (client.Entity.FirstRebornClass == 55 && client.Entity.SecondRebornClass == 55)
                {
                    if (client.Entity.Class == 51)
                    {
                        //client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        client.AddSpell(new Spell(true) { ID = 6003 });//CounterKill
                        client.AddSpell(new Spell(true) { ID = 6000 });//TwoFold
                        client.AddSpell(new Spell(true) { ID = 6001 });//Toxic
                        client.AddSpell(new Spell(true) { ID = 6002 });//PoisnStar
                        client.AddSpell(new Spell(true) { ID = 6004 });//ArcherBane
                        client.AddSpell(new Spell(true) { ID = 6010 });//ShurikenVortex
                        client.AddSpell(new Spell(true) { ID = 6011 });//FatalStrike
                        //client.AddSpell(new Spell(true) { ID = 3060 });//Reflect
                    }
                }
                #endregion
                #region AddPureMonkSpell
                if (client.Entity.FirstRebornClass == 65 && client.Entity.SecondRebornClass == 65)
                {
                    if (client.Entity.Class == 61)
                    {
                        ////client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        client.AddSpell(new Spell(true) { ID = 10405 });//SoulShakle
                        client.AddSpell(new Spell(true) { ID = 10381 });//Radiant
                        client.AddSpell(new Spell(true) { ID = 10390 });//Oblivion
                        client.AddSpell(new Spell(true) { ID = 10400 });//Serinity
                        client.AddSpell(new Spell(true) { ID = 10415 });//Whirld
                        client.AddSpell(new Spell(true) { ID = 10425 });//Tranquilty
                        client.AddSpell(new Spell(true) { ID = 10490 });//TripleAttack
                        client.AddSpell(new Spell(true) { ID = 10430 });//Compassion
                    }
                }
                #endregion
                #region AddPureWaterSpell
                if (client.Entity.FirstRebornClass == 135 && client.Entity.SecondRebornClass == 135)
                {
                    if (client.Entity.Class == 132)
                    {
                        //client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        client.AddSpell(new Spell(true) { ID = 30000 });//AzureShield
                        client.AddSpell(new Spell(true) { ID = 1280 });//WaterElf
                        client.AddSpell(new Spell(true) { ID = 1050 });//XpReveve
                        client.AddSpell(new Spell(true) { ID = 1170 });//Nectar
                        client.AddSpell(new Spell(true) { ID = 1175 });//AdvancedCure
                        client.AddSpell(new Spell(true) { ID = 1100 });//Pray
                        client.AddSpell(new Spell(true) { ID = 1075 });//inv
                        client.AddSpell(new Spell(true) { ID = 1095 });//Stigma
                        client.AddSpell(new Spell(true) { ID = 1090 });//MagicShield
                        client.AddSpell(new Spell(true) { ID = 1085 });//Star
                        client.AddSpell(new Spell(true) { ID = 1055 });//HealingRain
                        client.AddSpell(new Spell(true) { ID = 1195 });//Mediation
                        client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                        client.AddSpell(new Spell(true) { ID = 1000 });//Thunder
                        client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                    }
                }
                #endregion
                #region AddPureFireSpell
                if (client.Entity.FirstRebornClass == 145 && client.Entity.SecondRebornClass == 145)
                {
                    if (client.Entity.Class == 142)
                    {
                        //client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        client.AddSpell(new Spell(true) { ID = 10310 });//HeavenBlade
                        client.AddSpell(new Spell(true) { ID = 3080 });//Dodge
                        client.AddSpell(new Spell(true) { ID = 1195 });//Mediation
                        client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                        client.AddSpell(new Spell(true) { ID = 1000 });//Thunder
                        client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                        client.AddSpell(new Spell(true) { ID = 1002 });//Tornado
                        client.AddSpell(new Spell(true) { ID = 1150 });//FireRing
                        client.AddSpell(new Spell(true) { ID = 1180 });//FireMeteor
                        client.AddSpell(new Spell(true) { ID = 1120 });//FireCircle
                        client.AddSpell(new Spell(true) { ID = 1160 });//Bomb
                        client.AddSpell(new Spell(true) { ID = 1165 });//FireOfHell
                        client.AddSpell(new Spell(true) { ID = 1125 });//Volcano
                    }
                }
                #endregion
                #region AddPurePirate
                if (client.Entity.FirstRebornClass == 75 && client.Entity.SecondRebornClass == 75)
                {
                    if (client.Entity.Class == 71)
                    {
                        client.AddSpell(new Spell(true) { ID = 11110 });//SpiritHealing
                        client.AddSpell(new Spell(true) { ID = 11040 });//Cyclone
                        client.AddSpell(new Spell(true) { ID = 11050 });//Hercules
                        client.AddSpell(new Spell(true) { ID = 11060 });//Accury
                        client.AddSpell(new Spell(true) { ID = 11070 });//Scatter
                        client.AddSpell(new Spell(true) { ID = 11100 });//SpiritHealing
                        client.AddSpell(new Spell(true) { ID = 11120 });//Cyclone
                        client.AddSpell(new Spell(true) { ID = 11130 });//Hercules//11140
                        client.AddSpell(new Spell(true) { ID = 11140 });//Hercules//11140
                    }
                }
                #endregion

                if (client.Entity.Reborn == 2)
                {
                    #region if water
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 132 && client.Entity.Class <= 135)
                        {
                            //client.AddSpell(new Spell(true) { ID = 30000 });//AzureShield
                            client.AddSpell(new Spell(true) { ID = 1280 });//WaterElf
                            client.AddSpell(new Spell(true) { ID = 1050 });//XpReveve
                            client.AddSpell(new Spell(true) { ID = 1170 });//Nectar
                            client.AddSpell(new Spell(true) { ID = 1175 });//AdvancedCure
                            client.AddSpell(new Spell(true) { ID = 1100 });//Pray
                            client.AddSpell(new Spell(true) { ID = 1075 });//inv
                            client.AddSpell(new Spell(true) { ID = 1095 });//Stigma
                            client.AddSpell(new Spell(true) { ID = 1090 });//MagicShield
                            client.AddSpell(new Spell(true) { ID = 1085 });//Star
                            client.AddSpell(new Spell(true) { ID = 1055 });//HealingRain
                            client.AddSpell(new Spell(true) { ID = 1195 });//Mediation
                            client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                            client.AddSpell(new Spell(true) { ID = 1000 });//Thunder
                            client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                            client.AddSpell(new Spell(true) { ID = 1350 });//DivenHere
                        }
                    }
                    #endregion
                    #region if Fire
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 142 && client.Entity.Class <= 145)
                        {
                            //client.AddSpell(new Spell(true) { ID = 3080 });//Dodge
                            client.AddSpell(new Spell(true) { ID = 1195 });//Mediation
                            client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                            client.AddSpell(new Spell(true) { ID = 1000 });//Thunder
                            client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                            client.AddSpell(new Spell(true) { ID = 1002 });//Tornado
                            client.AddSpell(new Spell(true) { ID = 1150 });//FireRing
                            client.AddSpell(new Spell(true) { ID = 1180 });//FireMeteor
                            client.AddSpell(new Spell(true) { ID = 1120 });//FireCircle
                            client.AddSpell(new Spell(true) { ID = 1160 });//Bomb
                            client.AddSpell(new Spell(true) { ID = 1165 });//FireOfHell
                            client.AddSpell(new Spell(true) { ID = 1125 });//Volcano
                        }
                    }
                    #endregion
                    #region if Monk
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 60 && client.Entity.Class <= 65)
                        {
                            client.AddSpell(new Spell(true) { ID = 10381 });//Radiant
                            client.AddSpell(new Spell(true) { ID = 10390 });//Oblivion
                            client.AddSpell(new Spell(true) { ID = 10400 });//Serinity
                            client.AddSpell(new Spell(true) { ID = 10415 });//Whirld
                            client.AddSpell(new Spell(true) { ID = 10425 });//Tranquilty
                            client.AddSpell(new Spell(true) { ID = 10490 });//TripleAttack
                            client.AddSpell(new Spell(true) { ID = 10430 });//Compassion

                            client.AddSpell(new Spell(true) { ID = 10420 });//Whirld
                            client.AddSpell(new Spell(true) { ID = 10421 });//Tranquilty
                            client.AddSpell(new Spell(true) { ID = 10422 });//TripleAttack
                            client.AddSpell(new Spell(true) { ID = 10423 });//Compassion
                            client.AddSpell(new Spell(true) { ID = 10424 });//Compassion

                            client.AddSpell(new Spell(true) { ID = 10410 });//Compassion
                            client.AddSpell(new Spell(true) { ID = 10395 });//Compassion
                        }
                    }
                    #endregion
                    #region if Ninja
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 50 && client.Entity.Class <= 55)
                        {
                            client.AddSpell(new Spell(true) { ID = 6000 });//TwoFold
                            client.AddSpell(new Spell(true) { ID = 6001 });//Toxic
                            //client.AddSpell(new Spell(true) { ID = 6002 });//PoisnStar
                            client.AddSpell(new Spell(true) { ID = 6004 });//ArcherBane
                            client.AddSpell(new Spell(true) { ID = 6010 });//ShurikenVortex
                            client.AddSpell(new Spell(true) { ID = 6011 });//FatalStrike
                        }
                    }
                    #endregion
                    #region if Warrior
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 20 && client.Entity.Class <= 21)
                        {
                            client.AddSpell(new Spell(true) { ID = 1051 });//Dash
                            client.AddSpell(new Spell(true) { ID = 1320 });//FlyingMoon
                            client.AddSpell(new Spell(true) { ID = 1040 });//Roar
                            client.AddSpell(new Spell(true) { ID = 1025 });//SuperMan
                            client.AddSpell(new Spell(true) { ID = 1020 });//Shield
                        }
                    }
                    #endregion
                    #region if Archer
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 40 && client.Entity.Class <= 45)
                        {
                            client.AddSpell(new Spell(true) { ID = 8030 });//ArrowRain
                            client.AddSpell(new Spell(true) { ID = 8002 });//XpFly
                            client.AddSpell(new Spell(true) { ID = 9000 });//INTE
                            client.AddSpell(new Spell(true) { ID = 8003 });//AdvanceFly
                            client.AddSpell(new Spell(true) { ID = 8000 });//RapidFire
                            client.AddSpell(new Spell(true) { ID = 8001 });//Scatter
                        }
                    }
                    #endregion
                    #region if Trojan
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 10 && client.Entity.Class <= 15)
                        {
                            client.AddSpell(new Spell(true) { ID = 1190 });//SpiritHealing
                            client.AddSpell(new Spell(true) { ID = 1110 });//Cyclone
                            client.AddSpell(new Spell(true) { ID = 1115 });//Hercules
                            client.AddSpell(new Spell(true) { ID = 1015 });//Accury
                            client.AddSpell(new Spell(true) { ID = 1270 });//Scatter
                        }
                    }
                    #endregion
                    #region if Pirate
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 70 && client.Entity.Class <= 75)
                        {
                            client.AddSpell(new Spell(true) { ID = 11110 });//SpiritHealing
                            // client.AddSpell(new Spell(true) { ID = 11040 });//Cyclone
                            client.AddSpell(new Spell(true) { ID = 11050 });//Hercules
                            client.AddSpell(new Spell(true) { ID = 11060 });//Accury
                            client.AddSpell(new Spell(true) { ID = 11070 });//Scatter
                            //client.AddSpell(new Spell(true) { ID = 11100 });//SpiritHealing
                            client.AddSpell(new Spell(true) { ID = 11120 });//Cyclone
                            client.AddSpell(new Spell(true) { ID = 11130 });//Hercules//11140
                            client.AddSpell(new Spell(true) { ID = 11140 });//Hercules//11140
                            //client.AddSpell(new Spell(true) { ID = 11060 });//Accury
                            //client.AddSpell(new Spell(true) { ID = 11070 });//Scatter
                        }
                    }
                    #endregion
                }

                #region Adding earned skills
                if (client.Entity.SecondRebornClass == 15 && client.Entity.Class == 11)
                {
                    client.AddSpell(new Spell(true) { ID = 3050 });
                }
                if (client.Entity.SecondRebornClass == 75 && client.Entity.Class == 71)
                {
                    client.AddSpell(new Spell(true) { ID = 11100 });
                }
                if (client.Entity.Class == 51)
                {
                    client.AddSpell(new Spell(true) { ID = 11230 });
                }
                if (client.Entity.SecondRebornClass == 55 && client.Entity.Class == 51)
                {
                    client.AddSpell(new Spell(true) { ID = 6002 });
                }
                if (client.Entity.SecondRebornClass == 145 && client.Entity.Class == 142)
                {
                    client.AddSpell(new Spell(true) { ID = 3080 });
                }
                if (client.Entity.SecondRebornClass == 135 && client.Entity.Class == 132)
                {
                    client.AddSpell(new Spell(true) { ID = 3090 });
                }
                if (client.Entity.SecondRebornClass == 55 && client.Entity.FirstRebornClass == 55)
                {
                    client.AddSpell(new Spell(true) { ID = 6002 });
                }
                if (client.Entity.SecondRebornClass == 15 && client.Entity.FirstRebornClass == 15)
                {
                    client.AddSpell(new Spell(true) { ID = 3050 });
                }
                if (client.Entity.SecondRebornClass == 75 && client.Entity.FirstRebornClass == 75)
                {
                    client.AddSpell(new Spell(true) { ID = 11100 });
                }
                if (client.Entity.SecondRebornClass == 25)
                {
                    client.AddSpell(new Spell(true) { ID = 3060 });
                }
                if (client.Entity.SecondRebornClass == 145 && client.Entity.FirstRebornClass == 145)
                {
                    client.AddSpell(new Spell(true) { ID = 3080 });
                }
                if (client.Entity.SecondRebornClass == 135 && client.Entity.FirstRebornClass == 135)
                {
                    client.AddSpell(new Spell(true) { ID = 3090 });
                }
                #endregion

                #region Remove unallow skills skills
                if (client.Entity.Class == 11)
                {
                    client.RemoveSpell(new Spell(true) { ID = 1025 });
                    client.RemoveSpell(new Spell(true) { ID = 1020 });
                }
                if (client.Entity.Class == 71)
                {
                    client.RemoveSpell(new Spell(true) { ID = 1025 });
                    client.RemoveSpell(new Spell(true) { ID = 1020 });
                }
                if (client.Entity.Class == 41)
                {
                    client.RemoveSpell(new Spell(true) { ID = 1025 });

                }
                if (client.Entity.Class == 51)
                {
                    client.RemoveSpell(new Spell(true) { ID = 1025 });
                    client.RemoveSpell(new Spell(true) { ID = 1020 });
                }
                if (client.Entity.Class == 61)
                {
                    client.RemoveSpell(new Spell(true) { ID = 1025 });
                    client.RemoveSpell(new Spell(true) { ID = 1020 });
                }
                if (client.Entity.Class == 142)
                {
                    client.RemoveSpell(new Spell(true) { ID = 1025 });
                }
                if (client.Entity.Class == 142)
                {
                    client.RemoveSpell(new Spell(true) { ID = 6002 });
                }
                if (client.Entity.Class == 132)
                {
                    client.RemoveSpell(new Spell(true) { ID = 6002 });
                }
                #endregion

                #region Proficiencies
                foreach (Interfaces.ISkill proficiency in client.Proficiencies.Values)
                {
                    proficiency.PreviousLevel = proficiency.Level;
                    proficiency.Level = 0;
                    proficiency.Experience = 0;
                    proficiency.Send(client);
                }
                #endregion
                #region Low level items
                for (byte i = 1; i < 9; i++)
                {
                    if (i != 7)
                    {
                        Interfaces.IConquerItem item = client.Equipment.TryGetItem(i);
                        if (item != null && item.ID != 0)
                        {
                            try
                            {
                                //client.UnloadItemStats(item, false);
                                Database.ConquerItemInformation cii = new PhoenixProject.Database.ConquerItemInformation(item.ID, item.Plus);
                                item.ID = cii.LowestID(Network.PacketHandler.ItemMinLevel(Network.PacketHandler.ItemPosition(item.ID)));
                                item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                item.Send(client);
                                client.LoadItemStats(client.Entity);
                                client.CalculateStatBonus();
                                client.CalculateHPBonus();
                                Database.ConquerItemTable.UpdateItemID(item, client);
                            }
                            catch
                            {
                                Console.WriteLine("Reborn item problem: " + item.ID);
                            }
                        }
                    }
                }
                #region Alt Fix By Amjad
                Interfaces.IConquerItem AltRing = client.Equipment.TryGetItem(26);
                if (AltRing != null)
                {
                    client.Equipment.Remove(26);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                Interfaces.IConquerItem AltRightHand = client.Equipment.TryGetItem(24);
                if (AltRightHand != null)
                {
                    client.Equipment.Remove(24);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                Interfaces.IConquerItem AltNecklace = client.Equipment.TryGetItem(22);
                if (AltNecklace != null)
                {
                    client.Equipment.Remove(22);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                Interfaces.IConquerItem AltHead = client.Equipment.TryGetItem(21);
                if (AltHead != null)
                {
                    client.Equipment.Remove(21);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                Interfaces.IConquerItem AltLeftHand = client.Equipment.TryGetItem(25);
                if (AltLeftHand != null)
                {
                    client.Equipment.Remove(25);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                Interfaces.IConquerItem AltBoots = client.Equipment.TryGetItem(28);
                if (AltBoots != null)
                {
                    client.Equipment.Remove(28);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                Interfaces.IConquerItem AltArmor = client.Equipment.TryGetItem(23);
                if (AltArmor != null)
                {
                    client.Equipment.Remove(23);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);

                #endregion
                Interfaces.IConquerItem hand = client.Equipment.TryGetItem(5);
                if (hand != null)
                {
                    client.Equipment.Remove(5);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                    client.SendStatMessage();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                #endregion
                Database.DataHolder.GetStats(client.Entity.Class, client.Entity.Level, client);
                // client.loadi
                client.CalculateStatBonus();
                client.CalculateHPBonus();
                client.GemAlgorithm();
                client.SendStatMessage();
                client.Equipment.UpdateEntityPacket();
                //Database.ReincarnationTable.NewReincarnated(client.Entity);
                Network.PacketHandler.WorldMessage(client.Entity.Name + " has got Reincarnation! Congratulations!");
            }
        public static void PurifyRefinery(Purification ps, Client.GameState client)
        {
            Interfaces.IConquerItem item = null, refine = null;
            client.Inventory.TryGetItem(ps.ItemUID, out item);
            client.Inventory.TryGetItem(ps.AddUID, out refine);
            if (refine != null)
            {
                if (item == null)
                    item = client.Equipment.TryGetItem(ps.ItemUID);
                if (item != null)
                {
                    Refinery.RefineryItem refineStats;
                    if (Kernel.DatabaseRefinery.TryGetValue(refine.ID, out refineStats))
                    {
                        Boolean valid = true;
                        if (item.Position < 100)
                        {
                            UInt32 iType = item.ID / 1000;
                            Positions pos = GetPositionFromID(item.ID);
                            if (pos != (Positions)refineStats.Position)
                                valid = false;
                            if (pos == Positions.Garment)
                                return;
                            if (pos == Positions.Steed)
                                return;
                            if (pos == Positions.Bottle)
                                return;
                            if (pos == Positions.SteedArmor)
                                return;
                            if (pos == Positions.SteedTalisman)
                                return;
                            if (pos == Positions.LeftAccessory)
                                return;
                            if (pos == Positions.RightAccessory)
                                return;
                            if (pos == Positions.DefenceTalisman)
                                return;
                            if (pos == Positions.AttackTalisman)
                                return;
                            else if (refineStats.Position == 5)
                                valid = item.IsTwoHander();
                            if (iType == refineStats.Position)
                                valid = true;
                        }
                        else
                        {
                            if (item.GetItemType() != (ConquerItem.ItemTypes)refineStats.Position)
                                valid = false;
                        }

                        if (valid)
                        {
                            if (item.Position == 7)
                                return;
                            if (item.Position == 9)
                                return;
                            if (item.Position == 11)
                                return;
                            if (item.Position == 12)
                                return;
                            if (item.Position == 10)
                                return;
                            if (item.Position == 18)
                                return;
                            if (item.Position == 17)
                                return;
                            if (item.Position == 15)
                                return;
                            if (item.Position == 16)
                                return;
                            client.Inventory.Remove(refine, Game.Enums.ItemUse.Remove);
                            item.RefineItem = refineStats.Identifier;
                            item.Mode = Game.Enums.ItemMode.Update;
                            item.RefineryTime = DateTime.Now.AddDays(7);
                            item.Send(client);

                            client.LoadItemStats(client.Entity);
                            client.CalculateStatBonus();
                            client.CalculateHPBonus();

                            Database.ConquerItemTable.UpdateRefineryItem(item);
                            Database.ConquerItemTable.UpdateRefineryTime(item);

                            client.Send(WindowStats(client));
                            //LoadItemStatus(client);
                            // c.Send(new Game_HeroStats(c.Hero));
                        }
                        else
                            client.Send(new Message(String.Format("You cannot refine your {0} with that {1}.",
                                Database.ConquerItemInformation.BaseInformations[item.ID].Name, Database.ConquerItemInformation.BaseInformations[refine.ID].Name), System.Drawing.Color.Red, Message.TopLeft));
                    }
                    else
                        Console.WriteLine(String.Format("No database refinery {0}", refine.ID));
                }
            }
        }
        public static void PurifyItem(Purification ps, Client.GameState client)
        {
            Interfaces.IConquerItem Item = null, AddingItem = null;
            if (client.Inventory.TryGetItem(ps.ItemUID, out Item) && client.Inventory.TryGetItem(ps.AddUID, out AddingItem))
            {
                if (ps.ItemUID == ps.AddUID)
                    return;

                var PurifyInformation = Database.ConquerItemInformation.BaseInformations[AddingItem.ID];
                var ItemInformation = Database.ConquerItemInformation.BaseInformations[Item.ID];
                if (PurifyInformation.PurificationLevel > 0)
                {
                    if (ItemInformation.Level >= PurifyInformation.Level)
                    {
                        if (client.Inventory.Contains(1088001, PurifyInformation.PurificationMeteorNeed))
                        {
                            client.Inventory.Remove(1088001, (byte)PurifyInformation.PurificationMeteorNeed);
                            if (Item.Purification.PurificationItemID > 0)
                                Database.ItemAddingTable.RemoveAdding(Item.UID, Item.Purification.PurificationItemID);
                            client.Send(ps);
                            ItemAdding.Purification_ purify = new ItemAdding.Purification_();
                            purify.AddedOn = DateTime.Now;
                            purify.Available = true;
                            purify.ItemUID = ps.ItemUID;
                            purify.PurificationLevel = PurifyInformation.PurificationLevel;
                            purify.PurificationDuration = 7 * 24 * 60 * 60;
                            purify.PurificationItemID = AddingItem.ID;
                            Database.ItemAddingTable.AddPurification(purify);
                            Item.Purification = purify;
                            Item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                            Item.Send(client);
                            client.Inventory.Remove(AddingItem, PhoenixProject.Game.Enums.ItemUse.Remove);
                            client.LoadItemStats(client.Entity);
                            client.CalculateStatBonus();
                            client.CalculateHPBonus();
                            client.Send(ps);
                        }
                    }
                }
            }
        }
        static void LoginMessages(Client.GameState client)
        {
            if (client.WentToComplete)
                return;
            Data datas = new Data(true);
            datas.UID = client.Entity.UID;
            datas.ID = 116;
            datas.dwParam = 1197;
            client.Send(datas);
            client.SocketDisposed = false;

            // client.Send(Unknown2078Packet.Create(0x4f999eba));
            // client.TimeStamps.LoggedInTime = DateTime.Now;
            client.Send(new byte[] { 8, 0, 0x1f, 8, 0, 0, 0, 0, 0x54, 0x51, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72 });

            client.Send(new byte[] {
                    0x1c, 1, 0x25, 4, 0, 0, 0x22, 0, 0x7a, 3, 0, 0, 0, 0, 0, 0,
                    0xb2, 2, 0, 0, 0xff, 0xff, 0xff, 0xff, 0x8a, 2, 0, 0, 0, 0, 0, 0,
                    0x5b, 3, 0, 0, 0xff, 0xff, 0xff, 0xff, 90, 3, 0, 0, 0xff, 0xff, 0xff, 0xff,
                    0x59, 3, 0, 0, 0xff, 0xff, 0xff, 0xff, 0x58, 3, 0, 0, 0xff, 0xff, 0xff, 0xff,
                    0x57, 3, 0, 0, 0xff, 0xff, 0xff, 0xff, 0x56, 3, 0, 0, 0xff, 0xff, 0xff, 0xff,
                    0x55, 3, 0, 0, 0xff, 0xff, 0xff, 0xff, 0x54, 3, 0, 0, 0xff, 0xff, 0xff, 0xff,
                    0x53, 3, 0, 0, 0xff, 0xff, 0xff, 0xff, 0x52, 3, 0, 0, 0xff, 0xff, 0xff, 0xff,
                    0x57, 2, 0, 0, 0, 0, 0, 0, 0x56, 2, 0, 0, 0, 0, 0, 0,
                    0x55, 2, 0, 0, 0, 0, 0, 0, 0x54, 2, 0, 0, 0, 0, 0, 0,
                    0x53, 2, 0, 0, 0, 0, 0, 0, 0x52, 2, 0, 0, 0, 0, 0, 0,
                    0x51, 2, 0, 0, 0, 0, 0, 0, 80, 2, 0, 0, 0, 0, 0, 0,
                    0x4f, 2, 0, 0, 0, 0, 0, 0, 0x4e, 2, 0, 0, 0, 0, 0, 0,
                    0xf3, 1, 0, 0, 0, 0, 0, 0, 0xf2, 1, 0, 0, 0, 0, 0, 0,
                    0xf1, 1, 0, 0, 0, 0, 0, 0, 240, 1, 0, 0, 0, 0, 0, 0,
                    0xef, 1, 0, 0, 0, 0, 0, 0, 0xee, 1, 0, 0, 0, 0, 0, 0,
                    0xed, 1, 0, 0, 0, 0, 0, 0, 0xec, 1, 0, 0, 0, 0, 0, 0,
                    0xeb, 1, 0, 0, 0, 0, 0, 0, 0xea, 1, 0, 0, 0, 0, 0, 0,
                    210, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x54, 0x51, 0x53, 0x65,
                    0x72, 0x76, 0x65, 0x72
                 });
            client.Send(new byte[] {
                    60, 0, 0x7e, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x54, 0x51, 0x53, 0x65,
                    0x72, 0x76, 0x65, 0x72
                 });
            client.Send(new byte[] {
                    60, 0, 0x7e, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x54, 0x51, 0x53, 0x65,
                    0x72, 0x76, 0x65, 0x72
                 });
            client.Send(new byte[] {
                    0x54, 0, 0x20, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0x54, 0x51, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72
                 });

            DateTime time2 = new DateTime(0x7b2, 1, 1);
            TimeSpan span = (TimeSpan)(client.Entity.LastLogin - time2.ToLocalTime());
            uint num = (uint)span.TotalSeconds - 3600;
            // uint num = (uint)client.Entity.LastLogin.ToFileTime();
            if (num == 0)
            {
                DateTime time3 = new DateTime(0x7b2, 1, 1);
                TimeSpan span3 = (TimeSpan)(DateTime.Now - time3.ToLocalTime());

                num = (uint)span3.TotalSeconds - 3600;
            }
            LastLogin login = new LastLogin
            {
                TotalSeconds = num,
                Type = ((client.Account.IP != string.Empty) && (client.Account.IP != client.Account.OldIP)) ? PhoenixProject.Network.GamePackets.LastLogin.LastLoginTypes.DifferentCity : PhoenixProject.Network.GamePackets.LastLogin.LastLoginTypes.LastLogin,
                Unknown = 1
            };
            client.Send((byte[])login);

            if (client.Spells.ContainsKey(3050))
            {
                if (client.Entity.SecondRebornClass == 15 && client.Entity.FirstRebornClass == 15)
                {
                    // client.AddSpell(new Spell(true) { ID = 3050 });
                }
                else
                {
                    if (client.Entity.SecondRebornClass == 15 && client.Entity.Class >= 10 && client.Entity.Class <= 15)
                    {
                        // client.AddSpell(new Spell(true) { ID = 3050 });
                    }
                    else
                    {
                        if (client.Entity.FirstRebornClass == 15 && client.Entity.Class >= 10 && client.Entity.Class <= 15)
                        {
                            // client.AddSpell(new Spell(true) { ID = 3050 });
                        }
                        else
                        {
                            client.RemoveSpell(new Spell(true) { ID = 3050 });
                        }
                    }
                }
            }

            if (client.Spells.ContainsKey(11100))
            {
                if (client.Entity.SecondRebornClass == 75 && client.Entity.FirstRebornClass == 75)
                {
                    // client.AddSpell(new Spell(true) { ID = 3050 });
                }
                else
                {
                    if (client.Entity.SecondRebornClass == 75 && client.Entity.Class >= 70 && client.Entity.Class <= 75)
                    {
                        // client.AddSpell(new Spell(true) { ID = 3050 });
                    }
                    else
                    {
                        if (client.Entity.FirstRebornClass == 75 && client.Entity.Class >= 70 && client.Entity.Class <= 75)
                        {
                            // client.AddSpell(new Spell(true) { ID = 3050 });
                        }
                        else
                        {
                            client.RemoveSpell(new Spell(true) { ID = 11100 });
                        }
                    }
                }
            }

            if (client.Spells.ContainsKey(11050))
            {
                if (client.Spells[11050].Level > 0)
                {
                    client.RemoveSpell(new Spell(true) { ID = 11050 });
                    client.AddSpell(new Spell(true) { ID = 11050 });
                }
            }

            if (client.Entity.Class >= 50 && client.Entity.Class <= 55)
            {
                if (!client.Spells.ContainsKey(11230))
                {
                    client.AddSpell(new Spell(true) { ID = 11230 });
                }
            }
            else
            {
                if (client.Spells.ContainsKey(11230))
                {
                    client.RemoveSpell(new Spell(true) { ID = 11230 });
                }

            }

            if (client.Entity.Class >= 142 && client.Entity.Class <= 145 && client.Entity.FirstRebornClass == 145 && client.Entity.SecondRebornClass == 145)
            {
                if (!client.Spells.ContainsKey(10310))
                {
                    client.AddSpell(new Spell(true) { ID = 10310 });
                }
            }
            else
            {
                if (client.Spells.ContainsKey(10310))
                {
                    client.RemoveSpell(new Spell(true) { ID = 10310 });
                }

            }

            if (client.Entity.Class >= 132 && client.Entity.Class <= 135 && client.Entity.FirstRebornClass == 135 && client.Entity.SecondRebornClass == 135)
            {
                if (!client.Spells.ContainsKey(30000))
                {
                    client.AddSpell(new Spell(true) { ID = 30000 });
                }
            }
            else
            {
                if (client.Spells.ContainsKey(30000))
                {
                    client.RemoveSpell(new Spell(true) { ID = 30000 });
                }

            }

            if (client.Entity.Class >= 70 && client.Entity.Class <= 75 && client.Entity.FirstRebornClass == 75 && client.Entity.SecondRebornClass == 75)
            {
                if (!client.Spells.ContainsKey(11040))
                {
                    client.AddSpell(new Spell(true) { ID = 11040 });
                }
            }
            else
            {
                if (client.Spells.ContainsKey(11040))
                {
                    client.RemoveSpell(new Spell(true) { ID = 11040 });
                }

            }

            if (client.Entity.Class >= 50 && client.Entity.Class <= 55 && client.Entity.FirstRebornClass <= 55 && client.Entity.FirstRebornClass >= 50 && client.Entity.SecondRebornClass <= 55 && client.Entity.SecondRebornClass >= 50)
            {
                if (!client.Spells.ContainsKey(6003))
                {
                    client.AddSpell(new Spell(true) { ID = 6003 });
                }
            }
            else
            {
                if (client.Spells.ContainsKey(6003))
                {
                    client.RemoveSpell(new Spell(true) { ID = 6003 });
                }

            }
            if (client.Entity.Class >= 60 && client.Entity.Class <= 65 && client.Entity.FirstRebornClass <= 65 && client.Entity.FirstRebornClass >= 60 && client.Entity.SecondRebornClass <= 65 && client.Entity.SecondRebornClass >= 60)
            {
                if (!client.Spells.ContainsKey(10405))
                {
                    client.AddSpell(new Spell(true) { ID = 10405 });
                }
            }
            else
            {
                if (client.Spells.ContainsKey(10405))
                {
                    client.RemoveSpell(new Spell(true) { ID = 10405 });
                }

            }

            if (client.Entity.Class >= 40 && client.Entity.Class <= 45 && client.Entity.FirstRebornClass <= 45 && client.Entity.FirstRebornClass >= 40 && client.Entity.SecondRebornClass <= 45 && client.Entity.SecondRebornClass >= 40)
            {
                if (!client.Spells.ContainsKey(10313))
                {
                    client.AddSpell(new Spell(true) { ID = 10313 });
                }
            }
            else
            {
                if (client.Spells.ContainsKey(10313))
                {
                    client.RemoveSpell(new Spell(true) { ID = 10313 });
                }

            }
            if (client.Entity.Class >= 20 && client.Entity.Class <= 25 && client.Entity.FirstRebornClass <= 25 && client.Entity.FirstRebornClass >= 20 && client.Entity.SecondRebornClass <= 25 && client.Entity.SecondRebornClass >= 20)
            {
                if (!client.Spells.ContainsKey(10311))
                {
                    client.AddSpell(new Spell(true) { ID = 10311 });
                }
            }
            else
            {
                if (client.Spells.ContainsKey(10311))
                {
                    client.RemoveSpell(new Spell(true) { ID = 10311 });
                }

            }

            if (client.Entity.Class >= 10 && client.Entity.Class <= 15 && client.Entity.FirstRebornClass <= 15 && client.Entity.FirstRebornClass >= 10 && client.Entity.SecondRebornClass <= 15 && client.Entity.SecondRebornClass >= 10)
            {
                if (!client.Spells.ContainsKey(10315))
                {
                    client.AddSpell(new Spell(true) { ID = 10315 });
                }
            }
            else
            {
                if (client.Spells.ContainsKey(10315))
                {
                    client.RemoveSpell(new Spell(true) { ID = 10315 });
                }

            }

            if (client.Entity.Class >= 40 && client.Entity.Class <= 45)
            {
                if (client.Spells.ContainsKey(1025))
                {
                    client.RemoveSpell(new Spell(true) { ID = 1025 });//SuperMan
                }
            }
            if (client.Entity.Class >= 142 && client.Entity.Class <= 145)
            {
                if (client.Spells.ContainsKey(6002))
                {
                    client.RemoveSpell(new Spell(true) { ID = 6002 });//PiosnStar
                }
            }
            client.WentToComplete = true;
            client.Entity.SendUpdates = true;
            foreach (Interfaces.IConquerItem item in client.Inventory.Objects)
            {
                item.Send(client);
            }
            foreach (Interfaces.IConquerItem item in client.Equipment.Objects)
                if (item != null)
                {
                    if (Database.ConquerItemInformation.BaseInformations.ContainsKey(item.ID))
                    {
                        item.Send(client);
                        ItemUsage usage = new ItemUsage(true) { ID = ItemUsage.EquipItem };
                        usage.UID = item.UID;
                        usage.dwParam = item.Position;
                        client.Send(usage);
                        client.LoadItemStats(client.Entity);
                        client.CalculateStatBonus();
                        client.CalculateHPBonus();
                    }
                    else
                    {
                        client.Equipment.DestroyArrow(item.Position);
                    }
                }

            client.LoadItemStats(client.Entity);
            client.CalculateStatBonus();
            client.CalculateHPBonus();
            client.Equipment.UpdateEntityPacket();
            ClientEquip equips = new ClientEquip();
            equips.DoEquips(client);
            client.Send(equips);
            foreach (var Guild in ServerBase.Kernel.Guilds.Values)
            {
                Guild.SendName(client);
            }
            if (client.Entity.ClanId != 0 && client.Entity.ClanRank != 0 && client.Entity.ClanName != "")
            {
                if (client.Entity.Myclan != null)
                {
                    Network.GamePackets.Clan cl = new PhoenixProject.Network.GamePackets.Clan(client, 1);
                    client.Send(cl.ToArray());
                }
            }
            ServerTime time = new ServerTime();
            time.Year = (uint)DateTime.Now.Year;
            time.Month = (uint)DateTime.Now.Month;
            time.DayOfYear = (uint)DateTime.Now.DayOfYear;
            time.DayOfMonth = (uint)DateTime.Now.Day;
            time.Hour = (uint)DateTime.Now.Hour;
            time.Minute = (uint)DateTime.Now.Minute;
            time.Second = (uint)DateTime.Now.Second;
            client.Send(time);

            client.Entity.DoubleExperienceTime = (ushort)(client.Entity.DoubleExperienceTime + (1 - 1));
            client.Entity.HeavenBlessing = (ushort)(client.Entity.HeavenBlessing + (1 - 1));

            if (client.Mentor != null)
            {
                if (client.Mentor.IsOnline)
                {
                    MentorInformation Information = new MentorInformation(true);
                    Information.Mentor_Type = 1;
                    Information.Mentor_ID = client.Mentor.Client.Entity.UID;
                    Information.Apprentice_ID = client.Entity.UID;
                    Information.Enrole_Date = client.Mentor.EnroleDate;
                    Information.Mentor_Level = client.Mentor.Client.Entity.Level;
                    Information.Mentor_Class = client.Mentor.Client.Entity.Class;
                    Information.Mentor_PkPoints = client.Mentor.Client.Entity.PKPoints;
                    Information.Mentor_Mesh = client.Mentor.Client.Entity.Mesh;
                    Information.Mentor_Online = true;
                    Information.Shared_Battle_Power = (uint)(((client.Mentor.Client.Entity.BattlePower - client.Mentor.Client.Entity.ExtraBattlePower) - (client.Entity.BattlePower - client.Entity.ExtraBattlePower)) / 3.3F);
                    Information.String_Count = 3;
                    Information.Mentor_Name = client.Mentor.Client.Entity.Name;
                    Information.Apprentice_Name = client.Entity.Name;
                    Information.Mentor_Spouse_Name = client.Mentor.Client.Entity.Spouse;
                    client.ReviewMentor();
                    client.Send(Information);

                    ApprenticeInformation AppInfo = new ApprenticeInformation();
                    AppInfo.Apprentice_ID = client.Entity.UID;
                    AppInfo.Apprentice_Level = client.Entity.Level;
                    AppInfo.Apprentice_Class = client.Entity.Class;
                    AppInfo.Apprentice_PkPoints = client.Entity.PKPoints;
                    AppInfo.Apprentice_Experience = client.AsApprentice.Actual_Experience;
                    AppInfo.Apprentice_Composing = client.AsApprentice.Actual_Plus;
                    AppInfo.Apprentice_Blessing = client.AsApprentice.Actual_HeavenBlessing;
                    AppInfo.Apprentice_Name = client.Entity.Name;
                    AppInfo.Apprentice_Online = true;
                    AppInfo.Apprentice_Spouse_Name = client.Entity.Spouse;
                    AppInfo.Enrole_date = client.Mentor.EnroleDate;
                    AppInfo.Mentor_ID = client.Mentor.ID;
                    AppInfo.Mentor_Mesh = client.Mentor.Client.Entity.Mesh;
                    AppInfo.Mentor_Name = client.Mentor.Name;
                    AppInfo.Type = 2;
                    client.Mentor.Client.Send(AppInfo);
                }
                else
                {
                    MentorInformation Information = new MentorInformation(true);
                    Information.Mentor_Type = 1;
                    Information.Mentor_ID = client.Mentor.ID;
                    Information.Apprentice_ID = client.Entity.UID;
                    Information.Enrole_Date = client.Mentor.EnroleDate;
                    Information.Mentor_Online = false;
                    Information.String_Count = 2;
                    Information.Mentor_Name = client.Mentor.Name;
                    Information.Apprentice_Name = client.Entity.Name;

                    client.Send(Information);
                }
            }
            NobilityInfo update = new NobilityInfo(true);
            update.Type = NobilityInfo.Icon;
            update.dwParam = client.NobilityInformation.EntityUID;
            update.UpdateString(client.NobilityInformation);
            client.Send(update);
            client.Entity.Update(Update.Merchant, 255, false);

            foreach (Interfaces.IConquerItem item in client.Inventory.Objects)
                item.Send(client);

            foreach (Interfaces.IConquerItem item in client.Equipment.Objects)
                if (item != null)
                {
                    if (Database.ConquerItemInformation.BaseInformations.ContainsKey(item.ID))
                    {
                        item.Send(client);
                        //kimoSystem.Threading.Thread.Sleep(1);
                        // item.Send(client);

                    }
                    else
                    {
                        client.Equipment.DestroyArrow(item.Position);
                        Console.WriteLine("Announcement: Item have been removed because of invalid info. UID: " + item.UID + ". OWNER: " + client.Entity.Name);
                    }
                }
            client.LoadItemStats(client.Entity);
            client.CalculateStatBonus();
            client.CalculateHPBonus();
            if (!client.Equipment.Free(5))
            {
                if (IsArrow(client.Equipment.TryGetItem(5).ID))
                {
                    if (client.Equipment.Free(4))
                        client.Equipment.DestroyArrow(5);
                    else
                    {
                        client.Equipment.Remove(5);
                    }
                }
            }
            client.GemAlgorithm();
            client.CalculateStatBonus();
            client.CalculateHPBonus();
            client.Entity.Stamina = 100;

            client.Send(new Message(String.Format(
             "Welcome in " + PhoenixProject.Database.rates.servername + " - Legends Return Season III", client.Entity.Name,
             client.Entity.LastLogin.ToLongDateString().Replace('-', ' '),
             client.Entity.LastLogin.ToLongTimeString()), System.Drawing.Color.Red,
             Message.Service));
            client.Entity.UpdateEffects(true);

            // client.Send(new Message("Welcome in "+Database.rates.servername+"", System.Drawing.Color.Red, Message.Middle));

            if (client.Entity.VIPLevel > 0)
            {
                Network.GamePackets.VipStatus vip = new Network.GamePackets.VipStatus();
                client.Send(vip.ToArray());
            }
            client.Send(new MapStatus() { BaseID = (ushort)client.Map.BaseID, ID = (uint)client.Map.ID, Status = Database.MapsTable.MapInformations[client.Map.ID].Status, Weather = Database.MapsTable.MapInformations[client.Map.ID].Weather });

            if (client.Entity.Hitpoints == 0)
                client.Entity.Hitpoints = 1;
            client.Entity.VIPLevel = (byte)(client.Entity.VIPLevel + 0);
            client.Entity.HandleTiming = true;
            if (client.Entity.GuildSharedBp != 0)
                client.Entity.Update(Network.GamePackets.Update.GuildShareBP, client.Entity.GuildSharedBp, false);

            if (client.Entity.ExtraBattlePower != 0)
                client.Entity.Update(Network.GamePackets.Update.ExtraBattlePower, client.Entity.ExtraBattlePower, false);
            if (client.Guild != null)
                client.Guild.SendAllyAndEnemy(client);
            if (Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityID > 2)
                client.Send(new Network.GamePackets.Message(Game.ConquerStructures.Broadcast.CurrentBroadcast.Message, "ALLUSERS", Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityName, System.Drawing.Color.Red, Network.GamePackets.Message.BroadcastMessage));
            client.Entity.Update(Network.GamePackets.Update.LuckyTimeTimer, (byte)client.BlessTime, false);
            if (client.Entity.HeavenBlessing != 0)
                client.Entity.Update(Network.GamePackets.Update.OnlineTraining, client.OnlineTrainingPoints, false);
            if (client.ClaimableItem.Count > 0)
                foreach (var item in client.ClaimableItem.Values)
                    item.Send(client);
            if (client.DeatinedItem.Count > 0)
                foreach (var item in client.DeatinedItem.Values)
                    item.Send(client);
            if (client.ItemGive == true)
            {
                client.Inventory.Add(1001010, 0, 5);
                if (client.Entity.Class != 70)
                {
                    client.Inventory.AddandWear(132008, 0, 1, client);

                }
                else
                {
                    client.Inventory.AddandWear(132008, 0, 1, client);
                }
                if (client.Entity.Class == 10 || client.Entity.Class == 20)
                {
                    client.Inventory.AddandWear(410301, 0, 1, client);

                }
                if (client.Entity.Class >= 100)
                {
                    client.Inventory.AddandWear(421301, 0, 1, client);

                }
                if (client.Entity.Class == 70)
                {
                    client.Inventory.AddandWear(611301, 0, 1, client);

                }
                if (client.Entity.Class == 60)
                {
                    client.Inventory.AddandWear(610301, 0, 1, client);

                }
                if (client.Entity.Class == 50)
                {
                    client.Inventory.AddandWear(601301, 0, 1, client);

                }
                if (client.Entity.Class == 40)
                {
                    client.Inventory.AddandWear(500301, 0, 1, client);

                }
                client.ItemGive = false;
            }
            client.Entity.RacePoints = client.Entity.RacePoints;
            send1136(client);
            client.Equipment.UpdateEntityPacket();
        }
示例#11
0
        static void LoginMessages(Client.GameState client)
        {
            if (client.WentToComplete)
                return;

            // ServerBase.Kernel.Elite_PK_Tournament.LoginClient(client);
            if (client.Entity.MapID == 6002)
                ServerBase.Kernel.Elite_PK_Tournament.ObtinedOutCoord(client);
            //client.Account.State = Database.AccountTable.AccountState.Player;
            client.WentToComplete = true;
            client.Entity.SendUpdates = true;
            Data datas = new Data(true);
            datas.UID = client.Entity.UID;
            datas.ID = 116;
            datas.dwParam = 1197;
            client.Send(datas);
            if (client.Entity.VIPLevel > 0)
            {
                VIPAdvanced vp = new VIPAdvanced(true);
                vp.UID = 65535;
                client.Send(vp);
            }
            #region Game Updates

            client.Send(new GameUpdates(GameUpdates.Header, "Sharpness-Co Updates" + DateTime.Now.ToString()));
            //clients.Send(new GameUpdates(GameUpdates.Body, ""));
            client.Send(new GameUpdates(GameUpdates.Body, "All Events now Fixed"));
            client.Send(new GameUpdates(GameUpdates.Body, "1.Ping now is Now fixed enjoy"));
            client.Send(new GameUpdates(GameUpdates.Body, "2.Pirate 95% done still need reborn and skills"));
            client.Send(new GameUpdates(GameUpdates.Body, "3.Clan system now fixed "));
            client.Send(new GameUpdates(GameUpdates.Body, "4.Attack now fixed"));
            client.Send(new GameUpdates(GameUpdates.Body, "5.MemoryAgate now works"));
            client.Send(new GameUpdates(GameUpdates.Body, "6.Refinery now works good"));
            client.Send(new GameUpdates(GameUpdates.Body, "7.DecreasePK NPC in TwinCity now can less your pk fast"));
            client.Send(new GameUpdates(GameUpdates.Body, "8.All characters can take +6 items from twin city"));
            client.Send(new GameUpdates(GameUpdates.Body, "9.Cheak every thing  about Donation on game site "));
            client.Send(new GameUpdates(GameUpdates.Body, "10.Only PM number 0115641487 for donate"));
            client.Send(new GameUpdates(GameUpdates.Footer, "There is only 2[PM] has [PM] of  endes on his name dont trust any one else"));
            #endregion
            //#region SubClass

            ////client.Send(new SubClass(client.Entity).ToArray());

            //SubClassShowFull sub = new SubClassShowFull(true);
            //sub.ID = 1;
            //sub.Level = client.Entity.SubClassLevel;
            //sub.Class = client.Entity.SubClass;
            //#region [Effects-Addition]
            //switch ((Conquer_Online_Server.Game.ClassID)client.Entity.SubClass)
            //{
            //    case Conquer_Online_Server.Game.ClassID.Apothecary:
            //        {
            //            //

            //            client.Entity.Statistics.Detoxication = (ushort)(client.Entity.SubClasses.Classes[(byte)Conquer_Online_Server.Game.ClassID.Apothecary].Phase * 8);
            //            //client.Entity.Statistics.Detoxication += (client.Entity.SubClasses.Classes[To].Level);
            //            break;
            //        }

            //}

            //#endregion

            //client.Send(sub);
            //#endregion
            if (client.Entity.Myclan != null)
            {
                Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 1);
                client.Send(cl.ToArray());
            }
            foreach (var Guild in ServerBase.Kernel.Guilds.Values)
            {
                Guild.SendName(client);
            }
            if (client.Entity.ElitePK == 1)
            {
                client.Entity.TitleActivated = 14;
                Database.SubClassTable.Update56(client.Entity);
                Conquer_Online_Server.Database.EntityTable.SaveTop(client.Entity);
            }
            //foreach (Client.GameState clients in ServerBase.Kernel.GamePool.Values)
            //{
            //    clients.Entity.Owner.Send(new Conquer_Online_Server.Network.GamePackets.Message("Name= [" + client.Entity.Name + "] Level= [" + client.Entity.Level + "] Reborn= [" + client.Entity.Reborn + "] CPS= [" + client.Entity.ConquerPoints + "] VIPLevel= [" + client.Entity.VIPLevel + "] " + " Has Logged On and " + " Players online= [" + ServerBase.Kernel.GamePool.Count + "]", System.Drawing.Color.White, 2005));

            //}
            if (client.Entity.AddFlower == 1)
                if (client.Entity.Body.ToString().EndsWith("3") || client.Entity.Body.ToString().EndsWith("4"))
                    client.Send(new Network.GamePackets.FlowerPacket(new Game.Struct.Flowers()).ToArray());

            ServerTime time = new ServerTime();
            time.Year = (uint)DateTime.Now.Year;
            time.Month = (uint)DateTime.Now.Month;
            time.DayOfYear = (uint)DateTime.Now.DayOfYear;
            time.DayOfMonth = (uint)DateTime.Now.Day;
            time.Hour = (uint)DateTime.Now.Hour;
            time.Minute = (uint)DateTime.Now.Minute;
            time.Second = (uint)DateTime.Now.Second;
            client.Send(time);
            client.Entity.Spouse = client.Entity.Spouse;

            if (client.Guild != null)
            {
                if (client.Entity.GuildRank == (ushort)Game.Enums.GuildMemberRank.DeputyLeader)
                {
                    if (client.Guild.Name == Game.ConquerStructures.Society.GuildWar.Pole.Name)
                    {
                        client.Entity.AddFlag(Update.Flags.TopDeputyLeader);
                    }
                }
                else if (client.Entity.GuildRank == (ushort)Game.Enums.GuildMemberRank.GuildLeader)
                {
                    if (client.Guild.Name == Game.ConquerStructures.Society.GuildWar.Pole.Name)
                    {
                        client.Entity.AddFlag(Update.Flags.TopGuildLeader);
                    }
                }

            }

            client.Entity.DoubleExperienceTimeV1 = (ushort)(client.Entity.DoubleExperienceTimeV1 + (1 - 1));
            client.Entity.DoubleExperienceTime = (ushort)(client.Entity.DoubleExperienceTime + (1 - 1));
            client.Entity.DoubleExperienceTime5 = (ushort)(client.Entity.DoubleExperienceTime5 + (1 - 1));
            client.Entity.DoubleExperienceTime10 = (ushort)(client.Entity.DoubleExperienceTime10 + (1 - 1));
            client.Entity.DoubleExperienceTime15 = (ushort)(client.Entity.DoubleExperienceTime15 + (1 - 1));
            client.Entity.HeavenBlessing = (ushort)(client.Entity.HeavenBlessing + (1 - 1));

            if (client.Mentor != null)
            {
                if (client.Mentor.IsOnline)
                {
                    MentorInformation Information = new MentorInformation(true);
                    Information.Mentor_Type = 1;
                    Information.Mentor_ID = client.Mentor.Client.Entity.UID;
                    Information.Apprentice_ID = client.Entity.UID;
                    Information.Enrole_Date = client.Mentor.EnroleDate;
                    Information.Mentor_Level = client.Mentor.Client.Entity.Level;
                    Information.Mentor_Class = client.Mentor.Client.Entity.Class;
                    Information.Mentor_PkPoints = client.Mentor.Client.Entity.PKPoints;
                    Information.Mentor_Mesh = client.Mentor.Client.Entity.Mesh;
                    Information.Mentor_Online = true;
                    Information.Shared_Battle_Power = (uint)(((client.Mentor.Client.Entity.BattlePower - client.Mentor.Client.Entity.ExtraBattlePower) - (client.Entity.BattlePower - client.Entity.ExtraBattlePower)) / 3.3F);
                    Information.String_Count = 3;
                    Information.Mentor_Name = client.Mentor.Client.Entity.Name;
                    Information.Apprentice_Name = client.Entity.Name;
                    Information.Mentor_Spouse_Name = client.Mentor.Client.Entity.Spouse;
                    client.ReviewMentor();
                    client.Send(Information);

                    ApprenticeInformation AppInfo = new ApprenticeInformation();
                    AppInfo.Apprentice_ID = client.Entity.UID;
                    AppInfo.Apprentice_Level = client.Entity.Level;
                    AppInfo.Apprentice_Class = client.Entity.Class;
                    AppInfo.Apprentice_PkPoints = client.Entity.PKPoints;
                    AppInfo.Apprentice_Experience = client.AsApprentice.Actual_Experience;
                    AppInfo.Apprentice_Composing = client.AsApprentice.Actual_Plus;
                    AppInfo.Apprentice_Blessing = client.AsApprentice.Actual_HeavenBlessing;
                    AppInfo.Apprentice_Name = client.Entity.Name;
                    AppInfo.Apprentice_Online = true;
                    AppInfo.Apprentice_Spouse_Name = client.Entity.Spouse;
                    AppInfo.Enrole_date = client.Mentor.EnroleDate;
                    AppInfo.Mentor_ID = client.Mentor.ID;
                    AppInfo.Mentor_Mesh = client.Mentor.Client.Entity.Mesh;
                    AppInfo.Mentor_Name = client.Mentor.Name;
                    AppInfo.Type = 2;
                    client.Mentor.Client.Send(AppInfo);
                }
                else
                {
                    MentorInformation Information = new MentorInformation(true);
                    Information.Mentor_Type = 1;
                    Information.Mentor_ID = client.Mentor.ID;
                    Information.Apprentice_ID = client.Entity.UID;
                    Information.Enrole_Date = client.Mentor.EnroleDate;
                    Information.Mentor_Online = false;
                    Information.String_Count = 2;
                    Information.Mentor_Name = client.Mentor.Name;
                    Information.Apprentice_Name = client.Entity.Name;

                    client.Send(Information);
                }
            }
            NobilityInfo update = new NobilityInfo(true);
            update.Type = NobilityInfo.Icon;
            update.dwParam = client.NobilityInformation.EntityUID;
            update.UpdateString(client.NobilityInformation);
            client.Send(update);
            client.Entity.Update(Update.Merchant, 255, false);

            client.Entity.Stamina = 100;
            //client.Send(new Message("Welcome to the Reborn of " + ServerBase.Constants.ServerName + "Conquer ! Same staff here", System.Drawing.Color.Red, Message.Talk));
            //client.Send(new Message("All monster drop CpsBag! With random Cps! ", System.Drawing.Color.Red, Message.Talk));
            //client.Send(new Message("If you need help! Use Service Chat", System.Drawing.Color.Red, Message.Talk));
            //client.Send(new Message("GuildWar Start: Saturday Hour: 18", System.Drawing.Color.Red, Message.Talk));
            //client.Send(new Message("GuildWar Finish: Sunday Hour: 10", System.Drawing.Color.Red, Message.Talk));
            string[] wm = File.ReadAllLines(ServerBase.Constants.WelcomeMessages);
            foreach (string line in wm)
            {
                if (line.Length == 0)
                    continue;
                if (line[0] == ';')
                    continue;
                client.Send(new Message(line, System.Drawing.Color.Red, Message.Talk));
            }

            //if (Database.VoteTable.CanVote(client))
            //{
            //    client.OnMessageBoxOK = delegate
            //    {
            //        Network.GamePackets.Data data = new Network.GamePackets.Data(true);
            //        data.UID = client.Entity.UID;
            //        data.ID = Network.GamePackets.Data.OpenCustom;
            //        data.dwParam = Network.GamePackets.Data.CustomCommands.Minimize;
            //        client.Send(data);
            //        client.Send(new Message(ServerBase.Constants.ServerWebsite + ServerBase.Constants.WebAccExt + ServerBase.Constants.WebVoteExt, System.Drawing.Color.Red, Network.GamePackets.Message.Website));
            //    };
            //    client.Send(new NpcReply(NpcReply.MessageBox, "Would you like to consider voting for us? With more votes we will be come a bigger community."));
            //}

            /*if (client.Entity.VIPLevel != 0)
            {
                Database.PremiumTable.getVipInfo(client);
                if (client.VIPDays != 0)
                {
                    if (DateTime.Now >= client.VIPDate.AddDays(client.VIPDays))
                    {
                        client.Entity.VIPLevel = 0;
                        client.Send(ServerBase.Constants.VIPExpired);
                    }
                    else
                    {
                        DateTime VipEnds = client.VIPDate.AddDays(client.VIPDays);
                        TimeSpan span = VipEnds.Subtract(DateTime.Now);
                        client.Send(ServerBase.Constants.VIPRemaining(span.Days.ToString(), span.Hours.ToString()));
                    }
                }
                else
                    client.Send(ServerBase.Constants.VIPLifetime);
            }*/
            //if (Program.Today == DayOfWeek.Saturday || Program.Today == DayOfWeek.Sunday)
            //    client.Send(new Message("Double experience is on.", System.Drawing.Color.Red, Message.World));

            client.Send(new MapStatus() { BaseID = client.Map.BaseID, ID = client.Map.ID, Status = Database.MapsTable.MapInformations[client.Map.ID].Status });

            if (client.Entity.Hitpoints == 0)
                client.Entity.Hitpoints = 1;
            client.Entity.VIPLevel = (byte)(client.Entity.VIPLevel + 0);
            client.Entity.HandleTiming = true;
            if (client.Entity.ExtraBattlePower != 0)
                client.Entity.Update(Network.GamePackets.Update.ExtraBattlePower, client.Entity.ExtraBattlePower, false);
            if (client.Guild != null)
                client.Guild.SendAllyAndEnemy(client);
            if (Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityID > 2)
                client.Send(new Network.GamePackets.Message(Game.ConquerStructures.Broadcast.CurrentBroadcast.Message, "ALLUSERS", Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityName, System.Drawing.Color.Red, Network.GamePackets.Message.BroadcastMessage));
            client.Entity.Update(Network.GamePackets.Update.LuckyTimeTimer, client.BlessTime, false);
            if (client.Entity.HeavenBlessing != 0)
                client.Entity.Update(Network.GamePackets.Update.OnlineTraining, client.OnlineTrainingPoints, false);
            if (client.ClaimableItem.Count > 0)
                foreach (var item in client.ClaimableItem.Values)
                    item.Send(client);
            if (client.DeatinedItem.Count > 0)
                foreach (var item in client.DeatinedItem.Values)
                    item.Send(client);

            foreach (Interfaces.IConquerItem item in client.Inventory.Objects)
                item.Send(client);

            foreach (Interfaces.IConquerItem item in client.Equipment.Objects)
                if (item != null)
                {
                    if (Database.ConquerItemInformation.BaseInformations.ContainsKey(item.ID))
                    {
                        item.Send(client);
                        ItemUsage usage = new ItemUsage(true) { ID = ItemUsage.EquipItem };
                        usage.UID = item.UID;
                        usage.dwParam = item.Position;
                        client.Send(usage);
                        client.LoadItemStats(item);
                    }
                    else
                    {
                        client.Equipment.DestroyArrow(item.Position);
                        Console.WriteLine("Announcement: Item have been removed because of invalid info. UID: " + item.UID + ". OWNER: " + client.Entity.Name);
                    }
                }
            if (!client.Equipment.Free(5))
            {
                if (IsArrow(client.Equipment.TryGetItem(5).ID))
                {
                    if (client.Equipment.Free(4))
                        client.Equipment.DestroyArrow(5);
                    else
                    {
                        if (client.Equipment.TryGetItem(4).ID / 1000 != 500)
                            client.Equipment.DestroyArrow(5);
                    }
                }
            }
            client.GemAlgorithm();
            client.CalculateStatBonus();
            client.CalculateHPBonus();
            client.SendStatMessage();
            // Conquer_Online_Server.Game.Attacking.Calculate.Vitals(client.Entity, true);
            client.Equipment.UpdateEntityPacket();
            EntityEquipment equips = new EntityEquipment(true);
            equips.ParseHero(client);
            client.Send(equips);
            System.Threading.Thread.Sleep(3500);
            //if ((int)client.Account.State >= 3)
            //    client.Entity.AddFlag(Update.Flags.Flashy);
        }
示例#12
0
        static void HandlePacket(byte[] packet, Client.GameState client)
        {
            if (packet == null)
                return;
            if (client == null)
                return;
            ushort Length = BitConverter.ToUInt16(packet, 0);
            ushort ID = BitConverter.ToUInt16(packet, 2);
            ushort ID2 = BitConverter.ToUInt16(packet, 4);
            switch (ID)
            {
                #region market quest
                case 2400:
                    {
                        if (client.Entity.QQ1 == 0)
                        {
                            client.Entity.Teleport(1068, 053, 055);
                        }
                        else
                        {
                            client.Send(new Message("you can only make quest once in day", Color.AntiqueWhite, 2005));
                        }

                        break;
                    }
                #endregion
                #region ElitePk Tournament 2223 | 2219
                case 2223:
                    {
                        if (client.Entity.MapID == 6002)
                            break;

                        if (ServerBase.Kernel.Elite_PK_Tournament.Start)
                            break;

                        GamePackets.Elite_Pk pk = new Elite_Pk(client.Entity.UID);
                        pk.Send(client);
                        break;
                    }
                case 2219:
                    {
                        if (client.Entity.MapID == 6002)
                            break;
                        byte[] sed = new byte[36]
                        {
                        0x1C ,0x00 ,0xAB ,0x08 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x03 ,0x00    //  ; «         
            ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x54 ,0x51 ,0x53 ,0x65     // ;            TQSe
            ,0x72 ,0x76 ,0x65 ,0x72                                         // ;rver
                        };
                        client.Send(sed);
                        break;

                    }
                case 1063:
                    {
                        GamePackets.Guild_Pk pk = new Guild_Pk(client.Entity.UID);
                        pk.Send(client);
                        //byte[] sed = new byte[346];
                        ////{0x5a ,0x01 ,0x27 ,0x04 ,0x09 ,0x00 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x08 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x21 ,0x42 ,0x72 ,0x61 ,0x73 ,0x69 ,0x6c ,0x54 ,0x6f ,0x50 ,0x54 ,0x65 ,0x61 ,0x6d ,0x21 ,0x00 ,0x45 ,0x2a ,0x00 ,0x00 ,0x0e ,0x00 ,0x00 ,0x00 ,0x40 ,0xd2 ,0xdf ,0x03 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x7e ,0x5e ,0x21 ,0x54 ,0x68 ,0x65 ,0x5f ,0x42 ,0x65 ,0x73 ,0x74 ,0x21 ,0x5e ,0x7e ,0x00 ,0x00 ,0x2f ,0x20 ,0x00 ,0x00 ,0x09 ,0x00 ,0x00 ,0x00 ,0x00 ,0x0e ,0x27 ,0x07 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x46 ,0x69 ,0x72 ,0x65 ,0x45 ,0x6d ,0x62 ,0x6c ,0x65 ,0x6d ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x20 ,0x1c ,0x00 ,0x00 ,0x17 ,0x00 ,0x00 ,0x00 ,0x00 ,0xe1 ,0xf5 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x7e ,0x44 ,0x2e ,0x30 ,0x2e ,0x4a ,0x2e ,0x7e ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x3f ,0x0c ,0x00 ,0x00 ,0x0d ,0x00 ,0x00 ,0x00 ,0x40 ,0xf6 ,0xd3 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x2d ,0x4e ,0x7e ,0x4f ,0x7e ,0x59 ,0x7e ,0x50 ,0x7e ,0x49 ,0x2d ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x9e ,0x06 ,0x00 ,0x00 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 ,0x5a ,0x62 ,0x02 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x53 ,0x75 ,0x70 ,0x72 ,0x65 ,0x6d ,0x65 ,0x7e ,0x46 ,0x6f ,0x72 ,0x63 ,0x65 ,0x00 ,0x00 ,0x00 ,0x2f ,0x06 ,0x00 ,0x00 ,0x03 ,0x00 ,0x00 ,0x00 ,0x00 ,0x2d ,0x31 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0xc8 ,0x00 ,0x00 ,0x00 ,0x53 ,0x69 ,0x6c ,0x65 ,0x6e ,0x54 ,0x5f ,0x48 ,0x65 ,0x41 ,0x6c ,0x4c ,0x23 ,0x30 ,0x31 ,0x00 ,0x40 ,0x03 ,0x00 ,0x00 ,0x04 ,0x00 ,0x00 ,0x00 ,0x80 ,0xf0 ,0xfa ,0x02 ,0x00 ,0x00 ,0x00 ,0x00 ,0xf4 ,0x01 ,0x00 ,0x00 ,0x21 ,0x4e ,0x6f ,0x86 ,0x4d ,0x65 ,0x72 ,0x63 ,0x59 ,0x21 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0xe8 ,0x01 ,0x00 ,0x00 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00

                        ////};
                        //client.Send(sed);
                        break;

                    }
                case 2224:
                    {

                        client.Send(packet);
                        break;

                    }
                case 2232:
                    {

                        //                        byte[] sed = new byte[36]
                        //                        {
                        //                        0x1C ,0x00 ,0xAB ,0x08 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x03 ,0x00    //  ; «         
                        //,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x54 ,0x51 ,0x53 ,0x65     // ;            TQSe
                        //,0x72 ,0x76 ,0x65 ,0x72                                         // ;rver
                        //                        };
                        client.Send(packet);
                        break;

                    }
                case 2233:
                    {

                        GamePackets.Team_Pk pk = new Team_Pk(client.Entity.UID);
                        pk.Send(client);
                        break;

                    }
                case 2252:
                    {

                        // byte[] sed = new byte[60];
                        // ;rver };
                        client.Send(packet);
                        break;

                    }
                case 1130:
                    {
                        if (client.Entity.TitlePacket != null)
                        {
                            if (packet[9] == 4)
                            {
                                if (client.Entity.TitlePacket.dwParam2 != 0)
                                    client.Entity.TitlePacket.Send(client);
                            }
                            if (packet[9] == 3)
                            {
                                client.Entity.TitleActivated = packet[8];
                                client.Send(packet);
                                client.SendScreen(client.Entity.SpawnPacket, false);
                            }
                        }
                        break;
                    }
                #endregion
                #region TopGuilds
                case 1058:
                    {
                        if (client.Guild != null && client.AsMember != null)
                        {
                            if (client.AsMember != null)
                            {
                                Writer.WriteUInt32((uint)client.AsMember.SilverDonation, 8, packet);
                                if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        if (client.AsMember.SilverDonation > client.Guild.money_donation)
                                        {
                                            client.Guild.money_donation = (uint)client.AsMember.SilverDonation;
                                            client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.OSupervisor;
                                            client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                        }

                                Writer.WriteUInt32((uint)client.AsMember.ConquerPointDonation, 20, packet);
                                if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        if (client.AsMember.ConquerPointDonation > client.Guild.cp_donaion)
                                        {
                                            client.Guild.cp_donaion = (uint)client.AsMember.ConquerPointDonation;
                                            client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.CPSupervisor;
                                            client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                        }

                            }
                            Writer.WriteUInt32(client.Entity.PKPoints, 12, packet);
                            if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                    if (client.Entity.PKPoints > client.Guild.pkp_donation)
                                    {
                                        client.Guild.pkp_donation = (uint)client.Entity.PKPoints;
                                        client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.PKSupervisor;
                                        client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                    }

                            if (client.ArenaStatistic != null)
                            {
                                Writer.WriteUInt32(client.ArenaStatistic.CurrentHonor, 24, packet);
                                if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        if (client.ArenaStatistic.CurrentHonor > client.Guild.honor_donation)
                                        {
                                            client.Guild.honor_donation = (uint)client.ArenaStatistic.CurrentHonor;
                                            client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.HonoraryManager;
                                            client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                        }
                            }
                            Writer.WriteUInt32(0, 16, packet);
                            if (client.Entity != null)
                                if (client.Entity.MyFlowers != null)
                                {
                                    Writer.WriteUInt32((uint)client.Entity.MyFlowers.RedRoses, 28, packet);
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                        if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                            if (client.Entity.MyFlowers.RedRoses > client.Guild.rose_donation)
                                            {
                                                client.Guild.rose_donation = (uint)client.Entity.MyFlowers.RedRoses;
                                                client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.RoseSupervisor;
                                                client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                            }

                                    Writer.WriteUInt32((uint)client.Entity.MyFlowers.Tulips, 32, packet);
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                        if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                            if (client.Entity.MyFlowers.Tulips > client.Guild.tuil_donation)
                                            {
                                                client.Guild.tuil_donation = (uint)client.Entity.MyFlowers.Tulips;
                                                client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.TulipFollower;
                                                client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                            }

                                    Writer.WriteUInt32((uint)client.Entity.MyFlowers.Lilies, 36, packet);
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                        if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                            if (client.Entity.MyFlowers.Lilies > client.Guild.lilies_donation)
                                            {
                                                client.Guild.lilies_donation = (uint)client.Entity.MyFlowers.Lilies;
                                                client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.LilySupervisor;
                                                client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                            }

                                    Writer.WriteUInt32((uint)client.Entity.MyFlowers.Orchads, 40, packet);
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                        if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                            if (client.Entity.MyFlowers.Orchads > client.Guild.orchid_donation)
                                            {
                                                client.Guild.orchid_donation = (uint)client.Entity.MyFlowers.Orchads;
                                                client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.OrchidFollower;
                                                client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                            }
                                    Writer.WriteUInt32((uint)(client.Entity.MyFlowers.Orchads
                                        + (uint)client.Entity.MyFlowers.RedRoses
                                        + (uint)client.Entity.MyFlowers.Tulips
                                        + (uint)client.Entity.MyFlowers.Lilies), 44, packet);
                                }
                            if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                {
                                    if (client.Entity.Name == client.Guild.LeaderName)
                                    {
                                        client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.LeaderSpouse;
                                        client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                    }
                                }
                            if (client.Guild != null)
                                client.Guild.SendGuild(client);
                            client.Send(packet);
                        }
                        break;
                    }
                #endregion
                #region Guild members (2102)
                case 2102:
                    {
                        ushort Page = BitConverter.ToUInt16(packet, 8);
                        if (client.Guild != null)
                        {
                            client.Guild.SendMembers(client, Page);
                        }
                        break;
                    }
                #endregion
                #region EnitityCreate (1001)
                case 1001:
                    {
                        if (client.Action == 1)
                        {
                            EnitityCreate EC = new EnitityCreate();
                            EC.Deserialize(packet);
                            string Message = "";
                            Boolean Created = Database.EntityTable.CreateEntity(EC, client, ref Message);
                            client.Send(new Message(Message, "ALLUSERS", System.Drawing.Color.Orange, GamePackets.Message.PopUP));
                            if (Created)
                                Console.WriteLine(client.Account.Username + " Sucesfully Created a new Character " + EC.Name);
                            client.JustCreated = true;
                        }
                        break;
                    }
                #endregion
                #region Chat/Message (1004)
                case 1004:
                    {
                        if (client.Action != 2)
                            return;
                        Message message = new Message();
                        message.Deserialize(packet);
                        if (message.__Message.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries).Length > 0)
                            message.__Message = message.__Message.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries)[0];
                        Chat(message, client);
                        break;
                    }
                #endregion
                #region Item/Ping (1009)
                case 1009:
                    {
                        if (client.Action != 2)
                            return;
                        ItemUsage usage = new ItemUsage(false);
                        usage.Deserialize(packet);
                        if (!client.Entity.Dead || usage.ID == ItemUsage.Ping)
                        {
                            switch (usage.ID)
                            {

                                case 52:
                                    {
                                        var item = Database.ConquerItemTable.LoadItem(usage.UID);
                                        item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.ChatItem;
                                        item.Send(client);
                                        break;
                                    }
                                case 41:
                                    {
                                        var item = Database.ConquerItemTable.LoadItem(usage.UID);
                                        usage.dwParam = 5;
                                        client.Send(usage);
                                        break;
                                    }
                                case ItemUsage.ArrowReload:
                                    {
                                        ReloadArrows(client.Equipment.TryGetItem(ConquerItem.LeftWeapon), client);

                                        break;
                                    }
                                case ItemUsage.ShowBoothItems:
                                    {
                                        ShowBoothItems(usage, client);
                                        break;
                                    }
                                case ItemUsage.AddItemOnBoothForSilvers:
                                case ItemUsage.AddItemOnBoothForConquerPoints:
                                    {
                                        AddItemOnBooth(usage, client);
                                        break;
                                    }
                                case ItemUsage.BuyFromBooth:
                                    {
                                        BuyFromBooth(usage, client);
                                        break;
                                    }
                                case ItemUsage.RemoveItemFromBooth:
                                    {
                                        RemoveItemFromBooth(usage, client);
                                        break;
                                    }
                                case ItemUsage.EquipItem:
                                    {
                                        EquipItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.UnequipItem:
                                    {
                                        UnequipItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.BuyFromNPC:
                                    {
                                        HandleBuyFromNPC(usage, client);
                                        break;
                                    }
                                case ItemUsage.SellToNPC:
                                    {
                                        HandleSellToNPC(usage, client);
                                        break;
                                    }
                                case ItemUsage.Repair:
                                    {
                                        HandleRepair(usage, client);
                                        break;
                                    }
                                case ItemUsage.MeteorUpgrade:
                                case ItemUsage.DragonBallUpgrade:
                                    {
                                        UpgradeItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.Ping:
                                    {
                                        if (Time32.Now < client.LastPing.AddSeconds(2))
                                        {
                                            client.PingCount++;
                                            if (client.PingCount == 40)
                                            {
                                                client.Send(new Message("Speed hack detected!", System.Drawing.Color.BlanchedAlmond, Message.TopLeft));
                                                client.Disconnect();
                                                return;
                                            }
                                        }

                                        if (client.Entity != null)
                                        {
                                            if (client.Entity.UID != 0)
                                            {
                                                if (!ServerBase.Kernel.GamePool.ContainsKey(client.Entity.UID))
                                                {
                                                    ServerBase.Kernel.GamePool.Add(client.Entity.UID, client);
                                                }
                                            }
                                        }

                                        client.LastPingT = client.LastPing;
                                        client.LastPing = Time32.Now;

                                        if (client.LastPing > client.LastPingT.AddSeconds(2))
                                            client.PingCount = 0;
                                        usage.TimeStamp += 120;
                                        // client.Send(ReturnFinal(packet));
                                        //Network.PacketHandler.HandleBuffer(packet, client);
                                        client.Send(usage);
                                        if (!ServerBase.Kernel.GamePool.ContainsKey(client.Entity.UID))
                                            if (client.Socket.Connected)
                                            {
                                                ServerBase.Kernel.GamePool.Add(client.Entity.UID, client);
                                                client.Screen.FullWipe();
                                                client.Screen.Reload(null);
                                            }
                                        break;
                                    }
                                case ItemUsage.ViewWarehouse:
                                    {
                                        usage.dwParam = client.MoneySave;
                                        client.Send(usage);
                                        break;
                                    }
                                case ItemUsage.WarehouseDeposit:
                                    {
                                        if (client.Entity.Money >= usage.dwParam)
                                        {
                                            client.Entity.Money -= usage.dwParam;
                                            client.MoneySave += usage.dwParam;
                                        }
                                        break;
                                    }
                                case ItemUsage.WarehouseWithdraw:
                                    {
                                        if (client.MoneySave >= usage.dwParam)
                                        {
                                            client.Entity.Money += usage.dwParam;
                                            client.MoneySave -= usage.dwParam;
                                        }
                                        break;
                                    }
                                case ItemUsage.DropItem:
                                    {
                                        DropItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.DropMoney:
                                    {
                                        DropMoney(usage, client);
                                        break;
                                    }
                                case ItemUsage.Enchant:
                                    {
                                        EnchantItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.SocketTalismanWithItem:
                                    {
                                        SocketTalismanWithItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.SocketTalismanWithCPs:
                                    {
                                        SocketTalismanWithCPs(usage, client);
                                        break;
                                    }
                                case 40:
                                    {
                                        uint ItemAdd = (uint)((packet[4] & 0xFF) | ((packet[5] & 0xFF) << 8) | ((packet[6] & 0xFF) << 16) | ((packet[7] & 0xFF) << 24));

                                        //PrintPacket(packet);
                                        Interfaces.IConquerItem item_new = null;
                                        if (client.Inventory.TryGetItem(ItemAdd, out item_new))
                                        {
                                            if (item_new.Bless == 7)
                                                return;

                                            Queue<uint> amount = new Queue<uint>(packet[20]);

                                            for (ushort i = 84; i < 84 + 4 * packet[20]; i += 4)
                                            {
                                                if (client.Inventory.ContainsUID((uint)((packet[i] & 0xFF) | ((packet[(byte)(i + 1)] & 0xFF) << 8) | ((packet[(byte)(i + 2)] & 0xFF) << 16) | ((packet[(byte)(i + 3)] & 0xFF) << 24))))
                                                    amount.Enqueue((uint)((packet[i] & 0xFF) | ((packet[(byte)(i + 1)] & 0xFF) << 8) | ((packet[(byte)(i + 2)] & 0xFF) << 16) | ((packet[(byte)(i + 3)] & 0xFF) << 24)));
                                                else
                                                    return;
                                            }

                                            byte oldbless = item_new.Bless;
                                            if (item_new.Bless == 0 && amount.Count == 5)
                                                item_new.Bless = 1;
                                            else if (item_new.Bless == 1 && amount.Count == 1)
                                                item_new.Bless = 3;
                                            else if (item_new.Bless == 3 && amount.Count == 3)
                                                item_new.Bless = 5;
                                            else if (item_new.Bless == 5 && amount.Count == 5)
                                                item_new.Bless = 7;
                                            if (oldbless == item_new.Bless)
                                                return;

                                            while (amount.Count != 0)
                                                client.Inventory.Remove(amount.Dequeue(), Conquer_Online_Server.Game.Enums.ItemUse.Remove, true);

                                            item_new.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
                                            item_new.Send(client);
                                            Database.ConquerItemTable.UpdateItem(item_new, client);
                                        }
                                        //client.Send(packet);
                                        break;
                                    }
                                case 53:
                                    {
                                        uint ItemAdd = BitConverter.ToUInt32(packet, 8);

                                        //Interfaces.IConquerItem item_new = null;
                                        //if (client.Inventory.TryGetItem(ItemAdd, out item_new))
                                        {
                                            uint obtined_points = 0;
                                            Database.ConquerItemInformation iteminfo = new Conquer_Online_Server.Database.ConquerItemInformation(ItemAdd, 0);
                                            Dictionary<uint, uint> amount = new Dictionary<uint, uint>();//packet[20]);
                                            for (ushort i = 80; i < 84 + 4 * packet[20]; i += 4)
                                            {
                                                uint item_swap = BitConverter.ToUInt32(packet, i);
                                                if (client.Inventory.ContainsUID(item_swap))
                                                {
                                                    Interfaces.IConquerItem item = null;
                                                    if (client.Inventory.TryGetItem(item_swap, out item))
                                                    {
                                                        amount.Add(item_swap, i);
                                                    }
                                                    switch (item.ID)
                                                    {
                                                        case 191505:
                                                        case 191605:
                                                        case 191705:
                                                        case 191805:
                                                        case 191905:
                                                        case 191405:
                                                        case 183325:
                                                        case 183315:
                                                        case 183375:
                                                        case 183305:
                                                            {
                                                                obtined_points += 300;
                                                                break;
                                                            }
                                                        default:
                                                            obtined_points += 50;
                                                            break;
                                                    }
                                                }
                                            }
                                            if (iteminfo.BaseInformation.ConquerPointsWorth > obtined_points)
                                            {
                                                uint add_cps = 0;
                                                add_cps = (uint)(iteminfo.BaseInformation.ConquerPointsWorth - obtined_points);
                                                if (add_cps < client.Entity.ConquerPoints)
                                                {
                                                    client.Entity.ConquerPoints -= add_cps;
                                                    foreach (uint key in amount.Keys)
                                                    {
                                                        if (client.Inventory.ContainsUID(key))
                                                            client.Inventory.Remove(key, Conquer_Online_Server.Game.Enums.ItemUse.Remove, true);
                                                    }
                                                    client.Inventory.Add(ItemAdd, 0, 1);

                                                }
                                            }
                                            else
                                            {
                                                foreach (uint key in amount.Keys)
                                                {
                                                    if (client.Inventory.ContainsUID(key))
                                                        client.Inventory.Remove(key, Conquer_Online_Server.Game.Enums.ItemUse.Remove, true);
                                                }
                                                client.Inventory.Add(ItemAdd, 0, 1);

                                            }
                                        }
                                        break;
                                    }
                                case ItemUsage.SocketerMan:
                                    {
                                        #region Socketing
                                        UInt32 Count = usage.dwExtraInfo, ItemUID = usage.UID;
                                        Byte Type = 0;
                                        Interfaces.IConquerItem Item = null;
                                        if (client.Inventory.TryGetItem(ItemUID, out Item))
                                        {
                                            #region Removing Used Items
                                            for (int i = 1; i <= Count; i++)
                                            {
                                                uint It = BitConverter.ToUInt32(packet, (int)(80 + (4 * i)));
                                                Interfaces.IConquerItem Rem = null;
                                                if (client.Inventory.TryGetItem(It, out Rem))
                                                {
                                                    if (Rem.ID == 1088000 && Count == 12)
                                                        Type = 1;
                                                    if (Rem.ID == 1088000 && Count == 1)
                                                        Type = 2;
                                                    if (Rem.ID == 1088000 && Count == 5)
                                                        Type = 3;
                                                    if (Rem.ID == 1200005 && Count == 1)
                                                        Type = 4;
                                                    if (Rem.ID == 1200006 && Count == 7)
                                                        Type = 5;
                                                    client.Inventory.Remove(Rem, Game.Enums.ItemUse.Remove);
                                                }
                                            }
                                            #endregion
                                            #region Type Switch
                                            switch (Type)
                                            {
                                                #region Open First Socket
                                                case 1:
                                                case 2:
                                                    {
                                                        usage.dwParam = 1;
                                                        Item.Mode = Game.Enums.ItemMode.Update;
                                                        Item.SocketOne = (Game.Enums.Gem)255;
                                                        Item.Send(client);
                                                        Item.Mode = Game.Enums.ItemMode.Default;
                                                        Conquer_Online_Server.Database.ConquerItemTable.UpdateSockets(Item, client);
                                                        break;
                                                    }
                                                #endregion
                                                #region Open Second Socket
                                                case 3:
                                                case 5:
                                                    {
                                                        usage.dwParam = 1;
                                                        Item.Mode = Game.Enums.ItemMode.Update;
                                                        Kernel.SendWorldMessage(new Message("Congratulations! " + client.Entity.Name + " has oppened the second socket into his/her item!", System.Drawing.Color.Yellow, 2011), Kernel.GamePool.Values, client.Entity.UID);
                                                        Item.SocketTwo = (Game.Enums.Gem)255;
                                                        Item.Send(client);
                                                        Item.Mode = Game.Enums.ItemMode.Default;
                                                        Conquer_Online_Server.Database.ConquerItemTable.UpdateSockets(Item, client);
                                                        break;
                                                    }
                                                #endregion
                                                #region Using Tough Drill
                                                case 4:
                                                    {
                                                        if (ServerBase.Kernel.Rate(10))
                                                        {
                                                            usage.dwParam = 1;
                                                            Item.Mode = Game.Enums.ItemMode.Update;
                                                            Kernel.SendWorldMessage(new Message("Congratulations! " + client.Entity.Name + " has oppened the second socket into his/her item!", System.Drawing.Color.Yellow, 2011), Kernel.GamePool.Values, client.Entity.UID);
                                                            Item.SocketTwo = (Game.Enums.Gem)255;
                                                            Item.Send(client);
                                                            Item.Mode = Game.Enums.ItemMode.Default;
                                                            Conquer_Online_Server.Database.ConquerItemTable.UpdateSockets(Item, client);
                                                        }
                                                        else
                                                        {
                                                            usage.dwParam = 0;
                                                            client.Send(new Message("The ToughDrill has failed. Try your lucky next time!", System.Drawing.Color.Red, Message.TopLeft));
                                                            client.Inventory.Add(1200006, 0, 1);
                                                        }
                                                        break;
                                                    }
                                                #endregion
                                            }
                                            #endregion
                                        }
                                        //dWParam Values, = 0 = Failed, 1 = Suceed, 2 = Nothing
                                        client.Send(usage);
                                        #endregion
                                        break;
                                    }
                                case ItemUsage.RedeemGear:
                                    {
                                        var item = client.DeatinedItem[usage.UID];
                                        if (item != null)
                                        {
                                            if (DateTime.Now > item.Date.AddDays(7))
                                            {
                                                client.Send(new Message("This item is expired!", System.Drawing.Color.Red, Message.TopLeft));

                                                return;
                                            }
                                            if (client.Entity.ConquerPoints >= item.ConquerPointsCost)
                                            {
                                                client.Entity.ConquerPoints -= item.ConquerPointsCost;

                                                usage.dwParam = client.Entity.UID;
                                                usage.dwExtraInfo3 = item.ConquerPointsCost;
                                                client.Send(usage);

                                                client.Inventory.Add(item.Item, Conquer_Online_Server.Game.Enums.ItemUse.Add);

                                                Database.DetainedItemTable.Redeem(item, client);
                                                client.DeatinedItem.Remove(item.UID);

                                                if (ServerBase.Kernel.GamePool.ContainsKey(item.GainerUID))
                                                {
                                                    var pClient = ServerBase.Kernel.GamePool[item.GainerUID];
                                                    pClient.ClaimableItem[item.UID].OwnerUID = 500;
                                                    pClient.ClaimableItem[item.UID].MakeItReadyToClaim();
                                                    usage.dwParam = pClient.Entity.UID;
                                                    usage.ID = ItemUsage.ClaimGear;
                                                    pClient.Send(usage);
                                                    pClient.ClaimableItem[item.UID].Send(pClient);
                                                }

                                                Message message = new Message("Thank you for arresting " + item.OwnerName + ", " + item.GainerName + ". The arrested one has redeemed his items and you have received a great deal of ConquerPoints as reward. Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
                                                ServerBase.Kernel.SendWorldMessage(message, ServerBase.Kernel.GamePool.Values);
                                            }
                                        }
                                        else
                                        {
                                            client.Send(new Message("The item you want to redeem has already been redeemed.", System.Drawing.Color.Red, Message.TopLeft));
                                        }
                                        break;
                                    }
                                case ItemUsage.ClaimGear:
                                    {
                                        var item = client.ClaimableItem[usage.UID];
                                        if (item != null)
                                        {
                                            if (item.Bound)
                                            {
                                                client.Send(new Message("Unnclaimable item!", System.Drawing.Color.Red, Message.TopLeft));
                                                return;
                                            }
                                            if (DateTime.Now < item.Date.AddDays(7) && item.OwnerUID != 500)
                                            {
                                                client.Send(new Message("This item is not expired. You cannot claim it yet!", System.Drawing.Color.Red, Message.TopLeft));
                                                return;
                                            }
                                            if (item.OwnerUID == 500)
                                                client.Entity.ConquerPoints += item.ConquerPointsCost;
                                            else
                                            {
                                                client.Inventory.Add(item.Item, Conquer_Online_Server.Game.Enums.ItemUse.Move);
                                                Message message = new Message("Thank you for arresting " + item.OwnerName + ", " + item.GainerName + ". The arrested one has redeemed his items and you have received a great deal of ConquerPoints as reward. Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
                                                ServerBase.Kernel.SendWorldMessage(message, ServerBase.Kernel.GamePool.Values);
                                            }
                                            Database.DetainedItemTable.Claim(item, client);
                                            client.ClaimableItem.Remove(item.UID);

                                            usage.dwParam = client.Entity.UID;
                                            usage.dwExtraInfo3 = item.ConquerPointsCost;
                                            client.Send(usage);
                                        }
                                        else
                                        {
                                            client.Send(new Message("The item you want to claim has already been claimed.", System.Drawing.Color.Red, Message.TopLeft));
                                        }
                                        break;
                                    }
                                case 34:
                                    {
                                        break;
                                    }
                                case 45:
                                    {
                                        client.Entity.Teleport(1002, 429, 378);
                                        break;
                                    }
                                default:
                                    {
                                        Console.WriteLine("Unhandled item usage type : " + usage.ID);
                                        break;
                                    }
                            }
                        }
                        break;
                    }
                #endregion
                #region String (1015)
                case 1015:
                    {
                        if (client.Action != 2)
                            return;
                        _String stringpacket = new _String(false);
                        stringpacket.Deserialize(packet);
                        switch (stringpacket.Type)
                        {
                            case _String.WhisperDetails:
                                {
                                    if (stringpacket.Texts.Count > 0)
                                    {
                                        var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                        varr.MoveNext();
                                        int COunt = ServerBase.Kernel.GamePool.Count;
                                        for (uint x = 0;
                                            x < COunt;
                                            x++)
                                        {
                                            if (x >= COunt) break;

                                            Client.GameState pClient = (varr.Current as Client.GameState);

                                            if (pClient.Entity.Name == stringpacket.Texts[0])
                                            {
                                                string otherstring = "";
                                                otherstring += pClient.Entity.UID + " ";
                                                otherstring += pClient.Entity.Level + " ";
                                                otherstring += pClient.Entity.BattlePower + " #";
                                                if (pClient.Entity.GuildID != 0)
                                                    otherstring += pClient.Guild.Name + " fNone# ";
                                                else
                                                    otherstring += "None fNone# ";
                                                otherstring += pClient.Entity.Spouse + " ";
                                                otherstring += (byte)(pClient.Entity.NobilityRank) + " ";
                                                if (pClient.Entity.Body % 10 < 3)
                                                    otherstring += "1";
                                                else
                                                    otherstring += "0";
                                                stringpacket.Texts.Add(otherstring);
                                                client.Send(stringpacket);
                                            }

                                            varr.MoveNext();

                                        }
                                    }
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region KnownPersons (1019)
                case 1019:
                    {
                        KnownPersons knownP = new KnownPersons(false);
                        knownP.Deserialize(packet);
                        switch (knownP.Type)
                        {
                            case KnownPersons.RequestFriendship:
                                {
                                    AddFriend(knownP, client);
                                    break;
                                }
                            case KnownPersons.RemovePerson:
                                {
                                    RemoveFriend(knownP, client);
                                    break;
                                }
                            case KnownPersons.RemoveEnemy:
                                {
                                    RemoveEnemy(knownP, client);
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region Attack (1022)
                case 1022:
                    {
                        if (client.Action != 2)
                            return;
                        uint dmg = BitConverter.ToUInt32(packet, 24);
                        uint AttackType = BitConverter.ToUInt32(packet, 20);
                        switch (AttackType)
                        {
                            case 39:
                                {
                                    if (!Kernel.VotePool.ContainsKey(client.Account.IP))
                                    {
                                        if (!Kernel.VotePoolUid.ContainsKey(client.Entity.UID))
                                        {
                                            client.Entity.ConquerPoints += 1000;
                                            Conquer_Online_Server.Game.ConquerStructures.PlayersVot Vot = new Conquer_Online_Server.Game.ConquerStructures.PlayersVot();
                                            Vot.AdressIp = client.Account.IP;
                                            Vot.Uid = client.Entity.UID;
                                            Kernel.VotePool.Add(Vot.AdressIp, Vot);
                                            Kernel.VotePoolUid.Add(Vot.Uid, Vot);
                                            Database.EntityTable.SavePlayersVot(Vot);
                                            client.Send(new Conquer_Online_Server.Network.GamePackets.Message("http://5.41.141.216/index.php", 2105));
                                            client.Send(new Message("You Have clamied your Prize 1k Cps Server ", Color.Brown, 1000000));
                                        }
                                        else
                                        {
                                            client.Send(new Conquer_Online_Server.Network.GamePackets.Message("http://5.41.141.216/index.php", 2105));
                                            client.Send(new Message("you can only take prize once in day", Color.Brown, 10000000));
                                        }
                                    }
                                    else
                                    {
                                        client.Send(new Conquer_Online_Server.Network.GamePackets.Message("http://5.41.141.216/index.php", 2105));
                                        client.Send(new Message("you can only take prize once in day", Color.Brown, 10000000));
                                    }

                                    break;
                                }
                            default:
                                {
                                    GamePackets.Attack attack = new Attack(false);
                                    attack.Deserialize(packet);
                                    if (client.Entity.ContainsFlag(Update.Flags.Ride) && !client.Entity.Owner.Equipment.Free(18))
                                    {
                                        Attack(attack, client);
                                        return;
                                    }
                                    else
                                    {
                                        client.Entity.RemoveFlag(Update.Flags.Ride);
                                    }
                                    Attack(attack, client);
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region Teams (1023)
                case 1023:
                    {
                        if (client.Action != 2)
                            return;
                        Team teamPacket = new Team();
                        teamPacket.Deserialize(packet);
                        switch (teamPacket.Type)
                        {
                            case Team.Create: CreateTeam(teamPacket, client); break;
                            case Team.AcceptJoinRequest: AcceptRequestToJoinTeam(teamPacket, client); break;
                            case Team.AcceptInvitation: AcceptInviteToJoinTeam(teamPacket, client); break;
                            case Team.InviteRequest: SendInviteToJoinTeam(teamPacket, client); break;
                            case Team.JoinRequest: SendRequestJoinToTeam(teamPacket, client); break;
                            case Team.ExitTeam: LeaveTeam(teamPacket, client); break;
                            case Team.Dismiss: DismissTeam(teamPacket, client); break;
                            case Team.Kick: KickFromTeam(teamPacket, client); break;
                            case Team.ForbidJoining:
                                {
                                    if (client.Team != null && client.Team.Teammates != null) foreach (Client.GameState Teammate in client.Team.Teammates)
                                            if (Teammate != null)
                                            {
                                                Teammate.Team.ForbidJoin = true;
                                                Teammate.Send(teamPacket);
                                            }

                                    break;
                                }
                            case Team.UnforbidJoining:
                                {
                                    if (client.Team != null && client.Team.Teammates != null) foreach (Client.GameState Teammate in client.Team.Teammates)
                                            if (Teammate != null)
                                            {
                                                Teammate.Team.ForbidJoin = false;
                                                Teammate.Send(teamPacket);
                                            }

                                    break;
                                }
                            case Team.LootMoneyOff:
                                {
                                    if (client.Team != null && client.Team.Teammates != null) foreach (Client.GameState Teammate in client.Team.Teammates)
                                            if (Teammate != null)
                                            {
                                                Teammate.Team.PickupMoney = true;
                                                Teammate.Send(teamPacket);
                                            }
                                    break;
                                }
                            case Team.LootMoneyOn:
                                {
                                    if (client.Team != null && client.Team.Teammates != null) foreach (Client.GameState Teammate in client.Team.Teammates)
                                            if (Teammate != null)
                                            {
                                                Teammate.Team.PickupMoney = false;
                                                Teammate.Send(teamPacket);
                                            }
                                    break;
                                }
                            case Team.LootItemsOn:
                                {
                                    if (client.Team != null && client.Team.Teammates != null) foreach (Client.GameState Teammate in client.Team.Teammates)
                                            if (Teammate != null)
                                            {
                                                Teammate.Team.PickupItems = true;
                                                Teammate.Send(teamPacket);
                                            }
                                    break;
                                }
                            case Team.LootItemsOff:
                                {
                                    if (client.Team != null && client.Team.Teammates != null) foreach (Client.GameState Teammate in client.Team.Teammates)
                                            if (Teammate != null)
                                            {
                                                Teammate.Team.PickupItems = false;
                                                Teammate.Send(teamPacket);
                                            }
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region Atributes Set (1024)
                case 1024:
                    {
                        if (client.Action != 2)
                            return;
                        ushort AddStr = BitConverter.ToUInt16(packet, 8);
                        ushort AddAgi = BitConverter.ToUInt16(packet, 12);
                        ushort AddVit = BitConverter.ToUInt16(packet, 16);
                        ushort AddSpi = BitConverter.ToUInt16(packet, 20);
                        if (AddStr > 0)
                        {
                            if (client.Entity.Atributes >= AddStr)
                            {
                                client.Entity.Atributes -= AddStr;
                                client.Entity.Strength += AddStr;
                            }
                        }
                        if (AddAgi > 0)
                        {
                            if (client.Entity.Atributes >= AddAgi)
                            {
                                client.Entity.Atributes -= AddAgi;
                                client.Entity.Agility += AddAgi;
                            }
                        }
                        if (AddVit > 0)
                        {
                            if (client.Entity.Atributes >= AddVit)
                            {
                                client.Entity.Atributes -= AddVit;
                                client.Entity.Vitality += AddVit;
                            }
                        }
                        if (AddSpi > 0)
                        {
                            if (client.Entity.Atributes >= AddSpi)
                            {
                                client.Entity.Atributes -= AddSpi;
                                client.Entity.Spirit += AddSpi;
                            }
                        }
                        //Conquer_Online_Server.Game.Attacking.Calculate.Vitals(client.Entity, true);
                        client.CalculateStatBonus();
                        client.CalculateHPBonus();
                        client.GemAlgorithm();
                        client.SendStatMessage();
                        break;
                    }
                #endregion
                #region Socketing (1027)
                case 1027:
                    {
                        EmbedSocket socket = new EmbedSocket(false);
                        socket.Deserialize(packet);
                        SocketItem(socket, client);
                        break;
                    }
                #endregion
                #region ItemAdding Stabilization
                case 1038:
                    {
                        ItemAddingStabilization stabilization = new ItemAddingStabilization(false);
                        stabilization.Deserialize(packet);
                        StabilazeArtifact(stabilization, client);
                        break;
                    }
                #endregion
                #region LoginPacket (1052)
                case 1052:
                    {
                        if (client.Action == 1)
                        {
                            Connect connect = new Connect();
                            connect.Deserialize(packet);
                            AppendConnect(connect, client);
                        }
                        else
                            client.Disconnect();
                        break;
                    }
                #endregion
                #region Trade (1056)
                case 1056:
                    {
                        if (client.Action != 2)
                            return;
                        Trade trade = new Trade(false);
                        trade.Deserialize(packet);
                        switch (trade.Type)
                        {
                            case Trade.Request:
                                RequestTrade(trade, client);
                                break;
                            case Trade.Close:
                                CloseTrade(trade, client);
                                break;
                            case Trade.AddItem:
                                AddTradeItem(trade, client);
                                break;
                            case Trade.SetMoney:
                                SetTradeMoney(trade, client);
                                break;
                            case Trade.SetConquerPoints:
                                SetTradeConquerPoints(trade, client);
                                break;
                            case Trade.Accept:
                                AcceptTrade(trade, client);
                                break;
                        }
                        break;
                    }
                #endregion
                #region Floor items (1101)
                case 1101:
                    {
                        if (client.Action != 2)
                            return;
                        FloorItem floorItem = new FloorItem(false);
                        floorItem.Deserialize(packet);
                        PickupItem(floorItem, client);
                        break;
                    }
                #endregion
                #region Warehouses (1102)
                case 1102:
                    {
                        if (client.Action != 2)
                            return;
                        Warehouse warehousepacket = new Warehouse(false);
                        warehousepacket.Deserialize(packet);
                        switch (warehousepacket.Type)
                        {
                            case Warehouse.Entire:
                                {
                                    Game.ConquerStructures.Warehouse wh = client.Warehouses[(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID)warehousepacket.NpcID];
                                    if (wh == null) return;
                                    byte count = 0;
                                    warehousepacket.Count = 1;
                                    warehousepacket.Type = Warehouse.AddItem;
                                    for (; count < wh.Count; count++)
                                    {
                                        warehousepacket.Append(wh.Objects[count]);
                                        client.Send(warehousepacket);
                                    }
                                    break;
                                }
                            case Warehouse.AddItem:
                                {
                                    Game.ConquerStructures.Warehouse wh = client.Warehouses[(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID)warehousepacket.NpcID];
                                    if (wh == null) return;
                                    Interfaces.IConquerItem item = null;
                                    if (client.Inventory.TryGetItem(warehousepacket.UID, out item))
                                    {
                                        if (wh.Add(item))
                                        {
                                            warehousepacket.UID = 0;
                                            warehousepacket.Count = 1;
                                            warehousepacket.Append(item);
                                            client.Send(warehousepacket);
                                            return;
                                        }
                                    }
                                    break;
                                }
                            case Warehouse.RemoveItem:
                                {
                                    Game.ConquerStructures.Warehouse wh = client.Warehouses[(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID)warehousepacket.NpcID];
                                    if (wh == null) return;
                                    if (wh.ContainsUID(warehousepacket.UID))
                                    {
                                        if (wh.Remove(warehousepacket.UID))
                                        {
                                            client.Send(warehousepacket);
                                            return;
                                        }
                                    }
                                    break;
                                }
                            default:
                                {
                                    Console.WriteLine("Unknown type: " + warehousepacket.Type);
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region Guild command (1107)
                case 1107:
                    {
                        GuildCommand command = new GuildCommand(false);
                        command.Deserialize(packet);
                        switch (command.Type)
                        {
                            case GuildCommand.Neutral1:
                            case GuildCommand.Neutral2:
                                {
                                    string name = System.Text.ASCIIEncoding.ASCII.GetString(packet, 26, packet[25]);
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            client.Guild.RemoveAlly(name);
                                            foreach (var guild in ServerBase.Kernel.Guilds.Values)
                                            {
                                                if (guild.Name == name && client.Guild.Name != name)
                                                {
                                                    guild.RemoveAlly(client.Guild.Name);
                                                }
                                            }
                                            client.Guild.RemoveEnemy(name);
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.Allied:
                                {
                                    string name = System.Text.ASCIIEncoding.ASCII.GetString(packet, 26, packet[25]);
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            AllyGuilds(name, client);
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.Enemied:
                                {
                                    string name = System.Text.ASCIIEncoding.ASCII.GetString(packet, 26, packet[25]);
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            client.Guild.AddEnemy(name);
                                        }
                                    }
                                    break;
                                }
                            default:
                                {
                                    client.Send(packet);
                                    break;
                                }
                            case GuildCommand.Bulletin:
                                {
                                    string message = System.Text.ASCIIEncoding.ASCII.GetString(packet, 26, packet[25]);
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            client.Guild.Bulletin = message;
                                            client.Guild.SendGuild(client);
                                            Database.GuildTable.UpdateBulletin(client.Guild, client.Guild.Bulletin);
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.DonateSilvers:
                                {
                                    if (client.Guild != null)
                                    {
                                        if (client.Entity.Money >= command.dwParam)
                                        {
                                            client.Guild.SilverFund += command.dwParam;
                                            Database.GuildTable.SaveFunds(client.Guild);
                                            client.AsMember.SilverDonation += command.dwParam;
                                            client.Entity.Money -= command.dwParam;
                                            client.Guild.SendGuild(client);
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.DonateConquerPoints:
                                {
                                    if (client.Guild != null)
                                    {
                                        if (client.Entity.ConquerPoints >= command.dwParam)
                                        {
                                            client.Guild.ConquerPointFund += command.dwParam;
                                            Database.GuildTable.SaveFunds(client.Guild);
                                            client.AsMember.ConquerPointDonation += command.dwParam;
                                            client.Entity.ConquerPoints -= command.dwParam;
                                            client.Guild.SendGuild(client);
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.Refresh:
                                {
                                    if (client.AsMember != null)
                                    {
                                        if (client.Guild != null)
                                            client.Guild.SendGuild(client);
                                    }
                                    break;
                                }
                            case GuildCommand.Discharge:
                                {
                                    string name = System.Text.ASCIIEncoding.ASCII.GetString(packet, 26, packet[25]);
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            var member = client.Guild.GetMemberByName(name);
                                            if (member.ID != client.Entity.UID)
                                            {
                                                if (member.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                                {
                                                    client.Guild.DeputyLeaderCount--;
                                                    member.Rank = Conquer_Online_Server.Game.Enums.GuildMemberRank.Member;
                                                    if (member.IsOnline)
                                                    {
                                                        client.Guild.SendGuild(member.Client);
                                                        member.Client.Entity.GuildRank = (ushort)member.Rank;
                                                        member.Client.Screen.FullWipe();
                                                        member.Client.Screen.Reload(null);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.Promote:
                                {
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            if (client.Guild.Members.ContainsKey(command.dwParam))
                                            {
                                                var member = client.Guild.Members[command.dwParam];
                                                if (member.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.Member)
                                                {
                                                    member.Rank = Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader;
                                                    if (member.IsOnline)
                                                    {
                                                        client.Guild.SendGuild(member.Client);
                                                        member.Client.Entity.GuildRank = (ushort)member.Rank;
                                                        member.Client.Screen.FullWipe();
                                                        member.Client.Screen.Reload(null);
                                                    }
                                                }
                                                else if (member.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                                {
                                                    member.Rank = Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader;
                                                    if (member.IsOnline)
                                                    {
                                                        client.Guild.SendGuild(member.Client);
                                                        member.Client.Entity.GuildRank = (ushort)member.Rank;
                                                        member.Client.Screen.FullWipe();
                                                        member.Client.Screen.Reload(null);
                                                    }
                                                    client.AsMember.Rank = Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader;
                                                    client.Guild.SendGuild(client);
                                                    client.Entity.GuildRank = (ushort)client.AsMember.Rank;
                                                    client.Screen.FullWipe();
                                                    client.Screen.Reload(null);
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.JoinRequest:
                                {
                                    if (ServerBase.Kernel.GamePool.ContainsKey(command.dwParam))
                                    {
                                        var Client = ServerBase.Kernel.GamePool[command.dwParam];
                                        if (Client.OnHoldGuildJoin == client.OnHoldGuildJoin && Client.OnHoldGuildJoin != 0)
                                        {
                                            if (Client.Guild != null)
                                            {
                                                if (Client.AsMember.Rank != Conquer_Online_Server.Game.Enums.GuildMemberRank.Member)
                                                {
                                                    Client.Guild.AddMember(client);
                                                    Client.OnHoldGuildJoin = 0;
                                                    client.OnHoldGuildJoin = 0;
                                                }
                                            }
                                            else
                                            {
                                                if (client.AsMember.Rank != Conquer_Online_Server.Game.Enums.GuildMemberRank.Member)
                                                {
                                                    client.Guild.AddMember(Client);
                                                    Client.OnHoldGuildJoin = 0;
                                                    client.OnHoldGuildJoin = 0;
                                                }
                                            }
                                            return;
                                        }
                                        if (client.Guild == null)
                                        {
                                            command.dwParam = client.Entity.UID;
                                            Client.Send(command);
                                            Client.OnHoldGuildJoin = (uint)new Random().Next();
                                            client.OnHoldGuildJoin = Client.OnHoldGuildJoin;
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.InviteRequest:
                                {
                                    if (ServerBase.Kernel.GamePool.ContainsKey(command.dwParam))
                                    {
                                        var Client = ServerBase.Kernel.GamePool[command.dwParam];
                                        if (Client.OnHoldGuildJoin == client.OnHoldGuildJoin && Client.OnHoldGuildJoin != 0)
                                        {
                                            if (Client.Guild != null)
                                            {
                                                if (Client.AsMember.Rank != Conquer_Online_Server.Game.Enums.GuildMemberRank.Member)
                                                {
                                                    Client.Guild.AddMember(client);
                                                    Client.OnHoldGuildJoin = 0;
                                                    client.OnHoldGuildJoin = 0;
                                                }
                                            }
                                            else
                                            {
                                                if (client.AsMember.Rank != Conquer_Online_Server.Game.Enums.GuildMemberRank.Member)
                                                {
                                                    client.Guild.AddMember(Client);
                                                    Client.OnHoldGuildJoin = 0;
                                                    client.OnHoldGuildJoin = 0;
                                                }
                                            }
                                            return;
                                        }
                                        if (client.Guild != null)
                                        {
                                            command.dwParam = client.Entity.UID;
                                            Client.Send(command);
                                            Client.OnHoldGuildJoin = (uint)new Random().Next();
                                            client.OnHoldGuildJoin = Client.OnHoldGuildJoin;
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.Quit:
                                {
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank != Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            client.Guild.ExpelMember(client.Entity.Name, true);
                                        }
                                    }
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region Enlight (1127)
                case 1127:
                    {
                        Enlight enlight = new Enlight(false);
                        enlight.Deserialize(packet);
                        if (ServerBase.Kernel.GamePool.ContainsKey(enlight.Enlighted))
                        {
                            var Client = ServerBase.Kernel.GamePool[enlight.Enlighted];

                            if (enlight.Enlighter == client.Entity.UID && enlight.Enlighted != enlight.Enlighter)
                            {
                                if (Client.Entity.ReceivedEnlightenPoints < 5)
                                {
                                    if (client.Entity.EnlightenPoints >= 100)
                                    {
                                        if (Client.Entity.EnlightmentTime <= 80)
                                        {
                                            client.Entity.EnlightenPoints -= 100;
                                            Client.Entity.EnlightmentStamp = Time32.Now;
                                            Client.IncreaseExperience(Game.Attacking.Calculate.Percent((int)Client.ExpBall, .10F), false);
                                            Client.SendScreen(packet, true);
                                            Client.Entity.ReceivedEnlightenPoints++;
                                            Client.Entity.EnlightmentTime += 20;
                                            if (client.Entity.EnlightmentTime > 80)
                                                client.Entity.EnlightmentTime = 100;
                                            else if (client.Entity.EnlightmentTime > 60)
                                                client.Entity.EnlightmentTime = 80;
                                            else if (client.Entity.EnlightmentTime > 40)
                                                client.Entity.EnlightmentTime = 60;
                                            else if (client.Entity.EnlightmentTime > 20)
                                                client.Entity.EnlightmentTime = 40;
                                            else if (client.Entity.EnlightmentTime > 0)
                                                client.Entity.EnlightmentTime = 20;
                                        }
                                        else client.Send(new Message("You can't enlighten " + Client.Entity.Name + " yet because he has to wait a few minutes until he can be enlightened again.", System.Drawing.Color.Blue, Message.TopLeft));
                                    }
                                    else client.Send(new Message("You can't enlighten " + Client.Entity.Name + " because you don't have enough enlighten points!", System.Drawing.Color.Blue, Message.TopLeft));
                                }
                                else client.Send(new Message("You can't enlighten " + Client.Entity.Name + " because he/she was enlightened today five times already!", System.Drawing.Color.Blue, Message.TopLeft));
                            }
                        }
                        break;
                    }
                #endregion
                #region NPC Dialog (2031 + 2032)
                case 2031:
                case 2032:
                    {
                        if (client.Action != 2)
                            return;
                        NpcRequest req = new NpcRequest();
                        req.Deserialize(packet);
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 202)//HoursPK War
                        {
                            if (client.Entity.Owner.Equipment.TryGetItem((byte)12).Plus > 7)
                            {
                                client.Entity.AddFlag(Update.Flags.Ride);
                                Random R = new Random();
                                int Nr = R.Next(1, 10);
                                if (Nr == 1) client.Entity.Teleport(2525, 114, 078);
                                if (Nr == 2) client.Entity.Teleport(2525, 96, 87);
                                if (Nr == 3) client.Entity.Teleport(2525, 142, 88);
                                if (Nr == 4) client.Entity.Teleport(2525, 115, 115);
                                if (Nr == 5) client.Entity.Teleport(2525, 98, 130);
                                if (Nr == 6) client.Entity.Teleport(2525, 96, 153);
                                if (Nr == 7) client.Entity.Teleport(2525, 112, 162);
                                if (Nr == 8) client.Entity.Teleport(2525, 130, 166);
                                if (Nr == 9) client.Entity.Teleport(2525, 139, 114);
                                if (Nr == 10) client.Entity.Teleport(2525, 156, 119);
                            }
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 167)//Donation War
                        {
                            if (client.Entity.NobilityRank == Game.ConquerStructures.NobilityRank.King)
                            {
                                client.Entity.Teleport(1166, 50, 50);//Kings Map
                            }
                            if (client.Entity.NobilityRank == Game.ConquerStructures.NobilityRank.Prince)
                            {
                                client.Entity.Teleport(1167, 50, 50);//Princes Map
                            }
                            if (client.Entity.NobilityRank == Game.ConquerStructures.NobilityRank.Duke)
                            {
                                client.Entity.Teleport(1168, 50, 50);//Duke Map
                            }
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 133)//5th Elements
                        {
                            client.Entity.Teleport(1233, 36, 34);
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 159)//DeathTeam
                        {
                            client.Entity.Teleport(1595, 125, 130);
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 115)//GuildWar
                        {
                            Random R = new Random();
                            int Nr = R.Next(1, 10);
                            if (Nr == 1)
                            {
                                client.Entity.Teleport(1038, 351, 341);
                            }
                            if (Nr == 2)
                            {
                                client.Entity.Teleport(1038, 335, 345);
                            }
                            if (Nr == 3)
                            {
                                client.Entity.Teleport(1038, 309, 369);
                            }
                            if (Nr == 4)
                            {
                                client.Entity.Teleport(1038, 283, 340);
                            }
                            if (Nr == 5)
                            {
                                client.Entity.Teleport(1038, 310, 327);
                            }
                            if (Nr == 6)
                            {
                                client.Entity.Teleport(1038, 318, 297);
                            }
                            if (Nr == 7)
                            {
                                client.Entity.Teleport(1038, 347, 309);
                            }
                            if (Nr == 8)
                            {
                                client.Entity.Teleport(1038, 337, 320);
                            }
                            if (Nr == 9)
                            {
                                client.Entity.Teleport(1038, 309, 293);
                            }
                            if (Nr == 10)
                            {
                                client.Entity.Teleport(1038, 371, 300);
                            }
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 202)//HoursPK War
                        {
                            if (client.Entity.Owner.Equipment.TryGetItem((byte)12).Plus > 7)
                            {
                                client.Entity.AddFlag(Update.Flags.Ride);
                                Random R = new Random();
                                int Nr = R.Next(1, 10);
                                if (Nr == 1) client.Entity.Teleport(2525, 114, 078);
                                if (Nr == 2) client.Entity.Teleport(2525, 96, 87);
                                if (Nr == 3) client.Entity.Teleport(2525, 142, 88);
                                if (Nr == 4) client.Entity.Teleport(2525, 115, 115);
                                if (Nr == 5) client.Entity.Teleport(2525, 98, 130);
                                if (Nr == 6) client.Entity.Teleport(2525, 96, 153);
                                if (Nr == 7) client.Entity.Teleport(2525, 112, 162);
                                if (Nr == 8) client.Entity.Teleport(2525, 130, 166);
                                if (Nr == 9) client.Entity.Teleport(2525, 139, 114);
                                if (Nr == 10) client.Entity.Teleport(2525, 156, 119);
                            }
                        }
                        if (req.InteractType == NpcReply.MessageBox)
                        {
                            if (req.OptionID == 255)
                            {
                                if (client.OnMessageBoxOK != null)
                                {
                                    client.OnMessageBoxOK.Invoke();
                                    client.OnMessageBoxOK = null;
                                }
                            }
                            else
                            {
                                if (client.OnMessageBoxCANCEL != null)
                                {
                                    client.OnMessageBoxCANCEL.Invoke();
                                    client.OnMessageBoxCANCEL = null;
                                }
                            }
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 249)
                        {
                            Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 248)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1507, 100, 100);
                            }
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 247)
                        {

                            client.Entity.Teleport(1858, 70, 70);

                        }

                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 246)
                        {

                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);
                            }
                        }

                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 245)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);
                            }
                        }

                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 244)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);
                            }

                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 243)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);
                            }

                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 242)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);

                            }
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 241)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);
                            }

                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 240)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);
                            }

                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 238)
                        {

                            client.Entity.Teleport(2555, 50, 50);

                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 239)
                        {
                            if (Program.Steed == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The SteedRace has finished time of join."));

                            }
                            else
                            {
                                Conquer_Online_Server.Interfaces.IConquerItem I = client.Equipment.TryGetItem(12);
                                if (I != null && I.ID != 0)
                                {
                                    client.Entity.srjoin = 1;
                                    client.Entity.Teleport(1950, 077, 157);
                                    client.Entity.AddFlag(Update.Flags.Ride);
                                }
                                else
                                {
                                    client.Send(new Network.GamePackets.NpcReply(6, "You Dont have a Steed ."));
                                }
                            }

                        }
                        else
                        {
                            if (ID == 2031)
                                client.ActiveNpc = req.NpcID;
                            if (req.NpcID == 12)
                            {
                                if (client.Entity.VIPLevel > 0)
                                {
                                    Data data = new Data(true);
                                    data.ID = Data.OpenWindow;
                                    data.UID = client.Entity.UID;
                                    data.TimeStamp = Time32.Now;
                                    data.dwParam = Data.WindowCommands.VIPWarehouse;
                                    data.wParam1 = client.Entity.X;
                                    data.wParam2 = client.Entity.Y;
                                    client.WarehouseOpen = true;
                                    client.Send(data);
                                    break;
                                }
                            }
                            Interfaces.INpc npc = null;
                            if (req.InteractType == 102)
                            {
                                if (client.Guild != null)
                                {
                                    if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                    {
                                        client.Guild.ExpelMember(req.Input, false);
                                    }
                                }
                                return;
                            }
                            if (client.Map.Npcs.TryGetValue(client.ActiveNpc, out npc))
                            {
                                if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, npc.X, npc.Y) > 17)
                                    return;
                                if (req.OptionID == 255 || (req.OptionID == 0 && ID == 2032))
                                    return;
                                req.NpcID = client.ActiveNpc;
                                //NpcDialogs.Dialogs.GetDialog(req, client);
                                Dialogs.GetDialog(req, client);
                            }
                        }
                        break;
                    }
                #endregion
                #region Compose (2036)
                case 2036:
                    {
                        Compose compose = new Compose(false);
                        compose.Deserialize(packet);
                        ComposePlus(compose, client);
                        break;
                    }
                #endregion
                #region Offline TG (2044)
                case 2044:
                    {
                        OfflineTGRequest otgr = new OfflineTGRequest(false);
                        otgr.Deserialize(packet);
                        switch (otgr.ID)
                        {
                            case OfflineTGRequest.OnTrainingTimeRequested:
                                {
                                    otgr.Minutes = 900;
                                    client.Send(otgr);
                                    break;
                                }
                            case OfflineTGRequest.OnConfirmation:
                                {
                                    client.Entity.PreviousMapID = client.Entity.MapID;
                                    client.Entity.PrevX = client.Entity.X;
                                    client.Entity.PrevY = client.Entity.Y;
                                    client.Entity.MapID = 601;
                                    client.Entity.X = 64;
                                    client.Entity.Y = 56;
                                    client.OfflineTGEnterTime = DateTime.Now;

                                    client.Disconnect();
                                    break;
                                }
                            case OfflineTGRequest.ClaimExperience:
                                {
                                    var T1 = new TimeSpan(DateTime.Now.Ticks);
                                    var T2 = new TimeSpan(client.OfflineTGEnterTime.Ticks);
                                    ushort minutes = (ushort)(T1.TotalMinutes - T2.TotalMinutes);
                                    minutes = (ushort)Math.Min((ushort)900, minutes);
                                    double expballGain = (double)300 * (double)minutes / (double)900;
                                    while (expballGain >= 100)
                                    {
                                        expballGain -= 100;
                                        client.IncreaseExperience(client.ExpBall, false);
                                    }
                                    if (expballGain != 0)
                                        client.IncreaseExperience((uint)(client.ExpBall * (expballGain / 100)), false);

                                    client.Entity.SetLocation(client.Entity.PreviousMapID, client.Entity.PrevX, client.Entity.PrevY);
                                    if (client.Map.ID == 1036 || client.Map.ID == 1039)
                                        client.Entity.Teleport(1002, 430, 378);
                                    else
                                    {
                                        switch (client.Map.ID)
                                        {
                                            default:
                                                {
                                                    client.Entity.Teleport(1002, 429, 378);
                                                    break;
                                                }
                                            case 1000:
                                                {
                                                    client.Entity.Teleport(1000, 500, 650);
                                                    break;
                                                }
                                            case 1020:
                                                {
                                                    client.Entity.Teleport(1020, 565, 562);
                                                    break;
                                                }
                                            case 1011:
                                                {
                                                    client.Entity.Teleport(1011, 188, 264);
                                                    break;
                                                }
                                            case 6001:
                                                {
                                                    client.Entity.Teleport(6001, 030, 075);
                                                    break;
                                                }

                                            case 1015:
                                                {
                                                    client.Entity.Teleport(1015, 717, 571);
                                                    break;
                                                }
                                        }
                                    }
                                    client.OfflineTGEnterTime = DateTime.Now;
                                    break;
                                }
                            default:
                                client.Send(otgr);
                                break;
                        }
                        break;
                    }
                #endregion
                #region Trade partner (2046)
                case 2046:
                    {
                        TradePartner partner = new TradePartner(false);
                        partner.Deserialize(packet);
                        switch (partner.Type)
                        {
                            case TradePartner.RequestPartnership:
                                RequestTradePartnership(partner, client);
                                break;
                            case TradePartner.RejectRequest:
                                RejectPartnership(partner, client);
                                break;
                            case TradePartner.BreakPartnership:
                                BreakPartnership(partner, client);
                                break;
                        }
                        break;
                    }
                #endregion
                #region ItemLock (2048)
                case 2048:
                    {
                        if (client.Action != 2)
                            return;
                        ItemLock itemlock = new ItemLock(false);
                        itemlock.Deserialize(packet);
                        switch (itemlock.ID)
                        {
                            case ItemLock.RequestLock:
                                LockItem(itemlock, client);
                                break;
                            case ItemLock.RequestUnlock:
                                UnlockItem(itemlock, client);
                                break;
                        }
                        break;
                    }
                #endregion
                #region Broadcast (2050)
                case 2050:
                    {
                        Broadcast cast = new Broadcast(false);
                        cast.Deserialize(packet);
                        switch (cast.Type)
                        {
                            case Broadcast.ReleaseSoonMessages:
                                {
                                    BroadcastInfoAwaiting(cast, client);
                                    break;
                                }
                            case Broadcast.MyMessages:
                                {
                                    BroadcastClientMessages(cast, client);
                                    break;
                                }
                            case Broadcast.BroadcastMessage:
                                {
                                    if (Game.ConquerStructures.Broadcast.Broadcasts.Count == ServerBase.Constants.MaxBroadcasts)
                                    {
                                        client.Send(new Message("You cannot send any broadcasts for now. The limit has been reached. Wait until a broadcast is chopped down.", System.Drawing.Color.Red, Message.TopLeft));
                                        break;
                                    }
                                    if (client.Entity.ConquerPoints >= 5)
                                    {
                                        client.Entity.ConquerPoints = (uint)Math.Max(0, (int)((int)client.Entity.ConquerPoints - (int)5));
                                        Game.ConquerStructures.Broadcast.BroadcastStr broadcast = new Conquer_Online_Server.Game.ConquerStructures.Broadcast.BroadcastStr();
                                        broadcast.EntityID = client.Entity.UID;
                                        broadcast.EntityName = client.Entity.Name;
                                        broadcast.ID = Game.ConquerStructures.Broadcast.BroadcastCounter.Next;
                                        if (cast.List[0].Length > 80)
                                            cast.List[0] = cast.List[0].Remove(80);
                                        broadcast.Message = cast.List[0];
                                        if (Game.ConquerStructures.Broadcast.Broadcasts.Count == 0)
                                        {
                                            if (Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityID == 1)
                                            {
                                                Game.ConquerStructures.Broadcast.CurrentBroadcast = broadcast;
                                                Game.ConquerStructures.Broadcast.LastBroadcast = DateTime.Now;
                                                ServerBase.Kernel.SendWorldMessage(new Message(cast.List[0], "ALLUSERS", client.Entity.Name, System.Drawing.Color.Red, Message.BroadcastMessage), ServerBase.Kernel.GamePool.Values);
                                                client.Send(cast);
                                                break;
                                            }
                                        }
                                        Game.ConquerStructures.Broadcast.Broadcasts.Add(broadcast);
                                        cast.dwParam = (uint)Game.ConquerStructures.Broadcast.Broadcasts.Count;
                                        client.Send(cast);
                                        break;
                                    }
                                    break;
                                }
                            case Broadcast.Urgen5CPs:
                                {
                                    for (int c = 0; c < Game.ConquerStructures.Broadcast.Broadcasts.Count; c++)
                                    {
                                        var broadcast = Game.ConquerStructures.Broadcast.Broadcasts[c];
                                        if (broadcast.ID == cast.dwParam)
                                        {
                                            if (c != 0)
                                            {
                                                if (client.Entity.ConquerPoints >= 5)
                                                {
                                                    broadcast.SpentCPs += 5;
                                                    client.Entity.ConquerPoints = (uint)Math.Max(0, (int)((int)client.Entity.ConquerPoints - (int)5));
                                                    if (Game.ConquerStructures.Broadcast.Broadcasts[c - 1].SpentCPs <= broadcast.SpentCPs)
                                                    {
                                                        Game.ConquerStructures.Broadcast.Broadcasts[c] = Game.ConquerStructures.Broadcast.Broadcasts[c - 1];
                                                        Game.ConquerStructures.Broadcast.Broadcasts[c - 1] = broadcast;
                                                    }
                                                    else
                                                    {
                                                        Game.ConquerStructures.Broadcast.Broadcasts[c] = broadcast;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                            case Broadcast.Urgen15CPs:
                                {
                                    for (int c = 0; c < Game.ConquerStructures.Broadcast.Broadcasts.Count; c++)
                                    {
                                        var broadcast = Game.ConquerStructures.Broadcast.Broadcasts[c];
                                        if (broadcast.ID == cast.dwParam)
                                        {
                                            if (c != 0)
                                            {
                                                if (client.Entity.ConquerPoints >= 15)
                                                {
                                                    broadcast.SpentCPs += 15;
                                                    client.Entity.ConquerPoints = (uint)Math.Max(0, (int)((int)client.Entity.ConquerPoints - (int)15));
                                                    for (int b = c - 1; b > 0; b--)
                                                        Game.ConquerStructures.Broadcast.Broadcasts[b] = Game.ConquerStructures.Broadcast.Broadcasts[b - 1];

                                                    Game.ConquerStructures.Broadcast.Broadcasts[0] = broadcast;
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region Nobility (2064)
                case 2064:
                    {
                        NobilityInfo nobility = new NobilityInfo(false);
                        nobility.Deserialize(packet);
                        Game.ConquerStructures.Nobility.Handle(nobility, client);
                        break;
                    }
                #endregion
                #region Mentor prize (2067)
                #region MentorPremio
                case 1036:
                    {
                        switch (packet[4])
                        {
                            #region Send
                            case 0:
                                // Writer.WriteUInt32(client.Entity.Contribution_Experience.Training_Exp, 8, packet);
                                //Writer.WriteUInt32(client.Entity.Contribution_Experience.Blessing_Exp, 12, packet);
                                client.Send(packet);
                                break;
                            #endregion
                            #region Claim Training Exp
                            case 1:
                                {
                                    if (client.Entity.Contribution_Experience.Blessing_Exp > 0)
                                    {
                                        ulong Increase = (ulong)(client.ExpBall * (client.Entity.Contribution_Experience.Training_Exp / 6000000));
                                        client.Entity.Contribution_Experience.Training_Exp = 0;
                                        client.IncreaseExperience(Increase, true);
                                        client.Send(packet);
                                    }
                                    break;
                                }
                            #endregion
                            #region Claim Blessing Exp
                            case 2:
                                {
                                    if (client.Entity.Contribution_Experience.Blessing_Exp > 0)
                                    {
                                        ulong Increase = (ulong)(client.ExpBall * (client.Entity.Contribution_Experience.Blessing_Exp / 6000000));
                                        client.Entity.Contribution_Experience.Blessing_Exp = 0;
                                        client.IncreaseExperience(Increase, true);
                                        client.Send(packet);
                                    }
                                    break;
                                }
                            #endregion
                            default: Console.WriteLine("Unknown 1036 claim type " + packet[4]); break;
                        }
                        break;
                    }
                #endregion
                case 2067:
                    {
                        MentorPrize prize = new MentorPrize(false);
                        prize.Deserialize(packet);
                        switch (prize.Prize_Type)
                        {
                            case MentorPrize.ClaimExperience:
                                {
                                    // client.IncreaseExperience((ulong)(((double)client.PrizeExperience / 606) * client.ExpBall), false);
                                    client.PrizeExperience = 0;
                                    foreach (var appr in client.Apprentices.Values)
                                    {
                                        appr.Actual_Experience = 0;
                                        Database.KnownPersons.SaveApprenticeInfo(appr);
                                    }
                                    prize.Mentor_ID = client.Entity.UID;
                                    prize.Prize_Type = MentorPrize.Show;
                                    prize.Prize_Experience = client.PrizeExperience;
                                    prize.Prize_HeavensBlessing = client.PrizeHeavenBlessing;
                                    prize.Prize_PlusStone = client.PrizePlusStone;
                                    client.Send(prize);
                                    break;
                                }
                            case MentorPrize.ClaimHeavenBlessing:
                                {
                                    client.AddBless(client.PrizeHeavenBlessing);
                                    client.PrizeHeavenBlessing = 0;
                                    foreach (var appr in client.Apprentices.Values)
                                    {
                                        appr.Actual_HeavenBlessing = 0;
                                        Database.KnownPersons.SaveApprenticeInfo(appr);
                                    }
                                    prize.Mentor_ID = client.Entity.UID;
                                    prize.Prize_Type = MentorPrize.Show;
                                    prize.Prize_Experience = client.PrizeExperience;
                                    prize.Prize_HeavensBlessing = client.PrizeHeavenBlessing;
                                    prize.Prize_PlusStone = client.PrizePlusStone;
                                    client.Send(prize);
                                    break;
                                }
                            case MentorPrize.ClaimPlus:
                                {
                                    int stones = client.PrizePlusStone / 100;
                                    int totake = stones;
                                    if (stones > 0)
                                    {
                                        for (; stones > 0; stones--)
                                        {
                                            client.PrizePlusStone -= 100;
                                            if (!client.Inventory.Add(730001, 1, 1))
                                                break;
                                        }
                                    }
                                    foreach (var appr in client.Apprentices.Values)
                                    {
                                        if (appr.Actual_Plus >= totake)
                                        {
                                            appr.Actual_Plus -= (ushort)totake;
                                            totake = 0;
                                        }
                                        else
                                        {
                                            totake -= appr.Actual_Plus;
                                            appr.Actual_Plus = 0;
                                        }
                                        Database.KnownPersons.SaveApprenticeInfo(appr);
                                    }
                                    prize.Mentor_ID = client.Entity.UID;
                                    prize.Prize_Type = MentorPrize.Show;
                                    prize.Prize_Experience = client.PrizeExperience;
                                    prize.Prize_HeavensBlessing = client.PrizeHeavenBlessing;
                                    prize.Prize_PlusStone = client.PrizePlusStone;
                                    client.Send(prize);
                                    break;
                                }
                            case MentorPrize.Show:
                                {
                                    prize.Mentor_ID = client.Entity.UID;
                                    prize.Prize_Type = MentorPrize.Show;
                                    prize.Prize_Experience = client.PrizeExperience;
                                    prize.Prize_HeavensBlessing = client.PrizeHeavenBlessing;
                                    prize.Prize_PlusStone = client.PrizePlusStone;
                                    client.Send(prize);
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region MentorApprentice (2065)
                case 2065:
                    {
                        MentorApprentice ma = new MentorApprentice(false);
                        ma.Deserialize(packet);
                        switch (ma.Type)
                        {
                            case MentorApprentice.LeaveMentor:
                                {
                                    LeaveMentor(ma, client);
                                    break;
                                }
                            case MentorApprentice.ExpellApprentice:
                                {
                                    ExpelApprentice(ma, client);
                                    break;
                                }
                            case MentorApprentice.RequestApprentice:
                                {
                                    AddApprentice(ma, client);
                                    break;
                                }
                            case MentorApprentice.RequestMentor:
                                {
                                    AddMentor(ma, client);
                                    break;
                                }
                            case MentorApprentice.AcceptRequestApprentice:
                                {
                                    AcceptRequestApprentice(ma, client);
                                    break;
                                }
                            case MentorApprentice.AcceptRequestMentor:
                                {
                                    AcceptRequestMentor(ma, client);
                                    break;
                                }
                        }
                        break;
                    }
                case 2066:
                    {
                        MentorInformation info = new MentorInformation(false);
                        info.Deserialize(packet);
                        if (info.Mentor_Type == 1)
                        {
                            client.ReviewMentor();
                        }
                        break;
                    }
                #endregion
                #region PurifyItem (2076)
                case 2076:
                    {
                        Purification ps = new Purification(false);
                        ps.Deserialize(packet);
                        switch (ps.Mode)
                        {
                            case Purification.Purify:
                                PurifyItem(ps, client); break;
                            case Purification.Purify1:
                                new Game.Features.Refinery.Handle(packet, client);
                                break;
                        }
                        break;
                    }
                #endregion

                #region Arsenal Guild
                case 2202:
                    {

                        ArsenalInscribitionList list = new ArsenalInscribitionList();
                        client.Send(list.Build(packet, client.Guild));
                        break;
                    }
                case 2203:
                    {
                        client.Guild.Arsenal.Update(client.Guild);
                        client.Send(client.Guild.A_Packet);
                        Database.ArsenalsTable.Load(client.Guild);
                        #region Handle
                        byte pType = packet[4];
                        byte i_type = packet[8];
                        uint i_Uid = BitConverter.ToUInt32(packet, 12);
                        switch (pType)
                        {
                            case 0://Unlock
                                {
                                    uint value = 5000000;
                                    if (client.Guild.SilverFund >= value)
                                    {

                                        if (i_type == 2 || i_type == 3)
                                        { value = 10000000; }
                                        if (i_type >= 3 && i_type <= 5)
                                        { value = 15000000; }
                                        if (i_type == 6 || i_type == 7)
                                        { value = 20000000; }
                                        if (client.Guild.SilverFund >= value)
                                        {
                                            client.Guild.SilverFund -= value;
                                            Database.ArsenalsTable.CreateArsenal((ushort)client.Guild.ID, (Game.ConquerStructures.Society.ArsenalType)i_type);
                                        }
                                        else
                                            client.Send(new Network.GamePackets.Message("sorry, you need " + value + " guild Found", System.Drawing.Color.Red, Message.TopLeft).ToArray());
                                    }
                                    else
                                        client.Send(new Network.GamePackets.Message("sorry, you need " + value + " guild Found", System.Drawing.Color.Red, Message.TopLeft).ToArray());
                                    break;
                                }
                            case 1://Inscribe
                                {
                                    Interfaces.IConquerItem Item = null;
                                    if (client.Inventory.TryGetItem(i_Uid, out Item))
                                    {
                                        client.Guild.Arsenal.Inscribe((Game.ConquerStructures.Society.ArsenalType)i_type, Item, client);
                                        client.Guild.Arsenal.Update((Game.ConquerStructures.Society.ArsenalType)i_type, client.Guild);
                                    }
                                    break;
                                }
                            case 2://Uninscribe
                                {
                                    Game.ConquerStructures.Society.ArsenalSingle AS = null;
                                    if (client.Guild.Arsenal.Inscribed[(Game.ConquerStructures.Society.ArsenalType)i_type].TryGetValue(i_Uid, out AS))
                                    {
                                        client.Guild.Arsenal.Uninscribe((Game.ConquerStructures.Society.ArsenalType)i_type, AS, client);
                                        client.Guild.Arsenal.Update((Game.ConquerStructures.Society.ArsenalType)i_type, client.Guild);
                                    }
                                    break;
                                }
                            case 3://Enhance
                                {
                                    //client.Entity.Mentors.Share();
                                    client.Guild.A_Packet.SetTotals2();
                                    client.Send(client.Guild.A_Packet);
                                    break;
                                }
                            case 4://Show Main Info
                                {
                                    client.Guild.A_Packet.SetTotals();
                                    client.Send(client.Guild.A_Packet);
                                    break;
                                }
                        }
                        client.Send(packet);
                        #endregion
                        break;
                    }
                #endregion
                #region Arena (2207<->2211)
                case 2207://Request Arena ranking List
                    {
                        //Code snippet that belongs to Ultimation
                        ushort PageIndex = BitConverter.ToUInt16(packet, 6);
                        Game.ConquerStructures.Arena.Statistics.ShowRankingPage(packet[4], PageIndex, client);
                        break;
                    }
                case 2206:
                    {
                        //Code snippet that belongs to Ultimation
                        ushort PageIndex = BitConverter.ToUInt16(packet, 4);
                        Game.ConquerStructures.Arena.QualifyEngine.RequestGroupList(client, PageIndex);
                        break;
                    }
                case 2205://Arena Signup!
                    {
                        //Code snippet that belongs to Ultimation
                        uint DialogID = BitConverter.ToUInt32(packet, 4);
                        uint ButtonID = BitConverter.ToUInt32(packet, 8);
                        switch (DialogID)
                        {
                            case 4:
                                {
                                    switch (ButtonID)
                                    {
                                        case 0:
                                            {
                                                Game.ConquerStructures.Arena.QualifyEngine.DoQuit(client);
                                                break;
                                            }
                                    }
                                    break;
                                }
                            case 0: Game.ConquerStructures.Arena.QualifyEngine.DoSignup(client); client.Send(packet); break;
                            case 1: Game.ConquerStructures.Arena.QualifyEngine.DoQuit(client); client.Send(packet); break;
                            case 3:
                                {
                                    switch (ButtonID)
                                    {
                                        case 2: Game.ConquerStructures.Arena.QualifyEngine.DoGiveUp(client); break;
                                        case 1: Game.ConquerStructures.Arena.QualifyEngine.DoAccept(client); break;
                                    }
                                    break;
                                }
                            case 5:
                                {
                                    if (client.ArenaStatistic.ArenaPoints <= 1500)
                                        if (client.Entity.Money >= 9000000)
                                        {
                                            client.Entity.Money -= 9000000;
                                            client.ArenaStatistic.ArenaPoints += 1500;
                                            client.Send(client.ArenaStatistic);
                                        }
                                    break;
                                }
                            case 11://Win/Lose Dialog
                                {
                                    switch (ButtonID)
                                    {
                                        case 0: Game.ConquerStructures.Arena.QualifyEngine.DoSignup(client); break;
                                    }
                                    break;
                                }

                        }
                        break;
                    }
                case 2208://Request Arena Winner List
                    {
                        //Code snippet that belongs to Ultimation
                        Game.ConquerStructures.Arena.Statistics.ShowWiners(client);
                        break;
                    }
                case 2209:
                    {
                        client.ArenaStatistic.Send(client);
                        break;
                    }
                case 2211:
                    {
                        ushort Type = BitConverter.ToUInt16(packet, 4);
                        uint Fighter = BitConverter.ToUInt32(packet, 10);
                        if (Type == 0)
                        {
                            if (ServerBase.Kernel.GamePool.ContainsKey(Fighter))
                            {
                                Client.GameState Client = ServerBase.Kernel.GamePool[Fighter];
                                if (Client.QualifierGroup != null)
                                {
                                    if (Client.QualifierGroup.Inside)
                                    {
                                        if (!Client.QualifierGroup.Done)
                                        {
                                            Client.QualifierGroup.BeginWatching(client);
                                        }
                                    }
                                }
                            }
                        }
                        else if (Type == 1)
                        {
                            Game.ConquerStructures.Arena.QualifyEngine.DoLeave(client);
                        }
                        else if (Type == 4)
                        {
                            string name = "";
                            for (int c = 22; c < packet.Length; c++)
                            {
                                if (packet[c] != 0)
                                    name += (char)packet[c];
                                else
                                    break;
                            }
                            Game.ConquerStructures.Arena.QualifyEngine.DoCheer(client, name);
                        }
                        break;
                    }
                #endregion
                #region Movement/Walk (10005)
                case 10005:
                    {
                        if (client.Action != 2)
                            return;
                        GroundMovement groundMovement = new GroundMovement(false);
                        groundMovement.Deserialize(packet);
                        PlayerGroundMovment(groundMovement, client);
                        break;
                    }
                #endregion
                #region Data (10010)
                case 10010:
                    {
                        if (client.Action != 2)
                            return;
                        Data gData = new Data(false);
                        gData.Deserialize(packet);
                        switch (gData.ID)
                        {
                            case Data.SwingPickaxe:
                                client.Mining = true;
                                break;
                            case Data.Revive:

                                Revive(gData, client);
                                // Revive(gData, client);
                                break;
                            case Data.UsePortal:
                                if (client.Entity.MapID == 601)
                                {
                                    client.Entity.Teleport(601, 063, 055);
                                }
                                else
                                    UsePortal(gData, client);
                                break;

                            case Data.ChangePKMode:
                                ChangePKMode(gData, client);
                                break;
                            case Data.ChangeAction:
                                ChangeAction(gData, client);
                                break;
                            case Data.ChangeDirection:
                                ChangeDirection(gData, client);
                                break;
                            case Data.Hotkeys:
                                client.Send(packet);
                                break;
                            case 408://steed soul remoeve
                                {

                                    break;
                                }
                            case Data.ConfirmSpells:
                                if (client.Spells != null)
                                    foreach (Interfaces.ISkill spell in client.Spells.Values)
                                        if (spell.ID != 3060)
                                            spell.Send(client);
                                client.Send(packet);
                                break;
                            case Data.ConfirmProficiencies:
                                if (client.Proficiencies != null)
                                    foreach (Interfaces.ISkill proficiency in client.Proficiencies.Values)
                                        proficiency.Send(client);
                                client.Send(packet);
                                break;
                            case Data.ConfirmGuild:
                                client.Send(packet);
                                break;
                            case Data.ConfirmFriends:
                                #region Friends/Enemy/TradePartners/Apprentices
                                Message msg2 = new Message("Your friend, " + client.Entity.Name + ", has logged on.", System.Drawing.Color.Red, Message.TopLeft);

                                foreach (Game.ConquerStructures.Society.Friend friend in client.Friends.Values)
                                {
                                    if (friend.IsOnline)
                                    {
                                        var pckt = new KnownPersons(true)
                                        {
                                            UID = client.Entity.UID,
                                            Type = KnownPersons.RemovePerson,
                                            Name = client.Entity.Name,
                                            Online = true
                                        };
                                        friend.Client.Send(pckt);
                                        pckt.Type = KnownPersons.AddFriend;
                                        friend.Client.Send(pckt);
                                        friend.Client.Send(msg2);
                                    }
                                    client.Send(new KnownPersons(true)
                                    {
                                        UID = friend.ID,
                                        Type = KnownPersons.AddFriend,
                                        Name = friend.Name,
                                        Online = friend.IsOnline
                                    });
                                    if (friend.Message != "")
                                    {
                                        client.Send(new Message(friend.Message, client.Entity.Name, friend.Name, System.Drawing.Color.Red, Message.Whisper));
                                        Database.KnownPersons.UpdateMessageOnFriend(friend.ID, client.Entity.UID, "");
                                    }
                                }

                                foreach (Game.ConquerStructures.Society.Enemy enemy in client.Enemy.Values)
                                {
                                    client.Send(new KnownPersons(true)
                                    {
                                        UID = enemy.ID,
                                        Type = KnownPersons.AddEnemy,
                                        Name = enemy.Name,
                                        Online = enemy.IsOnline
                                    });
                                }
                                Message msg3 = new Message("Your partner, " + client.Entity.Name + ", has logged in.", System.Drawing.Color.Red, Message.TopLeft);

                                foreach (Game.ConquerStructures.Society.TradePartner partner in client.Partners.Values)
                                {
                                    if (partner.IsOnline)
                                    {
                                        var packet3 = new TradePartner(true)
                                        {
                                            UID = client.Entity.UID,
                                            Type = TradePartner.BreakPartnership,
                                            Name = client.Entity.Name,
                                            HoursLeft = (int)(new TimeSpan(partner.ProbationStartedOn.AddDays(3).Ticks).TotalHours - new TimeSpan(DateTime.Now.Ticks).TotalHours),
                                            Online = true
                                        };
                                        partner.Client.Send(packet3);
                                        packet3.Type = TradePartner.AddPartner;
                                        partner.Client.Send(packet3);
                                        partner.Client.Send(msg3);
                                    }
                                    var packet4 = new TradePartner(true)
                                    {
                                        UID = partner.ID,
                                        Type = TradePartner.AddPartner,
                                        Name = partner.Name,
                                        HoursLeft = (int)(new TimeSpan(partner.ProbationStartedOn.AddDays(3).Ticks).TotalHours - new TimeSpan(DateTime.Now.Ticks).TotalHours),
                                        Online = partner.IsOnline
                                    };
                                    client.Send(packet4);
                                }

                                foreach (Game.ConquerStructures.Society.Apprentice appr in client.Apprentices.Values)
                                {
                                    if (appr.IsOnline)
                                    {
                                        ApprenticeInformation AppInfo = new ApprenticeInformation();
                                        AppInfo.Apprentice_ID = appr.ID;
                                        AppInfo.Apprentice_Level = appr.Client.Entity.Level;
                                        AppInfo.Apprentice_Class = appr.Client.Entity.Class;
                                        AppInfo.Apprentice_PkPoints = appr.Client.Entity.PKPoints;
                                        AppInfo.Apprentice_Experience = appr.Actual_Experience;
                                        AppInfo.Apprentice_Composing = appr.Actual_Plus;
                                        AppInfo.Apprentice_Blessing = appr.Actual_HeavenBlessing;
                                        AppInfo.Apprentice_Name = appr.Name;
                                        AppInfo.Apprentice_Online = true;
                                        AppInfo.Apprentice_Spouse_Name = appr.Client.Entity.Spouse;
                                        AppInfo.Enrole_date = appr.EnroleDate;
                                        AppInfo.Mentor_ID = client.Entity.UID;
                                        AppInfo.Mentor_Mesh = client.Entity.Mesh;
                                        AppInfo.Mentor_Name = client.Entity.Name;
                                        AppInfo.Type = 2;
                                        client.Send(AppInfo);

                                        MentorInformation Information = new MentorInformation(true);
                                        Information.Mentor_Type = 1;
                                        Information.Mentor_ID = client.Entity.UID;
                                        Information.Apprentice_ID = appr.ID;
                                        Information.Enrole_Date = appr.EnroleDate;
                                        Information.Mentor_Level = client.Entity.Level;
                                        Information.Mentor_Class = client.Entity.Class;
                                        Information.Mentor_PkPoints = client.Entity.PKPoints;
                                        Information.Mentor_Mesh = client.Entity.Mesh;
                                        Information.Mentor_Online = true;
                                        Information.Shared_Battle_Power = (uint)(((client.Entity.BattlePower - client.Entity.ExtraBattlePower) - (appr.Client.Entity.BattlePower - appr.Client.Entity.ExtraBattlePower)) / 3.3F);
                                        Information.String_Count = 3;
                                        Information.Mentor_Name = client.Entity.Name;
                                        Information.Apprentice_Name = appr.Name;
                                        Information.Mentor_Spouse_Name = client.Entity.Spouse;
                                        appr.Client.ReviewMentor();
                                        appr.Client.Send(Information);
                                    }
                                    else
                                    {
                                        ApprenticeInformation AppInfo = new ApprenticeInformation();
                                        AppInfo.Apprentice_ID = appr.ID;
                                        AppInfo.Apprentice_Name = appr.Name;
                                        AppInfo.Apprentice_Online = false;
                                        AppInfo.Enrole_date = appr.EnroleDate;
                                        AppInfo.Mentor_ID = client.Entity.UID;
                                        AppInfo.Mentor_Mesh = client.Entity.Mesh;
                                        AppInfo.Mentor_Name = client.Entity.Name;
                                        AppInfo.Type = 2;
                                        client.Send(AppInfo);
                                    }
                                }
                                #endregion
                                client.Send(packet);
                                break;
                            case Data.EndTeleport:
                                break;
                            case Data.GetSurroundings:
                                if (client.Booth != null)
                                {
                                    client.Entity.TransformationID = 0;
                                    client.Booth.Remove();
                                    client.Booth = null;
                                }
                                GetSurroundings(client);
                                client.Send(new MapStatus() { BaseID = client.Map.BaseID, ID = client.Map.ID, Status = Database.MapsTable.MapInformations[client.Map.ID].Status });
                                Game.Weather.CurrentWeatherBase.Send(client);
                                client.Send(gData);
                                break;
                            case Data.SetLocation:
                                SetLocation(gData, client);
                                break;
                            case Data.Jump:
                                PlayerJump(gData, client);
                                break;
                            case Data.UnknownEntity:
                                {
                                    #region UnknownEntity
                                    Client.GameState pClient = null;
                                    if (ServerBase.Kernel.GamePool.TryGetValue(gData.dwParam, out pClient))
                                    {
                                        if (ServerBase.Kernel.GetDistance(pClient.Entity.X, pClient.Entity.Y, client.Entity.X, client.Entity.Y) <= ServerBase.Constants.pScreenDistance && client.Map.ID == pClient.Map.ID)
                                        {
                                            if (pClient.Guild != null)
                                                pClient.Guild.SendName(client);
                                            if (client.Guild != null)
                                                client.Guild.SendName(pClient);
                                            if (pClient.Entity.UID != client.Entity.UID)
                                            {
                                                if (pClient.Map.ID == client.Map.ID)
                                                {
                                                    if (pClient.Map.BaseID == 700)
                                                    {
                                                        if (client.QualifierGroup != null)
                                                        {
                                                            if (pClient.QualifierGroup != null)
                                                            {
                                                                client.Entity.SendSpawn(pClient, false);
                                                                pClient.Entity.SendSpawn(client, false);
                                                            }
                                                            else
                                                            {
                                                                client.Entity.SendSpawn(pClient, false);
                                                                client.Screen.Add(pClient.Entity);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (pClient.QualifierGroup != null)
                                                            {
                                                                pClient.Entity.SendSpawn(client, false);
                                                                pClient.Screen.Add(client.Entity);
                                                            }
                                                            else
                                                            {
                                                                client.Entity.SendSpawn(pClient, false);
                                                                pClient.Entity.SendSpawn(client, false);
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        client.Entity.SendSpawn(pClient, false);
                                                        pClient.Entity.SendSpawn(client, false);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Game.Entity monster = null;
                                        if (client.Map.Entities.TryGetValue(gData.dwParam, out monster))
                                        {
                                            if (ServerBase.Kernel.GetDistance(monster.X, monster.Y, client.Entity.X, client.Entity.Y) <= ServerBase.Constants.pScreenDistance)
                                            {
                                                monster.SendSpawn(client, false);
                                            }
                                        }
                                        if (client.Map.Companions.TryGetValue(gData.dwParam, out monster))
                                        {
                                            if (ServerBase.Kernel.GetDistance(monster.X, monster.Y, client.Entity.X, client.Entity.Y) <= ServerBase.Constants.pScreenDistance)
                                            {
                                                monster.SendSpawn(client, false);
                                            }
                                        }
                                    }
                                    #endregion
                                    break;
                                }
                            case Data.CompleteLogin:
                                LoginMessages(client);

                                EntityEquipment equips = new EntityEquipment(true);
                                equips.ParseHero(client);
                                client.Send(equips);
                                break;
                            case Data.ChangeFace:
                                ChangeFace(gData, client);
                                break;
                            case Data.ObserveEquipment:
                            case Data.ObserveEquipment2:
                            case Data.ObserveKnownPerson:
                                ObserveEquipment(gData, client);
                                break;
                            case Data.ViewEnemyInfo:
                                {
                                    if (client.Enemy.ContainsKey(gData.dwParam))
                                    {
                                        if (client.Enemy[gData.dwParam].IsOnline)
                                        {
                                            KnownPersonInfo info = new KnownPersonInfo(true);
                                            info.Fill(client.Enemy[gData.dwParam], true, false);
                                            if (client.Enemy[gData.dwParam].Client.Guild != null)
                                                client.Enemy[gData.dwParam].Client.Guild.SendName(client);
                                            client.Send(info);
                                        }
                                    }
                                    break;
                                }
                            case Data.ViewFriendInfo:
                                {
                                    if (client.Friends.ContainsKey(gData.dwParam))
                                    {
                                        if (client.Friends[gData.dwParam].IsOnline)
                                        {
                                            KnownPersonInfo info = new KnownPersonInfo(true);
                                            info.Fill(client.Friends[gData.dwParam], false, false);
                                            if (client.Friends[gData.dwParam].Client.Guild != null)
                                                client.Friends[gData.dwParam].Client.Guild.SendName(client);
                                            client.Send(info);
                                        }
                                    }
                                    break;
                                }
                            case Data.ViewPartnerInfo:
                                {
                                    if (client.Partners.ContainsKey(gData.dwParam))
                                    {
                                        if (client.Partners[gData.dwParam].IsOnline)
                                        {
                                            TradePartnerInfo info = new TradePartnerInfo(true);
                                            info.Fill(client.Partners[gData.dwParam]);
                                            if (client.Partners[gData.dwParam].Client.Guild != null)
                                                client.Partners[gData.dwParam].Client.Guild.SendName(client);
                                            client.Send(info);
                                        }
                                    }
                                    break;
                                }
                            case Data.EndFly:
                                client.Entity.RemoveFlag(Update.Flags.Fly);
                                break;
                            case Data.EndTransformation:
                                client.Entity.Untransform();
                                break;
                            case Data.XPListEnd:
                            case Data.Die:
                                break;
                            case Data.OwnBooth:
                                {

                                    //client.Entity.TransformationTime = 3600;
                                    if (client.WarehouseOpen == true)
                                    {
                                        client.Send(new Message("you cant booth when you open warehose", Color.AntiqueWhite, 2005));

                                        return;
                                    }
                                    else
                                    {
                                        client.Booth = new Conquer_Online_Server.Game.ConquerStructures.Booth(client, gData);
                                        client.Send(new Data(true) { ID = Data.ChangeAction, UID = client.Entity.UID, dwParam = 0 });

                                    }
                                    break;
                                }
                            case Data.Away:
                                {
                                    if (client.Entity.Away == 0)
                                        client.Entity.Away = 1;
                                    else
                                        client.Entity.Away = 0;
                                    client.SendScreenSpawn(client.Entity, false);
                                    break;
                                }
                            case Data.DeleteCharacter:
                                {
                                    if ((client.WarehousePW == null || client.WarehousePW == "" || client.WarehousePW == "0" && gData.dwParam == 0) || (client.WarehousePW == gData.dwParam.ToString()))
                                    {
                                        client.Account.EntityID = 0;
                                        client.Account.Save();
                                        client.Disconnect();
                                    }
                                    break;
                                }
                            case Data.TeamSearchForMember:
                                {
                                    if (client.Team != null)
                                    {
                                        Client.GameState Client = null;
                                        if (!client.Team.IsTeammate(gData.UID))
                                            return;
                                        if (Kernel.GamePool.TryGetValue(gData.UID, out Client))
                                        {
                                            gData.wParam1 = Client.Entity.X;
                                            gData.wParam2 = Client.Entity.Y;
                                            gData.Send(client);
                                        }
                                    }
                                    break;
                                }
                            default:
                                if (client.Account.State == Conquer_Online_Server.Database.AccountTable.AccountState.ProjectManager)
                                    client.Send(new Message("Unknown generaldata id: " + gData.ID, System.Drawing.Color.CadetBlue, Message.Talk));
                                break;
                        }
                        break;
                    }
                #endregion
                #region Status 1040
                case 1040:
                    {
                        Status ShowStatistics2 = new Status(client);
                        ShowStatistics2.Deserialize(packet);
                        ShowStatistics2.Send(client);
                        //uint UID = BitConverter.ToUInt32(packet, 4);
                        //Client.GameState Client;
                        //if (ServerBase.Kernel.GamePool.TryGetValue(UID, out Client))
                        //{
                        //    client.Send(WindowStats(Client));
                        //}
                        break;
                    }
                #endregion
                #region Flowers
                case 1150:
                    {
                        SendFlowers(client, packet);

                        break;
                    }
                case 1151:
                    {
                        AddFlowers(client, packet);

                        break;
                    }

                #endregion
                #region Clans
                case 1312:
                    {
                        switch (packet[4])
                        {
                            case 21://transfer
                                {
                                    if (client.Entity.Myclan != null)
                                    {
                                        PrintPacket(packet);
                                        uint lider = 0;
                                        string name_receive = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]);

                                        var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                        varr.MoveNext();
                                        int COunt = ServerBase.Kernel.GamePool.Count;
                                        for (uint x = 0;
                                            x < COunt;
                                            x++)
                                        {
                                            if (x >= COunt) break;

                                            Client.GameState clien = (varr.Current as Client.GameState);

                                            if (clien.Entity.Name == name_receive)
                                                lider = clien.Entity.UID;

                                            varr.MoveNext();

                                        }

                                        if (lider == client.Entity.UID) return;
                                        Client.GameState aClient = null;
                                        if (Conquer_Online_Server.ServerBase.Kernel.GamePool.TryGetValue(lider, out aClient))
                                        {

                                            if (Conquer_Online_Server.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                            {
                                                if (Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].Members.ContainsKey(aClient.Entity.UID))
                                                {
                                                    Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanLider = aClient.Entity.Name;
                                                    aClient.Entity.ClanRank = 100;
                                                    aClient.Entity.Myclan.Members[aClient.Entity.UID].Rank = 100;
                                                    if (aClient.Entity.Myclan.Members.ContainsKey(client.Entity.UID))
                                                        aClient.Entity.Myclan.Members[client.Entity.UID].Rank = 0;
                                                    client.Entity.ClanRank = 0;
                                                    Database.Clans.SaveClan(aClient.Entity.Myclan);
                                                    Database.Clans.JoinClan(client);
                                                }
                                            }

                                        }
                                        else
                                        {
                                            Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanLider = name_receive;
                                            client.Entity.ClanRank = 0;
                                            Database.Clans.JoinClan(client);
                                            Database.Clans.SaveClan(client.Entity.Myclan);
                                            Database.Clans.TransferClan(name_receive);
                                        }
                                    }
                                    break;
                                }
                            /* case 14://add enemy
                                 {
                                     break;
                                 }*/
                            case 9://recruit member
                                {
                                    break;
                                }
                            case 23://client exit
                                {
                                    if (client.Entity.Myclan != null)
                                    {
                                        if (Conquer_Online_Server.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                        {
                                            if (Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].Members.ContainsKey(client.Entity.UID))
                                            {
                                                Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].Members.Remove(client.Entity.UID);
                                            }
                                        }
                                        client.Entity.ClanId = 0;
                                        client.Entity.ClanName = "";
                                        client.Entity.Myclan = null;

                                        Database.Clans.KickClan(client.Entity.Name);
                                        client.Send(packet);
                                    }
                                    break;
                                }
                            case 25://buleitn
                                {
                                    if (client.Entity.Myclan == null) return;
                                    string buletin = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]);
                                    if (Conquer_Online_Server.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                        Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanBuletion = buletin;
                                    Database.Clans.SaveClan(Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId]);
                                    client.Send(packet);
                                    break;
                                }
                            case 22://give kick
                                {
                                    if (client.Entity.Myclan != null)
                                    {
                                        if (client.Entity.ClanRank == 100)
                                        {
                                            string name = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]);
                                            uint Key = 0;

                                            foreach (Game.ClanMembers mem in client.Entity.Myclan.Members.Values)
                                            {
                                                if (mem.Name == name)
                                                    Key = mem.UID;
                                            }
                                            if (Key != 0)
                                            {

                                                if (Conquer_Online_Server.ServerBase.Kernel.GamePool.ContainsKey(Key))
                                                {

                                                    if (Conquer_Online_Server.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                                    {
                                                        if (Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].Members.ContainsKey(Key))
                                                        {
                                                            Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].Members.Remove(Key);
                                                            Network.GamePackets.ClanMembers clan = new Network.GamePackets.ClanMembers(client);
                                                            client.Send(clan.ToArray());
                                                            Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 22);
                                                            ServerBase.Kernel.GamePool[Key].Send(cl.ToArray());
                                                            ServerBase.Kernel.GamePool[Key].Entity.ClanName = "";
                                                            ServerBase.Kernel.GamePool[Key].Entity.ClanId = 0;
                                                            ServerBase.Kernel.GamePool[Key].Entity.Myclan = null;
                                                            ServerBase.Kernel.GamePool[Key].Screen.FullWipe();
                                                            ServerBase.Kernel.GamePool[Key].Screen.Reload(null);
                                                        }
                                                    }
                                                }
                                            }
                                            Database.Clans.KickClan(name);
                                        }
                                    }

                                    break;
                                }

                            case 26://donation
                                {
                                    uint money = BitConverter.ToUInt32(packet, 8);
                                    if (client.Entity.Money >= money && client.Entity.Myclan != null)
                                    {
                                        client.Entity.Myclan.Members[client.Entity.UID].Donation += money;
                                        client.Entity.Money -= money;
                                        if (Conquer_Online_Server.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                            Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanDonation += money;
                                        Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 1);
                                        client.Send(cl.ToArray());
                                        Database.Clans.SaveClientDonation(client);
                                        Database.Clans.SaveClan(Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId]);
                                    }
                                    break;
                                }
                            case 11://add player
                                {

                                    uint lider = BitConverter.ToUInt32(packet, 8);
                                    if (Conquer_Online_Server.ServerBase.Kernel.GamePool.ContainsKey(lider))
                                    {
                                        packet[4] = 11;
                                        Network.Writer.WriteUInt32(client.Entity.UID, 8, packet);
                                        packet[16] = 1;
                                        packet[17] = (byte)client.Entity.Name.Length;
                                        for (int i = 0; i < client.Entity.Name.Length; i++)
                                        {
                                            try
                                            {
                                                packet[18 + i] = Convert.ToByte(client.Entity.Name[i]);

                                            }
                                            catch { }
                                        }
                                        if (Conquer_Online_Server.ServerBase.Kernel.GamePool[lider].Entity.Myclan != null)
                                            Conquer_Online_Server.ServerBase.Kernel.GamePool[lider].Send(packet);
                                    }
                                    break;
                                }
                            case 12:
                                {
                                    if (packet[16] == 1)
                                    {
                                        if (client.Entity.Myclan != null)
                                            if (client.Entity.Myclan.Members[client.Entity.UID].Rank == 100)
                                            {
                                                //if (client.Entity.Myclan != null)
                                                {
                                                    if (client.Entity.Myclan.Members.Count < 7)
                                                    {

                                                        uint memeber = BitConverter.ToUInt32(packet, 8);
                                                        if (ServerBase.Kernel.GamePool.ContainsKey(memeber))
                                                        {
                                                            Game.ClanMembers member = new Conquer_Online_Server.Game.ClanMembers();
                                                            member.UID = ServerBase.Kernel.GamePool[memeber].Entity.UID;
                                                            member.Donation = 0;
                                                            member.Rank = 10;
                                                            member.Class = ServerBase.Kernel.GamePool[memeber].Entity.Class;
                                                            member.Level = ServerBase.Kernel.GamePool[memeber].Entity.Level;
                                                            member.Name = ServerBase.Kernel.GamePool[memeber].Entity.Name;
                                                            if (!client.Entity.Myclan.Members.ContainsKey(memeber))
                                                                client.Entity.Myclan.Members.Add(member.UID, member);

                                                            ServerBase.Kernel.GamePool[memeber].Entity.ClanRank = 0;
                                                            ServerBase.Kernel.GamePool[memeber].Entity.ClanId = client.Entity.ClanId;
                                                            ServerBase.Kernel.GamePool[memeber].Entity.Myclan = client.Entity.Myclan;
                                                            ServerBase.Kernel.GamePool[memeber].Entity.ClanName = client.Entity.ClanName;
                                                            Database.Clans.JoinClan(ServerBase.Kernel.GamePool[memeber]);
                                                            ServerBase.Kernel.GamePool[memeber].Screen.FullWipe();
                                                            ServerBase.Kernel.GamePool[memeber].Screen.Reload(null);
                                                        }
                                                    }
                                                }
                                            }
                                    }
                                    break;
                                }
                            case 4://memebers
                                {
                                    ClanMembers clan = new ClanMembers(client);
                                    client.Send(clan.ToArray());
                                    break;
                                }
                            case 0x1d:
                                {
                                    if (client.Entity.Myclan != null)
                                    {
                                        Network.Writer.WriteUInt32(client.Entity.Myclan.ClanId, 8, packet);
                                        Network.Writer.WriteByte(1, 16, packet);
                                        Network.Writer.WriteByte(0x0d, 17, packet);
                                        Network.Writer.WriteString("0 0 0 0 0 0 0", 18, packet);
                                        client.Send(packet);
                                        Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 1);
                                        client.Send(cl.ToArray());
                                        client.Send(packet);

                                        if (client.Entity.Myclan.ClanBuletion != "")
                                            client.Send(cl.UpgradeBuletin(client.Entity.Myclan.ClanBuletion));
                                    }
                                    else
                                    {
                                        client.Send(packet);
                                        packet[4] = 23;
                                    }

                                    break;
                                }
                            case 0x18:
                                {
                                    client.Send(packet);
                                    break;
                                }
                            case (byte)Game.Clan_Typ.AddAlly:
                                {
                                    Game.Clans clan = client.Entity.Myclan;
                                    if (clan != null)
                                    {
                                        Client.GameState target;
                                        UInt32 Identifier = BitConverter.ToUInt32(packet, 8);

                                        if (client.Entity.ClanRank == 100)
                                        {
                                            if (clan.Allies.Count >= 5)
                                            { client.Send(new Message("The Ammount of Allies You can Have has exceeded", System.Drawing.Color.Red, Message.TopLeft)); break; }

                                            if (ServerBase.Kernel.GamePool.TryGetValue(Identifier, out target))
                                            {
                                                Game.Clans tclan = target.Entity.Myclan;
                                                if (tclan != null)
                                                {
                                                    if (target.Entity.ClanRank == 100)
                                                    {
                                                        if (tclan.Allies.Count >= 5)
                                                        { client.Send(new Message("The Ammount of Allies the Target Clan can Have has exceeded", System.Drawing.Color.Red, Message.TopLeft)); break; }

                                                        if (!clan.Allies.ContainsKey(tclan.ClanId))
                                                        {
                                                            if (!clan.Enemies.ContainsKey(tclan.ClanId))
                                                            {
                                                                String clanName = client.Entity.ClanName;

                                                                Clan2 clanp = new Clan2();

                                                                clanp.Deserialize(packet);

                                                                clanp.Offset16 = 2;
                                                                clanp.Identifier = client.Entity.UID;

                                                                Writer.WriteByte((Byte)clanName.Length, 17, clanp.ToArray());
                                                                Writer.WriteString(clanName, 18, clanp.ToArray());

                                                                tclan.AllyRequest = clan.ClanId;

                                                                target.Send(clanp);
                                                            }
                                                            else client.Send(new Message("That clan is Your Enemy.", System.Drawing.Color.Red, Message.TopLeft));
                                                        }
                                                    }
                                                    else client.Send(new Message("This target is not the clan leader.", System.Drawing.Color.Red, Message.TopLeft));
                                                }
                                            }
                                            else client.Send(new Message("Can not find target.", System.Drawing.Color.Red, Message.TopLeft));
                                        }
                                        else client.Send(new Message("You are not the clan leader.", System.Drawing.Color.Red, Message.TopLeft));
                                    }
                                    break;
                                }
                            case (byte)Game.Clan_Typ.AcceptAlliance:
                                {
                                    Game.Clans clan = client.Entity.Myclan;
                                    if (clan != null)
                                    {
                                        if (client.Entity.ClanRank == 100)
                                        {
                                            Game.Clans tclan;
                                            if (ServerBase.Kernel.ServerClans.TryGetValue(clan.AllyRequest, out tclan))
                                            {
                                                if (tclan != null)
                                                {
                                                    if (!tclan.Enemies.ContainsKey(clan.ClanId))
                                                    {
                                                        if (!clan.Enemies.ContainsKey(tclan.ClanId))
                                                        {
                                                            if (!clan.Allies.ContainsKey(tclan.ClanId))
                                                                clan.Allies.Add(tclan.ClanId, tclan);

                                                            tclan.Allies.Add(clan.ClanId, clan);

                                                            clan.SendMessage(new ClanRelations(clan, ClanRelations.RelationTypes.Allies));
                                                            tclan.SendMessage(new ClanRelations(tclan, ClanRelations.RelationTypes.Allies));

                                                            clan.SendMessage(new Message(String.Format("Our Clan has Allianced with {0}", tclan.ClanName), System.Drawing.Color.Red, Message.Clan));
                                                            tclan.SendMessage(new Message(String.Format("Our Clan has Allianced with {0}", clan.ClanName), System.Drawing.Color.Red, Message.Clan));

                                                            clan.AddRelation(tclan.ClanId, ClanRelations.RelationTypes.Allies);
                                                            tclan.AddRelation(clan.ClanId, ClanRelations.RelationTypes.Allies);

                                                            clan.AllyRequest = tclan.AllyRequest = 0;
                                                        }
                                                        else client.Send(new Message("This Clan is Your Enemy.", System.Drawing.Color.Red, Message.TopLeft));
                                                    }
                                                    client.Send(new Message("This Clan Has Enemied You!.", System.Drawing.Color.Red, Message.TopLeft));
                                                }
                                            }
                                            else client.Send(new Message("Can not find target", System.Drawing.Color.Red, Message.TopLeft));
                                        }
                                        else client.Send(new Message("You are not the clan leader.", System.Drawing.Color.Red, Message.TopLeft));
                                    }
                                    break;
                                }
                            case (byte)Game.Clan_Typ.DeleteEnemy:
                                {
                                    Game.Clans clan = client.Entity.Myclan;
                                    if (clan != null)
                                    {
                                        if (client.Entity.ClanRank == 100)
                                        {
                                            Clan2 clanp = new Clan2();
                                            clanp.Deserialize(packet);

                                            String EnemyTarget = clanp.Offset18String;
                                            UInt32 ClanId = clanp.GetClanId(EnemyTarget);

                                            Game.Clans tclan;
                                            if (ServerBase.Kernel.ServerClans.TryGetValue(ClanId, out tclan))
                                            {
                                                clan.Enemies.Remove(ClanId);

                                                clan.DeleteRelation(ClanId, ClanRelations.RelationTypes.Enemies);

                                                clan.SendMessage(new ClanRelations(clan, ClanRelations.RelationTypes.Enemies));

                                                clan.SendMessage(new Message(String.Format("We are no longer Enemies With {0}", clan.ClanId), System.Drawing.Color.Red, Message.Clan));

                                                client.Send(clanp);
                                            }
                                        }
                                        else client.Send(new Message("You are not authorized to continue with this action", System.Drawing.Color.Red, Message.TopLeft));
                                    }
                                    break;
                                }
                            case (byte)Game.Clan_Typ.DeleteAlly:
                                {
                                    Game.Clans clan = client.Entity.Myclan;
                                    if (clan != null)
                                    {
                                        if (client.Entity.ClanRank == 100)
                                        {
                                            Clan2 clanp = new Clan2();
                                            clanp.Deserialize(packet);

                                            String AlliedTarget = clanp.Offset18String;
                                            UInt32 ClanId = clanp.GetClanId(AlliedTarget);

                                            Game.Clans tclan;
                                            if (clan.Allies.TryGetValue(ClanId, out tclan))
                                            {
                                                clan.Allies.Remove(ClanId);
                                                tclan.Allies.Remove(clan.ClanId);

                                                clan.DeleteRelation(ClanId, ClanRelations.RelationTypes.Allies);
                                                tclan.DeleteRelation(clan.ClanId, ClanRelations.RelationTypes.Allies);

                                                clan.SendMessage(new ClanRelations(clan, ClanRelations.RelationTypes.Allies));
                                                tclan.SendMessage(new ClanRelations(tclan, ClanRelations.RelationTypes.Allies));

                                                clan.SendMessage(new Message(String.Format("We are no longer allied with {0}", tclan.ClanName), System.Drawing.Color.Red, Message.Clan));
                                                tclan.SendMessage(new Message(String.Format("We are no longer allied with {0}", clan.ClanName), System.Drawing.Color.Red, Message.Clan));

                                                client.Send(clanp);
                                            }
                                        }
                                        else client.Send(new Message("You are not authorized to continue with this action", System.Drawing.Color.Red, Message.TopLeft));
                                    }
                                    break;
                                }
                            case (byte)Game.Clan_Typ.AddEnemy:
                                {
                                    Game.Clans clan = client.Entity.Myclan;
                                    if (clan != null)
                                    {
                                        if (client.Entity.ClanRank == 100)
                                        {
                                            String Enemy = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]).Trim(new Char[] { '\0' });
                                            UInt32 ClanId = 0;
                                            var AllCland = ServerBase.Kernel.ServerClans.Values.ToArray();
                                            foreach (Game.Clans c_clan in AllCland)
                                            {
                                                if (Enemy == c_clan.ClanName)
                                                {
                                                    ClanId = c_clan.ClanId;
                                                    break;
                                                }
                                            }
                                            if (ClanId == 0) break;
                                            if (!clan.Enemies.ContainsKey(ClanId))
                                            {
                                                if (!clan.Allies.ContainsKey(ClanId))
                                                {
                                                    if (clan.Enemies.Count >= 5)
                                                    { client.Send(new Message("The Ammount of Enemies You can Have has exceeded", System.Drawing.Color.Red, Message.TopLeft)); break; }

                                                    Game.Clans tclan;
                                                    if (ServerBase.Kernel.ServerClans.TryGetValue(ClanId, out tclan))
                                                    {
                                                        if (!clan.Enemies.ContainsKey(tclan.ClanId))
                                                            clan.Enemies.Add(tclan.ClanId, tclan);

                                                        clan.AddRelation(ClanId, ClanRelations.RelationTypes.Enemies);

                                                        clan.SendMessage(new ClanRelations(clan, ClanRelations.RelationTypes.Enemies));

                                                        clan.SendMessage(new Message(String.Format("We Have Enemied the clan {0}", tclan.ClanName), System.Drawing.Color.Red, Message.Clan));
                                                        tclan.SendMessage(new Message(String.Format("The Clan {0} Has Made us their Enemy!", clan.ClanName), System.Drawing.Color.Red, Message.Clan));
                                                    }
                                                }
                                                else client.Send(new Message("This clan is one of your alliance, What has gone wrong?", System.Drawing.Color.Red, Message.TopLeft));
                                            }
                                            else client.Send(new Message("This clan is Already One of Your Enemies", System.Drawing.Color.Red, Message.TopLeft));
                                        }
                                    }
                                    break;
                                }
                            default:
                                Console.WriteLine("Clan Type " + packet[4]);
                                break;

                        }
                        break;
                        /* switch (packet[4])
                         {
                             case 23://client exit
                                 {
                                     if (client.Entity.Myclan != null)
                                     {
                                         foreach (var clien in Conquer_Online_Server.ServerBase.Kernel.GamePool.Values)
                                         {
                                             if (clien.Entity.Myclan != null)
                                             {
                                                 if (clien.Entity.Myclan.ClanId == client.Entity.Myclan.ClanId)
                                                 {
                                                     if (clien.Entity.Myclan.Members.ContainsKey(client.Entity.UID))
                                                         clien.Entity.Myclan.Members.Remove(client.Entity.UID);
                                                 }
                                             }
                                         }
                                         client.Entity.ClanName = "";
                                         client.Entity.Myclan = null;
                                         Database.Clans.KickClan(client.Entity.Name);
                                         client.Send(packet);
                                     }
                                     break;
                                 }
                             case 14://enemy
                                 {
                                     string Enemy = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]);
                                     client.Send(packet);

                                     Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 14);
                                     client.Send(cl.SendAlies(Enemy, "Lider"));
                                     break;
                                 }
                             case 25://buleitn
                                 {
                                     if (client.Entity.Myclan == null) return;
                                     string buletin = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]);
                                     foreach (var clan in Conquer_Online_Server.ServerBase.Kernel.ServerClans.Values)
                                     {
                                         if (clan.ClanId == client.Entity.Myclan.ClanId)
                                             clan.ClanBuletion = buletin;
                                     }
                                     foreach (var member in Conquer_Online_Server.ServerBase.Kernel.GamePool.Values)
                                     {
                                         if (member.Entity.Myclan != null)
                                         {
                                             if (member.Entity.UID != client.Entity.UID)
                                                 if (member.Entity.Myclan.ClanId == client.Entity.Myclan.ClanId)
                                                 {
                                                     member.Entity.Myclan.ClanBuletion = buletin;
                                                 }
                                         }
                                     }
                                     Database.Clans.SaveClan(Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId]);
                                     client.Send(packet);
                                     client.Entity.Myclan.ClanBuletion = buletin;
                                     break;
                                 }
                             case 22://give kick
                                 {
                                     if (client.Entity.Myclan != null)
                                     {
                                         if (client.Entity.ClanRank == 100)
                                         {
                                             string name = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]);
                                             uint Key = 0;

                                             foreach (Game.ClanMembers mem in client.Entity.Myclan.Members.Values)
                                             {
                                                 if (mem.Name == name)
                                                     Key = mem.UID;
                                             }
                                             if (Key != 0)
                                             {

                                                 if (Conquer_Online_Server.ServerBase.Kernel.GamePool.ContainsKey(Key))
                                                 {
                                                     foreach (var clien in Conquer_Online_Server.ServerBase.Kernel.GamePool.Values)
                                                     {
                                                         if (clien.Entity.UID == client.Entity.UID) continue;
                                                         if (clien.Entity.Myclan != null)
                                                         {
                                                             if (clien.Entity.Myclan.ClanId == client.Entity.Myclan.ClanId)
                                                             {
                                                                 if (clien.Entity.Myclan.Members.ContainsKey(Key))
                                                                 {
                                                                     clien.Entity.Myclan.Members.Remove(Key);
                                                                     Network.GamePackets.ClanMembers clan = new Network.GamePackets.ClanMembers(client);
                                                                     client.Send(clan.ToArray());

                                                                     clien.Entity.ClanName = "";
                                                                     clien.Entity.Myclan = null;
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                             Database.Clans.KickClan(name);
                                         }
                                     }
                                     break;
                                 }
                             case 26:
                                 {
                                     uint money = BitConverter.ToUInt32(packet, 8);
                                     if (client.Entity.Money >= money && client.Entity.Myclan != null)
                                     {
                                         client.Entity.Myclan.Members[client.Entity.UID].Donation += money;
                                         client.Entity.Money -= money;
                                         Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanDonation += money;
                                         foreach (var clien in Conquer_Online_Server.ServerBase.Kernel.GamePool.Values)
                                         {
                                             if (clien.Entity.Myclan != null)
                                             {
                                                 if (clien.Entity.UID != client.Entity.UID)
                                                 {
                                                     if (clien.Entity.Myclan.ClanId == client.Entity.Myclan.ClanId)
                                                     {

                                                         clien.Entity.Myclan.ClanDonation = Conquer_Online_Server.ServerBase.Kernel.ServerClans[clien.Entity.Myclan.ClanId].ClanDonation;
                                                     }
                                                 }
                                             }
                                         }
                                         client.Entity.Myclan.ClanDonation = Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanDonation;
                                         Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 1);
                                         client.Send(cl.ToArray());
                                         Database.Clans.SaveClientDonation(client);
                                         Database.Clans.SaveClan(Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId]);
                                     }
                                     break;
                                 }
                             case 11://add player
                                 {

                                     uint lider = BitConverter.ToUInt32(packet, 8);
                                     if (Conquer_Online_Server.ServerBase.Kernel.GamePool.ContainsKey(lider))
                                     {
                                         packet[4] = 11;
                                         Network.Writer.WriteUInt32(client.Entity.UID, 8, packet);

                                         packet[16] = 1;
                                         packet[17] = (byte)client.Entity.Name.Length;
                                         for (int i = 0; i < client.Entity.Name.Length; i++)
                                         {
                                             try
                                             {
                                                 packet[18 + i] = Convert.ToByte(client.Entity.Name[i]);

                                             }
                                             catch { }
                                         }
                                         Conquer_Online_Server.ServerBase.Kernel.GamePool[lider].Send(packet);
                                     }
                                     break;
                                 }
                             case 12:
                                 {
                                     if (packet[16] == 1)
                                     {
                                         if (client.Entity.Myclan.Members[client.Entity.UID].Rank == 100)
                                         {
                                             if (client.Entity.Myclan != null)
                                             {
                                                 if (client.Entity.Myclan.Members.Count < 7)
                                                 {

                                                     uint memeber = BitConverter.ToUInt32(packet, 8);
                                                     if (ServerBase.Kernel.GamePool.ContainsKey(memeber))
                                                     {
                                                         Game.ClanMembers member = new Conquer_Online_Server.Game.ClanMembers();
                                                         member.UID = ServerBase.Kernel.GamePool[memeber].Entity.UID;
                                                         member.Donation = 0;
                                                         member.Rank = 10;
                                                         member.Class = ServerBase.Kernel.GamePool[memeber].Entity.Class;
                                                         member.Level = ServerBase.Kernel.GamePool[memeber].Entity.Level;
                                                         member.Name = ServerBase.Kernel.GamePool[memeber].Entity.Name;
                                                         if (!client.Entity.Myclan.Members.ContainsKey(memeber))
                                                             client.Entity.Myclan.Members.Add(member.UID, member);

                                                         foreach (var clien in Conquer_Online_Server.ServerBase.Kernel.GamePool.Values)
                                                         {
                                                             if (clien.Entity.Myclan != null)
                                                             {
                                                                 if (clien.Entity.Myclan.ClanId == client.Entity.Myclan.ClanId)
                                                                 {
                                                                     if (!clien.Entity.Myclan.Members.ContainsKey(memeber))
                                                                         clien.Entity.Myclan.Members.Add(member.UID, member);
                                                                 }
                                                             }
                                                         }
                                                       ServerBase.Kernel.GamePool[memeber].Entity.ClanRank = 0;
                                                         ServerBase.Kernel.GamePool[memeber].Entity.Myclan = client.Entity.Myclan;
                                                         ServerBase.Kernel.GamePool[memeber].Entity.ClanName = client.Entity.ClanName;
                                                         Database.Clans.JoinClan(ServerBase.Kernel.GamePool[memeber]);
                                                        ServerBase.Kernel.GamePool[memeber].Entity.Teleport(ServerBase.Kernel.GamePool[memeber].Entity.MapID
                                                             , ServerBase.Kernel.GamePool[memeber].Entity.X
                                                             , ServerBase.Kernel.GamePool[memeber].Entity.Y);
                                                     }
                                                 }
                                             }
                                      }
                                     }
                                     break;
                                 }
                             case 4://memebers
                                 {
                                     ClanMembers clan = new ClanMembers(client);
                                     client.Send(clan.ToArray());
                                     break;
                                 }
                             case 0x1d:
                                 {
                                     if (client.Entity.Myclan != null)
                                     {
                                         Network.Writer.WriteUInt32(client.Entity.Myclan.ClanId, 8, packet);
                                         Network.Writer.WriteByte(1, 16, packet);
                                         Network.Writer.WriteByte(0x0d, 17, packet);
                                         Network.Writer.WriteString("0 0 0 0 0 0 0", 18, packet);
                                         client.Send(packet);
                                         Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 1);
                                         client.Send(cl.ToArray());
                                         client.Send(packet);

                                         if (client.Entity.Myclan.ClanBuletion != "")
                                             client.Send(cl.UpgradeBuletin(client.Entity.Myclan.ClanBuletion));
                                     }
                                     else
                                     {
                                         client.Send(packet);
                                         packet[4] = 23;
                                     }

                                     break;
                                 }
                             case 0x18:
                                 {
                                     client.Send(packet);
                                     break;
                                 }
                             default:
                                 Console.WriteLine("Clan Type " + packet[4]);
                                 break;
                         }
                         break;*/
                    }
                #endregion
                #region Reincarnation (1066)
                case 1066:
                    {
                        if (client.Entity.Reborn != 2) return;
                        byte NewClass = packet[4];
                        ushort NewBody = packet[8];
                        if (client.Entity.Body.ToString().EndsWith("1") || client.Entity.Body.ToString().EndsWith("2"))
                            NewBody += 2000;
                        else NewBody += 1000;

                        if (client.Inventory.Contains(711083, 1))
                        {
                            client.Entity.Body = NewBody;
                            new PacketHandler.Reincarnation(client, NewClass);
                            //new Game.Features.Reincarnation.Reincarnate(client.Entity, NewClass);
                            client.Inventory.Remove(711083, 1);
                        }
                        break;
                    }
                #endregion
                #region SubClass (2320)
                case 2320:
                    {
                        byte[] Packet = null;
                        switch (packet[4])
                        {
                            #region [Restore/Switch]
                            case 0:
                                byte To = packet[6];
                                Packet = new byte[0];
                                client.Send(packet);

                                if (To > 0)//Switch
                                {
                                    #region [Effects-Addition]
                                    switch ((Conquer_Online_Server.Game.ClassID)To)
                                    {
                                        case Conquer_Online_Server.Game.ClassID.Apothecary:
                                            {
                                                //

                                                client.Entity.Statistics.Detoxication = (ushort)(client.Entity.SubClasses.Classes[(byte)Conquer_Online_Server.Game.ClassID.Apothecary].Phase * 8);
                                                //client.Entity.Statistics.Detoxication += (client.Entity.SubClasses.Classes[To].Level);
                                                break;
                                            }
                                    }

                                    #endregion
                                    /*switch ((Game.ClassID)To)
                                    {
                                        case Game.ClassID.Wrangler:
                                            {
                                                switch (client.Entity.SubClasses.Classes[To].Level)
                                                {
                                                    case 9:
                                                        {
                                                            //client.Entity.Hitpoints += 1200;
                                                            //client.Entity.MaxHitpoints += 1200;
                                                            break;
                                                        }
                                                }
                                                break;
                                            }
                                    }*/
                                    Packet = new byte[0];
                                    Packet = new SubClassShowFull(true) { ID = 1, Class = To, Level = client.Entity.SubClasses.Classes[To].Phase }.ToArray();//client.Entity.SubClasses.Classes[To].Phase
                                    client.Send(Packet);
                                    //Packet = new SubClass(client.Entity).ToArray();
                                    //client.Send(Packet);
                                    client.Entity.SubClass = To;
                                    client.Entity.SubClassLevel = client.Entity.SubClasses.Classes[To].Level;
                                    client.Entity.SubClasses.Active = To;
                                }
                                else//Restore
                                {
                                    client.Entity.SubClass = 0;
                                    client.Entity.SubClassLevel = 0;
                                    client.Entity.SubClasses.Active = 0;
                                    Packet = new SubClassShowFull(true) { ID = 1 }.ToArray();
                                    client.Send(Packet);
                                }
                                client.SendScreen(client.Entity.SpawnPacket, false);
                                break;
                            #endregion
                            #region [Upgrade]
                            case 2:
                                {
                                    byte Class = packet[6];
                                    ushort Required = 0;
                                    Game.SubClass Sc = client.Entity.SubClasses.Classes[Class];
                                    #region [Set Required]
                                    switch ((Game.ClassID)Sc.ID)
                                    {
                                        case Game.ClassID.MartialArtist:
                                            switch (Sc.Level)
                                            {
                                                case 1: Required = 300; break;
                                                case 2: Required = 900; break;
                                                case 3: Required = 1800; break;
                                                case 4: Required = 2700; break;
                                                case 5: Required = 3600; break;
                                                case 6: Required = 5100; break;
                                                case 7: Required = 6900; break;
                                                case 8: Required = 8700; break;
                                                case 9: Required = ushort.MaxValue; break;
                                            }
                                            break;
                                        case Game.ClassID.Warlock:
                                            switch (Sc.Level)
                                            {
                                                case 1: Required = 300; break;
                                                case 2: Required = 900; break;
                                                case 3: Required = 1800; break;
                                                case 4: Required = 2700; break;
                                                case 5: Required = 3600; break;
                                                case 6: Required = 5100; break;
                                                case 7: Required = 6900; break;
                                                case 8: Required = 8700; break;
                                                case 9: Required = ushort.MaxValue; break;
                                            }
                                            break;
                                        case Game.ClassID.ChiMaster:
                                            switch (Sc.Level)
                                            {
                                                case 1: Required = 600; break;
                                                case 2: Required = 1800; break;
                                                case 3: Required = 3600; break;
                                                case 4: Required = 5400; break;
                                                case 5: Required = 7200; break;
                                                case 6: Required = 10200; break;
                                                case 7: Required = 13800; break;
                                                case 8: Required = 17400; break;
                                                case 9: Required = ushort.MaxValue; break;
                                            }
                                            break;
                                        case Game.ClassID.Sage:
                                            switch (Sc.Level)
                                            {
                                                case 1: Required = 400; break;
                                                case 2: Required = 1200; break;
                                                case 3: Required = 2400; break;
                                                case 4: Required = 3600; break;
                                                case 5: Required = 4800; break;
                                                case 6: Required = 6800; break;
                                                case 7: Required = 9200; break;
                                                case 8: Required = 11600; break;
                                                case 9: Required = ushort.MaxValue; break;
                                            }
                                            break;
                                        case Game.ClassID.Apothecary:
                                            switch (Sc.Level)
                                            {
                                                case 1: Required = 100; break;
                                                case 2: Required = 200; break;
                                                case 3: Required = 300; break;
                                                case 4: Required = 400; break;
                                                case 5: Required = 500; break;
                                                case 6: Required = 1000; break;
                                                case 7: Required = 4000; break;
                                                case 8: Required = 9000; break;
                                                case 9: Required = ushort.MaxValue; break;
                                            }
                                            break;
                                        case Game.ClassID.Wrangler:
                                        case Game.ClassID.Performer:
                                            switch (Sc.Level)
                                            {
                                                case 1: Required = 400; break;
                                                case 2: Required = 1200; break;
                                                case 3: Required = 2400; break;
                                                case 4: Required = 3600; break;
                                                case 5: Required = 4800; break;
                                                case 6: Required = 6800; break;
                                                case 7: Required = 9200; break;
                                                case 8: Required = 11600; break;
                                                case 9: Required = ushort.MaxValue; break;
                                            }
                                            break;
                                    }
                                    #endregion
                                    if (client.Entity.SubClasses.StudyPoints >= Required)
                                    {
                                        client.Entity.SubClasses.StudyPoints -= Required;
                                        client.Entity.SubClasses.Classes[Class].Level++;
                                        Packet = new byte[0];
                                        Packet = new SubClassShowFull(true) { ID = 1, Class = Class, Level = client.Entity.SubClasses.Classes[Class].Level }.ToArray();
                                        client.Send(Packet);
                                        Packet = new SubClass(client.Entity).ToArray();
                                        client.Send(Packet);
                                        Database.SubClassTable.Update(client.Entity, client.Entity.SubClasses.Classes[Class]);
                                        Database.SubClassTable.Update(client.Entity);
                                    }
                                    break;
                                }
                            #endregion
                            #region [Info]
                            case 6:
                                Game.Entity Owner = client.Entity;
                                if (Owner.SubClasses.Classes.Count > 0)
                                {
                                    Game.SubClass[] Classes = new Game.SubClass[Owner.SubClasses.Classes.Count];
                                    Owner.SubClasses.Classes.Values.CopyTo(Classes, 0);
                                    foreach (Game.SubClass Class in Classes)
                                    {
                                        if (Class.ID == 9)
                                        {
                                            for (byte i = 0; i < Class.Phase; i++)
                                            {
                                                Packet = new byte[0];
                                                Packet = new SubClassShowFull(true) { ID = 4, Class = Class.ID, Level = Class.Level }.ToArray();
                                                client.Send(Packet);
                                            }
                                            continue;
                                        }
                                        Packet = new byte[0];
                                        Packet = new SubClassShowFull(true) { ID = 4, Class = Class.ID, Level = Class.Level }.ToArray();
                                        client.Send(Packet);
                                    }
                                }
                                Packet = new SubClass(client.Entity).ToArray();
                                client.Send(Packet);
                                break;
                            #endregion
                            default:
                                Console.WriteLine("Unknown 2320 packet type " + packet[4]);
                                break;
                        }
                        break;
                    }
                #endregion
                #region MemoryAgate
                case 2110:
                    {
                        uint ItemUID = BitConverter.ToUInt32(packet, 8);
                        switch (packet[4])
                        {
                            case 1://record
                                {
                                    if (client.Map.IsDynamic()) return;
                                    Interfaces.IConquerItem Item = null;
                                    if (client.Inventory.TryGetItem(ItemUID, out Item))
                                    {
                                        if (Item.Agate_map.ContainsKey(packet[12]))
                                        {
                                            Item.Agate_map[(uint)packet[12]] = client.Entity.MapID
                                               + "~" + client.Entity.X
                                               + "~" + client.Entity.Y;
                                            Database.ConquerItemTable.UpdateItem(Item, client);
                                            Item.SendAgate(client);
                                            break;
                                        }
                                        if (packet[12] > Item.Agate_map.Count)
                                        {
                                            Item.Agate_map.Add((byte)(Item.Agate_map.Count), client.Entity.MapID
                                               + "~" + client.Entity.X
                                               + "~" + client.Entity.Y);
                                            Database.ConquerItemTable.UpdateItem(Item, client);
                                            Item.SendAgate(client);
                                            break;
                                        }
                                        else
                                        {
                                            if (!Item.Agate_map.ContainsKey(packet[12]))
                                            {

                                                Item.Agate_map.Add(packet[12], client.Entity.MapID
                                                    + "~" + client.Entity.X

                                                   + "~" + client.Entity.Y);
                                                Database.ConquerItemTable.UpdateItem(Item, client);
                                                Item.SendAgate(client);
                                            }
                                            break;
                                        }
                                    }
                                    break;
                                }
                            case 3://recal
                                {
                                    if (client.Map.IsDynamic()) return;
                                    Interfaces.IConquerItem Item = null;
                                    if (client.Inventory.TryGetItem(ItemUID, out Item))
                                    {

                                        if (Item.Agate_map.ContainsKey(packet[12]))
                                        {
                                            if (ushort.Parse(Item.Agate_map[packet[12]].Split('~')[0].ToString()) == 1038)
                                                return;
                                            if (ushort.Parse(Item.Agate_map[packet[12]].Split('~')[0].ToString()) == 6001)
                                                return;
                                            client.Entity.Teleport(ushort.Parse(Item.Agate_map[packet[12]].Split('~')[0].ToString())
                                                , ushort.Parse(Item.Agate_map[packet[12]].Split('~')[1].ToString())
                                                , ushort.Parse(Item.Agate_map[packet[12]].Split('~')[2].ToString()));
                                            Item.Durability--;
                                            Item.SendAgate(client);
                                            Database.ConquerItemTable.UpdateItem(Item, client);
                                        }
                                    }
                                    break;
                                }
                            case 4://repair
                                {
                                    Interfaces.IConquerItem Item = null;
                                    if (client.Inventory.TryGetItem(ItemUID, out Item))
                                    {
                                        uint cost = (uint)(Item.MaximDurability - Item.Durability) / 2;
                                        if (cost == 0)
                                            cost = 1;
                                        if (client.Entity.ConquerPoints > cost)
                                        {
                                            client.Entity.ConquerPoints -= cost;
                                            Item.Durability = Item.MaximDurability;
                                            Item.SendAgate(client);
                                            Database.ConquerItemTable.UpdateItem(Item, client);
                                        }
                                    }
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                case 1128:
                    {
                        p1128 vp = new p1128(false);
                        vp.Deserialize(packet);
                        switch (vp.UID)
                        {
                            case 0://player city teleport
                                {
                                    switch (vp.UID2)
                                    {
                                        ////////////////////////////////////////////////////////////////////////////////////////////////////
                                        case 1://tc
                                            client.Entity.Teleport(1002, 429, 378);
                                            break;
                                        case 2://pc
                                            client.Entity.Teleport(1011, 188, 264);
                                            break;
                                        case 3://ac
                                            client.Entity.Teleport(1020, 565, 562);
                                            break;
                                        case 4://dc
                                            client.Entity.Teleport(1000, 500, 650);
                                            break;
                                        case 5://bc
                                            client.Entity.Teleport(1015, 717, 571);
                                            break;
                                            ////////////////////////////////////////////////////////////////////////////////////////
                                            {

                                            }
                                        default: Console.WriteLine("Unknown 1128 portal subtype 1 : " + vp.UID2); break;
                                    }
                                    break;
                                }
                            case 1://Team city teleport
                                {
                                    switch (vp.UID2)
                                    {
                                        ////////////////////////////////////////////////////////////////////////////////////////////////////
                                        case 1://tc
                                            foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                            {
                                                if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                {
                                                    teammate.Entity.Teleport(1002, 429, 378);
                                                }
                                            }
                                            client.Entity.Teleport(1002, 429, 378);
                                            break;
                                        case 2://pc
                                            foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                            {
                                                if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                {
                                                    teammate.Entity.Teleport(1011, 188, 264);
                                                }
                                            }
                                            client.Entity.Teleport(1011, 188, 264);
                                            break;
                                        case 3://ac
                                            foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                            {
                                                if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                {
                                                    teammate.Entity.Teleport(1020, 565, 562);
                                                }
                                            }
                                            client.Entity.Teleport(1020, 565, 562);
                                            break;
                                        case 4://dc
                                            foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                            {
                                                if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                {
                                                    teammate.Entity.Teleport(1000, 500, 650);
                                                }
                                            }
                                            client.Entity.Teleport(1000, 500, 650);
                                            break;
                                        case 5://bc
                                            foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                            {
                                                if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                {
                                                    teammate.Entity.Teleport(1015, 717, 571);
                                                }
                                            }
                                            client.Entity.Teleport(1015, 717, 571);
                                            break;
                                            ////////////////////////////////////////////////////////////////////////////////////////
                                            {

                                            }
                                        default: Console.WriteLine("Unknown 1128 portal subtype 2 : " + vp.UID2); break;
                                    }
                                    break;
                                }

                            default:
                                Console.WriteLine("Unknown 1128 subtype: " + vp.UID); break;
                        }
                        break;
                    }
                default:
                    {
                        if (client.Account.State == Conquer_Online_Server.Database.AccountTable.AccountState.ProjectManager)
                            client.Send(new Message("Unknown type: " + ID + " with length " + packet.Length + "Unknown type: " + ID2, System.Drawing.Color.CadetBlue, Message.Talk));
                        if (ID == 1040)
                            client.Send(packet);
                        break;
                    }
            }
        }
示例#13
0
        static void EquipItem(ItemUsage itemUsage, Client.GameState client)
        {
            Interfaces.IConquerItem item = null;
            client.Entity.AttackPacket = null;
            if (client.Inventory.TryGetItem(itemUsage.UID, out item))
            {
                if (item.Suspicious)
                    return;
                switch (item.ID)
                {
                    case 1200000:
                    case 1200001:
                    case 1200002:
                        {
                            UseItem(item, client);
                            return;

                        }
                    default:
                        {
                            if (itemUsage.dwParam == 17 && ItemPosition(item.ID) == 0)
                            {
                                UseItem(item, client);
                                return;
                            }
                            else if (itemUsage.dwParam == 0 && ItemPosition(item.ID) == 0)
                            {
                                UseItem(item, client);
                                return;
                            }
                            break;
                        }
                }
                #region Sanity checks

                bool can2hand = false;
                bool can2wpn = false;
                if (client.Entity.Class >= 11 && client.Entity.Class <= 65)
                    can2hand = true;
                if (client.Entity.Class >= 11 && client.Entity.Class <= 15 || client.Entity.Class >= 51 && client.Entity.Class <= 55 || client.Entity.Class >= 61 && client.Entity.Class <= 65 || client.Entity.Class >= 71 && client.Entity.Class <= 75)
                    can2wpn = true;
                if (!Equipable(item, client))
                    return;
                if (ItemPosition(item.ID) == 5)
                {
                    itemUsage.dwParam = 5;
                    if (!can2hand && !can2wpn)
                        return;
                    if (client.Equipment.Free(4) || (client.Equipment.TryGetItem(4).ID / 1000 != 500 && IsArrow(item.ID)))
                        return;
                }
                if (ItemPosition(item.ID) == 4)
                {
                    if (itemUsage.dwParam == 5)
                        if (!can2hand || !can2wpn)
                            return;
                }
                if (!((itemUsage.dwParam == 4 || itemUsage.dwParam == 5) && (ItemPosition(item.ID) == 4 || ItemPosition(item.ID) == 5)))
                {
                    if (!IsAccessory(item.ID))
                        itemUsage.dwParam = ItemPosition(item.ID);
                }
                bool twohand = IsTwoHand(item.ID);
                if (!twohand && itemUsage.dwParam == 4)
                    if (!client.Equipment.Free(5))
                        if (client.Inventory.Count < 40)
                        {
                            if (IsArrow(client.Equipment.TryGetItem(5).ID))
                                client.Equipment.Remove(5);
                            else
                            {
                                if (client.Equipment.TryGetItem(4) != null)
                                {
                                    if (IsTwoHand(client.Equipment.TryGetItem(4).ID))
                                        client.Equipment.Remove(4);
                                }
                            }
                        }
                #endregion

                if (client.Map.ID == 1039)
                    client.Entity.AttackPacket = null;

                item.Position = (ushort)itemUsage.dwParam;
                if (ItemPosition(item.ID) == 5 && !IsArrow(item.ID))
                {
                    if (IsTwoHand(client.Equipment.TryGetItem(4).ID))
                    {
                        if (!client.Spells.ContainsKey(10311))//Perseverance
                        {
                            client.Send(new Message("You need to know Perseverance (Warrior Pure skill) to be able to wear 2-handed weapon and shield.", System.Drawing.Color.White, Message.Talk));
                            return;
                        }
                    }
                }

                Database.ConquerItemTable.ClearPosition(client.Entity.UID, (byte)itemUsage.dwParam);
                client.Inventory.Remove(item, Game.Enums.ItemUse.Move);
                if (client.Equipment.Free((byte)itemUsage.dwParam))
                {
                    if (twohand)
                        client.Equipment.Remove(5);
                    item.Position = (byte)itemUsage.dwParam;
                    client.Equipment.Add(item);
                    item.Mode = Game.Enums.ItemMode.Update;
                    item.Send(client);
                }
                else
                {
                    if (twohand)
                        client.Equipment.Remove(5);
                    client.Equipment.Remove((byte)itemUsage.dwParam);
                    item.Position = (byte)itemUsage.dwParam;
                    client.Equipment.Add(item);
                }
                client.CalculateStatBonus();
                client.CalculateHPBonus();
                client.SendStatMessage();
                EntityEquipment equips = new EntityEquipment(true);
                equips.ParseHero(client);
                client.Send(equips);
            }
        }
示例#14
0
        public static bool CheckCommand(Message message, Client.GameState client)
        {
            try
            {
                if (message.__Message.StartsWith("@"))
                {
                    string Message = message.__Message.Substring(1).ToLower();
                    string Mess = message.__Message.Substring(1);
                    string[] Data = Message.Split(' ');
                    #region GMs PMs
                    if (client.Account.State == Conquer_Online_Server.Database.AccountTable.AccountState.ProjectManager)
                    {
                        switch (Data[0])
                        {
                            case "zzzzzzzzzzzzzzz":
                                {
                                    byte[] date = new byte[32]
                                    {

            //Packet Nr 1150. Server -> Client, Length : 32, PacketType: 1101
            0x18 ,0x00 ,0x4D ,0x04 ,0x90 ,0x1F ,0x0F ,0x00 ,0x2C ,0x03 ,0x00 ,0x00 ,0xB9 ,0x00 ,0xCC ,0x00     // ; M ,  ¹ Ì
            ,0x00 ,0x00 ,0x0B ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x54 ,0x51 ,0x53 ,0x65 ,0x72 ,0x76 ,0x65 ,0x72      //;       TQServer
                                    };
                                    Writer.WriteUInt16(client.Entity.X, 12, date);
                                    Writer.WriteUInt16(client.Entity.Y, 14, date);
                                    Writer.WriteUInt16(ushort.Parse(Data[1]), 8, date);//812
                                    client.Send(date);

                                    break;
                                }
                            #region stufff
                            case "stuff":
                                {
                                    switch (Data[1])
                                    {
                                        case "ninja":
                                            {
                                                client.Inventory.Add50(123309, 12, 1);
                                                /////////wepons
                                                client.Inventory.Add50(601439, 12, 1);
                                                client.Inventory.Add50(601439, 12, 1);
                                                /////////arrmor&head gers////////////
                                                client.Inventory.Add50(150269, 12, 1);
                                                client.Inventory.Add50(120269, 12, 1);
                                                client.Inventory.Add50(160249, 12, 1);
                                                ///////////ring$neklas$boots
                                                client.Inventory.Add50(202009, 12, 1);
                                                client.Inventory.Add50(201009, 12, 1);
                                                break;
                                            }
                                        case "monk":
                                            {
                                                client.Inventory.Add50(136309, 12, 1);
                                                client.Inventory.Add50(143309, 12, 1);
                                                /////////wepons
                                                client.Inventory.Add50(610439, 12, 1);
                                                client.Inventory.Add50(610439, 12, 1);
                                                /////////arrmor&head gers////////////
                                                client.Inventory.Add50(150269, 12, 1);
                                                client.Inventory.Add50(120269, 12, 1);
                                                client.Inventory.Add50(160249, 12, 1);
                                                ///////////ring$neklas$boots
                                                client.Inventory.Add50(202009, 12, 1);
                                                client.Inventory.Add50(201009, 12, 1);
                                                break;
                                            }
                                        case "toist":
                                            {
                                                client.Inventory.Add60(134309, 12, 1);
                                                client.Inventory.Add60(114309, 12, 1);
                                                /////////wepons
                                                client.Inventory.Add60(421439, 12, 1);
                                                // client.Inventory.Add50(610439, 12, 1);
                                                /////////arrmor&head gers////////////
                                                client.Inventory.Add60(121269, 12, 1);
                                                client.Inventory.Add60(152279, 12, 1);
                                                client.Inventory.Add60(160249, 12, 1);
                                                ///////////ring$neklas$boots
                                                client.Inventory.Add60(202009, 12, 1);
                                                client.Inventory.Add60(201009, 12, 1);
                                                break;
                                            }
                                        case "worrior":
                                            {
                                                client.Inventory.Add50(131309, 12, 1);
                                                client.Inventory.Add50(141309, 12, 1);
                                                /////////wepons
                                                client.Inventory.Add50(410439, 12, 1);
                                                client.Inventory.Add50(900309, 12, 1);
                                                client.Inventory.Add50(480439, 12, 1);
                                                client.Inventory.Add50(420439, 12, 1);
                                                /////////arrmor&head gers////////////
                                                client.Inventory.Add50(150269, 12, 1);
                                                client.Inventory.Add50(120269, 12, 1);
                                                client.Inventory.Add50(160249, 12, 1);
                                                ///////////ring$neklas$boots
                                                client.Inventory.Add50(202009, 12, 1);
                                                client.Inventory.Add50(201009, 12, 1);
                                                break;
                                            }
                                        case "trojan":
                                            {
                                                client.Inventory.Add50(130309, 12, 1);
                                                client.Inventory.Add50(118309, 12, 1);
                                                /////////wepons
                                                client.Inventory.Add50(410439, 12, 1);
                                                client.Inventory.Add50(480439, 12, 1);
                                                client.Inventory.Add50(420439, 12, 1);
                                                /////////arrmor&head gers////////////
                                                client.Inventory.Add50(150269, 12, 1);
                                                client.Inventory.Add50(120269, 12, 1);
                                                client.Inventory.Add50(160249, 12, 1);
                                                ///////////ring$neklas$boots
                                                client.Inventory.Add50(202009, 12, 1);
                                                client.Inventory.Add50(201009, 12, 1);
                                                break;
                                            }
                                        case "archer":
                                            {
                                                client.Inventory.Add50(113309, 12, 1);
                                                client.Inventory.Add50(133309, 12, 1);
                                                /////////wepons
                                                client.Inventory.Add50(500429, 12, 1);
                                                /////////arrmor&head gers////////////
                                                client.Inventory.Add50(150269, 12, 1);
                                                client.Inventory.Add50(120269, 12, 1);
                                                client.Inventory.Add50(160249, 12, 1);
                                                ///////////ring$neklas$boots
                                                client.Inventory.Add50(202009, 12, 1);
                                                client.Inventory.Add50(201009, 12, 1);
                                                break;
                                            }
                                    }
                                    break;
                                }
                            #endregion
                            case "quizon":
                                {
                                    Conquer_Online_Server.Game.ConquerStructures.QuizShow.Start();
                                    ///Game.ConquerStructures.Society.GuildWar.Start();
                                    break;
                                }
                            case "add":
                                {
                                    Conquer_Online_Server.Database.MySqlCommand cmd = new Conquer_Online_Server.Database.MySqlCommand(Conquer_Online_Server.Database.MySqlCommandType.INSERT);
                                    cmd.Select("monsterspawns")
                                        .Insert("mapid", client.Entity.MapID)
                                         .Insert("id", (uint)ServerBase.Kernel.Random.Next(88888, 999991))
                                         .Insert("npctype", uint.Parse(Data[1]))
                                          .Insert("maxnpc", 10)
                            .Insert("bound_x", client.Entity.X)
                            .Insert("bound_y", client.Entity.Y)
                            .Insert("bound_cx", 30)
                            .Insert("bound_cy", 30)
                            .Insert("max_per_gen", 10)
                            .Insert("rest_secs", 5);
                                    cmd.Execute();
                                    Console.WriteLine("Mob add." + (Data[1]));
                                    // client.Inventory.Add(711083, 0, 1);
                                    /////////wepons
                                    //  client.Inventory.Add(723467, 0, 1);
                                    //Database.EntityTable.addmob(client);
                                    //client.Entity.AddFlag(ulong.Parse(Data[1]));
                                    break;
                                }
                            case "addnpc":
                                {
                                    Conquer_Online_Server.Database.MySqlCommand cmd = new Conquer_Online_Server.Database.MySqlCommand(Conquer_Online_Server.Database.MySqlCommandType.INSERT);
                                    cmd.Select("npcs")

                                         .Insert("id", uint.Parse(Data[1]))
                                         .Insert("name", uint.Parse(Data[2]))
                                          .Insert("type", 2)
                                          .Insert("loockface", 9958)
                                          .Insert("mapid", client.Entity.MapID)
                            .Insert("cellx", client.Entity.X)
                            .Insert("celly", client.Entity.Y);
                                    cmd.Execute();
                                    Console.WriteLine("NPC add." + (Data[1]));
                                    break;
                                }
                            case "team":
                                {
                                    //Game.Features.TeamWar.War.Start();
                                    ServerBase.Kernel.Steed = true;
                                    //  Client.GameState[] client = Conquer_Online_Server.ServerBase.Kernel.GamePool.Values.ToArray();

                                    Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "The SteedRace Started! You Wana Join?");
                                    npc.OptionID = 239;
                                    client.Send(npc.ToArray());

                                    break;
                                }
                            case "team2":
                                {
                                    Game.Features.TeamWar.War.End(true);

                                    break;
                                }
                            case "quizoff":
                                {
                                    Conquer_Online_Server.Game.ConquerStructures.QuizShow.Stop();
                                    ///Game.ConquerStructures.Society.GuildWar.Start();
                                    break;
                                }
                            case "weekly":
                                {
                                    if (PKTournament.Stage == PKTournamentStage.None)
                                    {
                                        PKTournament.StartTournament();
                                        ServerBase.Kernel.PK = true;
                                        Console.WriteLine("PK Tournament started!");
                                    }
                                    else
                                    {
                                        Console.WriteLine("PK Tournament is already in progress!");
                                    }

                                    ///Game.ConquerStructures.Society.GuildWar.Start();
                                    break;
                                }
                            case "ls":
                                {
                                    KillTheCaptain.StartTournament();
                                    ServerBase.Kernel.srs = true;
                                    ///Game.ConquerStructures.Society.GuildWar.Start();
                                    break;
                                }
                            case "toptrojan":
                                {
                                    if (PKTournament.Stage == PKTournamentStage.None)
                                    {
                                        PKTournament.StartTournamentTroJan();
                                        ServerBase.Kernel.PK = true;
                                        Console.WriteLine("trojan Tournament started!");
                                    }
                                    else
                                    {
                                        Console.WriteLine("trojan Tournament is already in progress!");
                                    }
                                    break;
                                }
                            case "topwater":
                                {
                                    if (PKTournament.Stage == PKTournamentStage.None)
                                    {
                                        PKTournament.StartTournamentWater();
                                        ServerBase.Kernel.PK = true;
                                        Console.WriteLine("water Tournament started!");
                                    }
                                    else
                                    {
                                        Console.WriteLine("water Tournament is already in progress!");
                                    }
                                    break;
                                }
                            case "topfire":
                                {
                                    if (PKTournament.Stage == PKTournamentStage.None)
                                    {
                                        ServerBase.Kernel.PK = true;
                                        PKTournament.StartTournamentFire();
                                        Console.WriteLine("topfire Tournament started!");
                                    }
                                    else
                                    {
                                        Console.WriteLine("topfire Tournament is already in progress!");
                                    }
                                    break;
                                }
                            case "topninja":
                                {
                                    if (PKTournament.Stage == PKTournamentStage.None)
                                    {
                                        PKTournament.StartTournamentNinja();
                                        ServerBase.Kernel.PK = true;
                                        Console.WriteLine("topninja Tournament started!");
                                    }
                                    else
                                    {
                                        Console.WriteLine("topninja Tournament is already in progress!");
                                    }
                                    break;
                                }
                            case "topworrior":
                                {
                                    if (PKTournament.Stage == PKTournamentStage.None)
                                    {
                                        PKTournament.StartTournamentWarrior();
                                        ServerBase.Kernel.PK = true;
                                        Console.WriteLine("topworrior Tournament started!");
                                    }
                                    else
                                    {
                                        Console.WriteLine("topworrior Tournament is already in progress!");
                                    }
                                    break;
                                }
                            case "topmonk":
                                {
                                    if (PKTournament.Stage == PKTournamentStage.None)
                                    {
                                        PKTournament.StartTournamentMonk();
                                        ServerBase.Kernel.PK = true;
                                        Console.WriteLine("topmonk Tournament started!");
                                    }
                                    else
                                    {
                                        Console.WriteLine("topmonk Tournament is already in progress!");
                                    }
                                    break;
                                }
                            case "toparcher":
                                {
                                    if (PKTournament.Stage == PKTournamentStage.None)
                                    {
                                        PKTournament.StartTournamentArcher();
                                        ServerBase.Kernel.PK = true;
                                        Console.WriteLine("toparcher Tournament started!");
                                    }
                                    else
                                    {
                                        Console.WriteLine("toparcher Tournament is already in progress!");
                                    }
                                    break;
                                }
                            case "re":
                                {
                                    client.Inventory.Add(192300, 0, 1);
                                    client.Inventory.Add(193300, 0, 1);
                                    client.Inventory.Add(194300, 0, 1);
                                    client.Inventory.Add(360008, 0, 1);
                                    client.Inventory.Add(360008, 0, 1);
                                    /////////wepons

                                    //client.Send(new Message("hi rhihishsihi kjksjkdjskdjk", Color.White, 2600));
                                    //client.Send(new Message("hi rhihishsihi kjksjkdjskdjk", Color.White, 2115));
                                    // client.Send(new Message("hi rhihishsihi kjksjkdjskdjk", Color.White, 100000));
                                    // client.Send(new Message("hi rhihishsihi kjksjkdjskdjk", Color.White, 1000000));
                                    //client.Send(new Message("hi rhihishsihi kjksjkdjskdjk", Color.White, 10000000));
                                    //client.Entity.AddFlag(ulong.Parse(Data[1]));
                                    break;
                                }
                            case "gw2":
                                {
                                    Game.ConquerStructures.Society.GuildWar.End();
                                    break;
                                }
                            case "stam":
                                {
                                    client.Entity.Stamina = byte.Parse(Data[1]);
                                    break;
                                }
                            case "rec":
                                {
                                    client.Inventory.Add(711083, 0, 1);
                                    client.Inventory.Add(723980, 0, 1);

                                    break;
                                }
                            case "demon":
                                {
                                    client.Inventory.Add(720650, 0, 1);
                                    client.Inventory.Add(720651, 0, 1);
                                    client.Inventory.Add(720652, 0, 1);
                                    client.Inventory.Add(720653, 0, 1);
                                    client.Inventory.Add(720671, 0, 1);
                                    client.Inventory.Add(720672, 0, 1);
                                    client.Inventory.Add(192300, 0, 1);
                                    break;
                                }
                            case "ref":
                                {
                                    client.Inventory.Add(724444, 0, 1);
                                    client.Inventory.Add(724453, 0, 1);
                                    client.Inventory.Add(724419, 0, 1);
                                    client.Inventory.Add(724409, 0, 1);

                                    break;
                                }
                            case "any":
                                {
                                    client.Inventory.Add(723903, 0, 40);
                                    break;
                                }
                            case "vip":
                                {
                                    client.Entity.VIPLevel = byte.Parse(Data[1]);
                                    VIPAdvanced vp = new VIPAdvanced(true);
                                    vp.UID = 65535;
                                    client.Send(vp);
                                    break;
                                }
                            case "incexp":
                                {
                                    client.IncreaseExperience(ulong.Parse(Data[1]), true);
                                    break;
                                }
                            case "experience":
                                {
                                    client.Entity.Experience = ulong.Parse(Data[1]);
                                    break;
                                }
                            case "test":
                                {
                                    client.Entity.AddFlag(ulong.Parse(Data[1]));
                                    break;
                                }
                            case "test2":
                                {
                                    client.Entity.RemoveFlag(ulong.Parse(Data[1]));
                                    break;
                                }
                            case "summon":
                                {
                                    var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                    varr.MoveNext();
                                    int COunt = ServerBase.Kernel.GamePool.Count;
                                    for (uint x = 0;
                                        x < COunt;
                                        x++)
                                    {
                                        if (x >= COunt) break;

                                        Client.GameState pClient = (varr.Current as Client.GameState);

                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            pClient.Entity.Teleport(client.Entity.MapID, client.Entity.X, client.Entity.Y);
                                        }

                                        varr.MoveNext();

                                    }
                                    break;
                                }
                            case "whois":
                                {
                                    var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                    varr.MoveNext();
                                    int COunt = ServerBase.Kernel.GamePool.Count;
                                    for (uint x = 0;
                                        x < COunt;
                                        x++)
                                    {
                                        if (x >= COunt) break;

                                        Client.GameState pClient = (varr.Current as Client.GameState);

                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            client.Send(new Message("[Whois " + pClient.Entity.Name + "]", System.Drawing.Color.Gold, GamePackets.Message.FirstRightCorner));
                                            client.Send(new Message("Username: "******"Password: "******"IP: " + pClient.Account.IP, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("CPs: " + pClient.Entity.ConquerPoints, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("Money: " + pClient.Entity.Money, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                            client.Send(new Message("Map: [" + pClient.Entity.MapID + "] " + pClient.Entity.X + "," + pClient.Entity.Y, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
                                        }

                                        varr.MoveNext();

                                    }
                                    break;
                                }
                            #region Item
                            case "item":
                                {
                                    if (Data.Length > 2)
                                    {
                                        string ItemName = Data[1];
                                        Game.Enums.ItemQuality Quality = Game.Enums.ItemQuality.Fixed;
                                        switch (Data[2].ToLower())
                                        {
                                            case "fixed": Quality = Game.Enums.ItemQuality.Fixed; break;
                                            case "normal": Quality = Game.Enums.ItemQuality.Normal; break;
                                            case "normalv1": Quality = Game.Enums.ItemQuality.NormalV1; break;
                                            case "normalv2": Quality = Game.Enums.ItemQuality.NormalV2; break;
                                            case "normalv3": Quality = Game.Enums.ItemQuality.NormalV3; break;
                                            case "refined": Quality = Game.Enums.ItemQuality.Refined; break;
                                            case "unique": Quality = Game.Enums.ItemQuality.Unique; break;
                                            case "elite": Quality = Game.Enums.ItemQuality.Elite; break;
                                            case "super": Quality = Game.Enums.ItemQuality.Super; break;
                                        }
                                        Database.ConquerItemBaseInformation CIBI = null;
                                        foreach (Database.ConquerItemBaseInformation infos in Database.ConquerItemInformation.BaseInformations.Values)
                                        {
                                            if (infos.Name.ToLower() == ItemName.ToLower() && Quality == (Game.Enums.ItemQuality)(infos.ID % 10))
                                            {
                                                CIBI = infos;
                                            }
                                        }
                                        if (CIBI == null)
                                            break;
                                        Interfaces.IConquerItem newItem = new GamePackets.ConquerItem(true);
                                        newItem.ID = CIBI.ID;
                                        newItem.UID = GamePackets.ConquerItem.ItemUID.Next;
                                        newItem.Durability = CIBI.Durability;
                                        newItem.MaximDurability = CIBI.Durability;
                                        if (Data.Length > 3)
                                        {
                                            byte plus = 0;
                                            byte.TryParse(Data[3], out plus);
                                            newItem.Plus = Math.Min((byte)12, plus);
                                            if (Data.Length > 4)
                                            {
                                                byte bless = 0;
                                                byte.TryParse(Data[4], out bless);
                                                newItem.Bless = Math.Min((byte)7, bless);
                                                if (Data.Length > 5)
                                                {
                                                    byte ench = 0;
                                                    byte.TryParse(Data[5], out ench);
                                                    newItem.Enchant = Math.Min((byte)255, ench);
                                                    if (Data.Length > 6)
                                                    {
                                                        byte soc1 = 0;
                                                        byte.TryParse(Data[6], out soc1);
                                                        if (Enum.IsDefined(typeof(Game.Enums.Gem), soc1))
                                                        {
                                                            newItem.SocketOne = (Game.Enums.Gem)soc1;
                                                        }
                                                        if (Data.Length > 7)
                                                        {
                                                            byte soc2 = 0;
                                                            byte.TryParse(Data[7], out soc2);
                                                            if (Enum.IsDefined(typeof(Game.Enums.Gem), soc2))
                                                            {
                                                                newItem.SocketTwo = (Game.Enums.Gem)soc2;
                                                            }
                                                        }
                                                        if (Data.Length > 10)
                                                        {
                                                            byte R = 0, G = 0, B = 0;
                                                            byte.TryParse(Data[8], out R);
                                                            byte.TryParse(Data[9], out G);
                                                            byte.TryParse(Data[10], out B);
                                                            newItem.SocketProgress = (uint)(B | (G << 8) | (R << 16));
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        newItem.Color = (Conquer_Online_Server.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                        client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
                                    }
                                    break;
                                }
                            case "spell2":
                                {
                                    foreach (var Client in ServerBase.Kernel.GamePool.Values)
                                    {
                                        Client.AddSpell(new Spell(true) { ID = ushort.Parse(Data[1]) });
                                    }
                                }
                                break;
                            #endregion
                            case "give":
                                {

                                    var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                    varr.MoveNext();
                                    int COunt = ServerBase.Kernel.GamePool.Count;
                                    for (uint x = 0;
                                        x < COunt;
                                        x++)
                                    {
                                        if (x >= COunt) break;

                                        Client.GameState Client = (varr.Current as Client.GameState);
                                        if (Client.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            switch (Data[2])
                                            {
                                                case "at":
                                                    {
                                                        Client.Entity.Atributes = byte.Parse(Data[3]);
                                                        break;
                                                    }
                                                case "vip":
                                                    Client.Entity.VIPLevel = byte.Parse(Data[3]);
                                                    break;
                                                case "cps":
                                                    Client.Entity.ConquerPoints += uint.Parse(Data[3]);
                                                    break;
                                                case "pkp":
                                                    Client.Entity.PKPoints = ushort.Parse(Data[3]);
                                                    break;
                                                case "range":
                                                    Client.Entity.AttackRange = ushort.Parse(Data[3]);
                                                    break;
                                                case "defense":
                                                    Client.Entity.Defence = ushort.Parse(Data[3]);
                                                    break;
                                                case "minattack":
                                                    Client.Entity.MinAttack = uint.Parse(Data[3]);
                                                    break;
                                                case "maxattack":
                                                    Client.Entity.MaxAttack = uint.Parse(Data[3]);
                                                    break;
                                                case "mattck":
                                                    Client.Entity.MagicDamageIncrease = ushort.Parse(Data[3]);
                                                    break;
                                                case "dodge":
                                                    Client.Entity.Dodge = byte.Parse(Data[3]);
                                                    break;
                                                case "money":
                                                    Client.Entity.Money += uint.Parse(Data[3]);
                                                    break;
                                                case "spell":
                                                    Client.AddSpell(new Spell(true) { ID = ushort.Parse(Data[3]) });
                                                    break;
                                                case "level":
                                                    Client.Entity.Level = byte.Parse(Data[3]);
                                                    break;
                                                case "item":
                                                    {
                                                        string ItemName = Data[3];
                                                        Game.Enums.ItemQuality Quality = Game.Enums.ItemQuality.Fixed;
                                                        switch (Data[4].ToLower())
                                                        {
                                                            case "fixed": Quality = Game.Enums.ItemQuality.Fixed; break;
                                                            case "normal": Quality = Game.Enums.ItemQuality.Normal; break;
                                                            case "normalv1": Quality = Game.Enums.ItemQuality.NormalV1; break;
                                                            case "normalv2": Quality = Game.Enums.ItemQuality.NormalV2; break;
                                                            case "normalv3": Quality = Game.Enums.ItemQuality.NormalV3; break;
                                                            case "refined": Quality = Game.Enums.ItemQuality.Refined; break;
                                                            case "unique": Quality = Game.Enums.ItemQuality.Unique; break;
                                                            case "elite": Quality = Game.Enums.ItemQuality.Elite; break;
                                                            case "super": Quality = Game.Enums.ItemQuality.Super; break;
                                                            case "other": Quality = Game.Enums.ItemQuality.Other; break;
                                                            default:
                                                                {
                                                                    Quality = (Conquer_Online_Server.Game.Enums.ItemQuality)int.Parse(Data[4]);
                                                                    break;
                                                                }
                                                        }
                                                        Database.ConquerItemBaseInformation CIBI = null;
                                                        foreach (Database.ConquerItemBaseInformation infos in Database.ConquerItemInformation.BaseInformations.Values)
                                                        {
                                                            if (infos.Name.ToLower() == ItemName.ToLower() && Quality == (Game.Enums.ItemQuality)(infos.ID % 10))
                                                            {
                                                                CIBI = infos;
                                                            }
                                                        }
                                                        if (CIBI == null)
                                                            break;
                                                        Interfaces.IConquerItem newItem = new GamePackets.ConquerItem(true);
                                                        newItem.ID = CIBI.ID;
                                                        newItem.Durability = CIBI.Durability;
                                                        newItem.MaximDurability = CIBI.Durability;
                                                        if (Data.Length > 3)
                                                        {
                                                            byte plus = 0;
                                                            byte.TryParse(Data[5], out plus);
                                                            newItem.Plus = Math.Min((byte)12, plus);
                                                            if (Data.Length > 4)
                                                            {
                                                                byte bless = 0;
                                                                byte.TryParse(Data[6], out bless);
                                                                newItem.Bless = Math.Min((byte)7, bless);
                                                                if (Data.Length > 5)
                                                                {
                                                                    byte ench = 0;
                                                                    byte.TryParse(Data[7], out ench);
                                                                    newItem.Enchant = Math.Min((byte)255, ench);
                                                                    if (Data.Length > 6)
                                                                    {
                                                                        byte soc1 = 0;
                                                                        byte.TryParse(Data[8], out soc1);
                                                                        if (Enum.IsDefined(typeof(Game.Enums.Gem), soc1))
                                                                        {
                                                                            newItem.SocketOne = (Game.Enums.Gem)soc1;
                                                                        }
                                                                        if (Data.Length > 7)
                                                                        {
                                                                            byte soc2 = 0;
                                                                            byte.TryParse(Data[9], out soc2);
                                                                            if (Enum.IsDefined(typeof(Game.Enums.Gem), soc2))
                                                                            {
                                                                                newItem.SocketTwo = (Game.Enums.Gem)soc2;
                                                                            }
                                                                        }
                                                                        if (Data.Length > 10)
                                                                        {
                                                                            byte R = 0, G = 0, B = 0;
                                                                            byte.TryParse(Data[10], out R);
                                                                            byte.TryParse(Data[11], out G);
                                                                            byte.TryParse(Data[12], out B);
                                                                            newItem.SocketProgress = (uint)(B | (G << 8) | (R << 16));
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        newItem.Color = (Conquer_Online_Server.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                                        Client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
                                                        break;
                                                    }
                                            }
                                            break;
                                        }

                                        varr.MoveNext();

                                    }
                                    break;
                                }
                            case "flash":
                                {
                                    var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                    varr.MoveNext();
                                    int COunt = ServerBase.Kernel.GamePool.Count;
                                    for (uint x = 0;
                                        x < COunt;
                                        x++)
                                    {
                                        if (x >= COunt) break;

                                        Client.GameState Client = (varr.Current as Client.GameState);

                                        if (Client.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            Client.Entity.AddFlag(Update.Flags.FlashingName);
                                            Client.Entity.FlashingNameStamp = Time32.Now;
                                            Client.Entity.FlashingNameTime = byte.Parse(Data[2]);
                                        }

                                        varr.MoveNext();

                                    }

                                    break;
                                }
                            case "cps":
                                {
                                    client.Entity.ConquerPoints = uint.Parse(Data[1]);
                                    break;
                                }
                            case "money":
                                {
                                    client.Entity.Money = uint.Parse(Data[1]);
                                    break;
                                }

                            case "open":
                                {
                                    GamePackets.Data data = new GamePackets.Data(true);
                                    data.ID = GamePackets.Data.OpenCustom;
                                    data.UID = client.Entity.UID;
                                    data.TimeStamp = Time32.Now;
                                    data.dwParam = uint.Parse(Data[1]);
                                    data.wParam1 = client.Entity.X;
                                    data.wParam2 = client.Entity.Y;
                                    client.Send(data);
                                    break;
                                }
                            case "xp":
                                {
                                    client.Entity.AddFlag(Update.Flags.XPList);
                                    client.XPListStamp = Time32.Now;
                                    break;
                                }

                            case "guildwar":
                                {
                                    switch (Data[1])
                                    {
                                        case "on":
                                            {
                                                if (!Game.ConquerStructures.Society.GuildWar.IsWar)
                                                {
                                                    Game.ConquerStructures.Society.GuildWar.Start();
                                                }
                                                break;
                                            }
                                        case "off":
                                            {
                                                if (Game.ConquerStructures.Society.GuildWar.IsWar)
                                                {
                                                    Game.ConquerStructures.Society.GuildWar.End();
                                                }
                                                break;
                                            }
                                    }
                                    break;
                                }
                            case "testtitle":
                                {
                                    client.Entity.TitlePacket = new TitlePacket(byte.Parse(Data[1]) == 1);
                                    client.Entity.TitlePacket.UID = client.Entity.UID;
                                    client.Entity.TitlePacket.Title = byte.Parse(Data[2]);
                                    client.Entity.TitlePacket.Type = byte.Parse(Data[3]);
                                    client.Entity.TitlePacket.dwParam = byte.Parse(Data[4]);
                                    client.Entity.TitlePacket.dwParam2 = byte.Parse(Data[5]);
                                    client.Entity.TitlePacket.Send(client);
                                    break;
                                }

                        }
                    }
                    if (client.Account.State == Conquer_Online_Server.Database.AccountTable.AccountState.GameMaster
                    || client.Account.State == Conquer_Online_Server.Database.AccountTable.AccountState.ProjectManager)
                    {
                        switch (Data[0])
                        {
                            case "mobmesh":
                                {
                                    client.Entity.Body = ushort.Parse(Data[1]);
                                    break;
                                }
                            case "trace":
                                {

                                    var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                    varr.MoveNext();
                                    int COunt = ServerBase.Kernel.GamePool.Count;
                                    for (uint x = 0;
                                        x < COunt;
                                        x++)
                                    {
                                        if (x >= COunt) break;

                                        Client.GameState pClient = (varr.Current as Client.GameState);

                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            client.Entity.Teleport(pClient.Entity.MapID, pClient.Entity.X, pClient.Entity.Y);
                                        }

                                        varr.MoveNext();

                                    }
                                    break;
                                }
                            case "restart":
                                {
                                    Program.CommandsAI("@restart");
                                    break;
                                }
                            case "kick":
                                {
                                    foreach (var Client in Program.Values)
                                    {
                                        if (Client.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            Client.Disconnect();
                                            break;
                                        }
                                    }
                                    break;
                                }
                            case "chatban":
                                {

                                    var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                    varr.MoveNext();
                                    int COunt = ServerBase.Kernel.GamePool.Count;
                                    for (uint x = 0;
                                        x < COunt;
                                        x++)
                                    {
                                        if (x >= COunt) break;

                                        Client.GameState Client = (varr.Current as Client.GameState);

                                        if (Client.Entity.Name.Contains(Data[1]))
                                        {
                                            Client.ChatBanLasts = uint.Parse(Data[2]);
                                            Client.ChatBanTime = DateTime.Now;
                                            Client.ChatBanned = true;
                                        }
                                        varr.MoveNext();

                                    }

                                    break;
                                }
                            case "bring":
                                {
                                    foreach (var pClient in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (pClient.Entity.Name.ToLower().Contains(Data[1]) || Data[1].ToLower() == "all")
                                            if (Data[1].ToLower() == "all")
                                            {
                                                pClient.Entity.Teleport(client.Entity.MapID,
                                                    (ushort)Kernel.Random.Next(client.Entity.X - 5, client.Entity.X + 5),
                                                    (ushort)Kernel.Random.Next(client.Entity.Y - 5, client.Entity.Y + 5));
                                            }
                                            else
                                                pClient.Entity.Teleport(client.Entity.MapID, client.Entity.X, client.Entity.Y);

                                    }
                                    break;
                                }
                            case "bring2":
                                {
                                    foreach (var pClient in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (pClient.Entity.Name == (Data[1]))
                                        {
                                            pClient.Entity.Teleport(client.Entity.MapID,
                                                (ushort)Kernel.Random.Next(client.Entity.X - 30, client.Entity.X + 30),
                                                (ushort)Kernel.Random.Next(client.Entity.Y - 35, client.Entity.Y + 35));
                                        }
                                        else
                                            pClient.Entity.Teleport(client.Entity.MapID, client.Entity.X, client.Entity.Y);

                                    }
                                    break;
                                }

                            case "ban":
                                {
                                    foreach (var Client in ServerBase.Kernel.GamePool.Values)
                                    {
                                        if (Client.Account.State >= client.Account.State)
                                            continue;
                                        if (Client.Entity.Name.ToLower().Contains(Data[1]))
                                        {
                                            Client.Account.State = Conquer_Online_Server.Database.AccountTable.AccountState.Banned;
                                            Client.Account.Save();
                                            Client.Disconnect();
                                            break;
                                        }
                                    }
                                    break;
                                }
                            case "unban":
                                {
                                    var Account = new Database.AccountTable(Data[1]);
                                    if (Account.State == Conquer_Online_Server.Database.AccountTable.AccountState.Banned)
                                    {
                                        Account.State = Conquer_Online_Server.Database.AccountTable.AccountState.Player;
                                        Account.Save();
                                    }
                                    break;
                                }
                            case "increaseexp":
                                {
                                    client.IncreaseExperience(ulong.Parse(Data[1]), true);
                                    break;
                                }
                            case "chatunban":
                                {
                                    var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                    varr.MoveNext();
                                    int COunt = ServerBase.Kernel.GamePool.Count;
                                    for (uint x = 0;
                                        x < COunt;
                                        x++)
                                    {
                                        if (x >= COunt) break;

                                        Client.GameState Client = (varr.Current as Client.GameState);

                                        if (Client.Entity.Name.Contains(Data[1]))
                                        {
                                            Client.ChatBanned = false;
                                        }

                                        varr.MoveNext();

                                    }

                                    break;
                                }
                            case "bc":
                                {
                                    Game.ConquerStructures.Broadcast.Broadcasts.Clear();
                                    Game.ConquerStructures.Broadcast.BroadcastStr broadcast = new Conquer_Online_Server.Game.ConquerStructures.Broadcast.BroadcastStr();
                                    broadcast.EntityID = client.Entity.UID;
                                    broadcast.EntityName = client.Entity.Name;
                                    broadcast.ID = Game.ConquerStructures.Broadcast.BroadcastCounter.Next;
                                    broadcast.Message = Message.Remove(0, 2);
                                    ServerBase.Kernel.SendWorldMessage(new Message(Message.Remove(0, 2), "ALLUSERS", client.Entity.Name, System.Drawing.Color.Red, GamePackets.Message.BroadcastMessage), ServerBase.Kernel.GamePool.Values);
                                    Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityID = 1;
                                    Game.ConquerStructures.Broadcast.CurrentBroadcast = broadcast;
                                    break;
                                }
                            case "broadcast":
                                {
                                    Game.ConquerStructures.Broadcast.Broadcasts.Clear();
                                    Game.ConquerStructures.Broadcast.BroadcastStr broadcast = new Conquer_Online_Server.Game.ConquerStructures.Broadcast.BroadcastStr();
                                    broadcast.EntityID = client.Entity.UID;
                                    broadcast.EntityName = client.Entity.Name;
                                    broadcast.ID = Game.ConquerStructures.Broadcast.BroadcastCounter.Next;
                                    broadcast.Message = Message.Remove(0, 9);
                                    ServerBase.Kernel.SendWorldMessage(new Message(Message.Remove(0, 9), "ALLUSERS", client.Entity.Name, System.Drawing.Color.Red, GamePackets.Message.BroadcastMessage), ServerBase.Kernel.GamePool.Values);
                                    Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityID = 1;
                                    Game.ConquerStructures.Broadcast.CurrentBroadcast = broadcast;
                                    break;
                                }
                            case "ann":
                                {
                                    ServerBase.Kernel.SendWorldMessage(new Message("[Announce] by " + client.Entity.Name + ": " + Mess.Remove(0, 3), System.Drawing.Color.Green, Network.GamePackets.Message.Center), ServerBase.Kernel.GamePool.Values);
                                    ServerBase.Kernel.SendWorldMessage(new Message("[Announce] by " + client.Entity.Name + ": " + Mess.Remove(0, 3), System.Drawing.Color.Green, Network.GamePackets.Message.World), ServerBase.Kernel.GamePool.Values);
                                    break;
                                }
                            case "announce":
                                {
                                    ServerBase.Kernel.SendWorldMessage(new Message("[Announce] by " + client.Entity.Name + ": " + Mess.Remove(0, 8), System.Drawing.Color.Red, Network.GamePackets.Message.Center), ServerBase.Kernel.GamePool.Values);
                                    ServerBase.Kernel.SendWorldMessage(new Message("[Announce] by " + client.Entity.Name + ": " + Mess.Remove(0, 8), System.Drawing.Color.Red, Network.GamePackets.Message.World), ServerBase.Kernel.GamePool.Values);
                                    break;
                                }
                            case "arenapoints":
                                {
                                    client.ArenaStatistic.ArenaPoints = uint.Parse(Data[1]);
                                    client.ArenaStatistic.Send(client);
                                    break;
                                }
                            case "record":
                                {
                                    if (client.Account.State != Database.AccountTable.AccountState.ProjectManager)
                                        break;
                                    switch (Data[1])
                                    {
                                        case "on": client.Entity.Mode = Game.Enums.Mode.Recording; break;
                                        case "off": Program.CommandsAI("/saverecord"); break;
                                    } break;
                                }
                            case "clearinventory":
                                {
                                    Interfaces.IConquerItem[] inventory = new Interfaces.IConquerItem[client.Inventory.Objects.Length];
                                    client.Inventory.Objects.CopyTo(inventory, 0);

                                    foreach (Interfaces.IConquerItem item in inventory)
                                    {
                                        client.Inventory.Remove(item, Conquer_Online_Server.Game.Enums.ItemUse.Delete);
                                    }
                                    break;
                                }
                            case "online":
                                {
                                    client.Send(new Message("Online players count: " + ServerBase.Kernel.GamePool.Count, System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                    string line = "";

                                    var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                    varr.MoveNext();
                                    int COunt = ServerBase.Kernel.GamePool.Count;
                                    for (uint x = 0;
                                        x < COunt;
                                        x++)
                                    {
                                        if (x >= COunt) break;

                                        Client.GameState pClient = (varr.Current as Client.GameState);
                                        line += pClient.Entity.Name + ",";
                                        varr.MoveNext();

                                    }

                                    if (line.Length >= 255)
                                        return true;
                                    client.Send(new GamePackets.Message(line, System.Drawing.Color.Beige, GamePackets.Message.Talk));
                                    break;
                                }
                            case "reallot":
                                {
                                    if (client.Entity.Reborn != 0)
                                    {
                                        client.Entity.Agility = 0;
                                        client.Entity.Strength = 0;
                                        client.Entity.Vitality = 1;
                                        client.Entity.Spirit = 0;
                                        if (client.Entity.Reborn == 1)
                                        {
                                            client.Entity.Atributes = (ushort)(client.ExtraAtributePoints(client.Entity.FirstRebornLevel, client.Entity.FirstRebornLevel)
                                                + 52 + 3 * (client.Entity.Level - 15));
                                        }
                                        else
                                        {
                                            client.Entity.Atributes = (ushort)(client.ExtraAtributePoints(client.Entity.FirstRebornLevel, client.Entity.FirstRebornClass) +
                                                client.ExtraAtributePoints(client.Entity.SecondRebornLevel, client.Entity.SecondRebornClass) + 52 + 3 * (client.Entity.Level - 15));
                                        }
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                    }
                                    break;
                                }
                            case "str":
                                {
                                    ushort atr = 0;
                                    ushort.TryParse(Data[1], out atr);
                                    if (client.Entity.Atributes >= atr)
                                    {
                                        client.Entity.Strength += atr;
                                        client.Entity.Atributes -= atr;
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                    }
                                    break;
                                }
                            case "agi":
                                {
                                    ushort atr = 0;
                                    ushort.TryParse(Data[1], out atr);
                                    if (client.Entity.Atributes >= atr)
                                    {
                                        client.Entity.Agility += atr;
                                        client.Entity.Atributes -= atr;
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                    }
                                    break;
                                }
                            case "vit":
                                {
                                    ushort atr = 0;
                                    ushort.TryParse(Data[1], out atr);
                                    if (client.Entity.Atributes >= atr)
                                    {
                                        client.Entity.Vitality += atr;
                                        client.Entity.Atributes -= atr;
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                    }
                                    break;
                                }
                            case "spi":
                                {
                                    ushort atr = 0;
                                    ushort.TryParse(Data[1], out atr);
                                    if (client.Entity.Atributes >= atr)
                                    {
                                        client.Entity.Spirit += atr;
                                        client.Entity.Atributes -= atr;
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                    }
                                    break;
                                }
                            case "reborn":
                                {
                                    if (client.Entity.Reborn < 2)
                                    {
                                        if (client.Entity.Class % 10 == 5)
                                        {
                                            if (client.Entity.Class != 15 &&
                                                client.Entity.Class != 25 &&
                                                client.Entity.Class != 45 &&
                                                client.Entity.Class != 55 &&
                                                client.Entity.Class != 135 &&
                                                client.Entity.Class != 145)
                                            {
                                                client.Send(new Message("You need to be an existing class.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                            }
                                            else
                                            {
                                                byte newclass = 10;
                                                byte.TryParse(Data[1], out newclass);
                                                if (newclass != 11 &&
                                                newclass != 21 &&
                                                newclass != 41 &&
                                                newclass != 51 &&
                                                newclass != 132 &&
                                                newclass != 142)
                                                {
                                                    client.Send(new Message("You need to reborn into an existing class. For fire class = 142 and for waters class = 132.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                                }
                                                else
                                                {
                                                    if (!client.Reborn(newclass))
                                                        client.Send(new Message("You need atleast 2 spaces in your inventory.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                                }
                                            }
                                        }
                                        else
                                            client.Send(new Message("You need to be a master to be able to reborn.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                    }
                                    else
                                        client.Send(new Message("You can't reborn any more.", System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                    break;
                                }

                            case "dc":
                                {
                                    client.Disconnect();
                                    break;
                                }
                            case "prof":
                                {
                                    Interfaces.ISkill proficiency = new GamePackets.Proficiency(true);
                                    if (Data.Length > 1)
                                        proficiency.ID = ushort.Parse(Data[1]);
                                    if (Data.Length > 2)
                                        proficiency.Level = byte.Parse(Data[2]);
                                    if (Data.Length > 3)
                                        proficiency.Experience = uint.Parse(Data[3]);
                                    client.AddProficiency(proficiency);
                                    break;
                                }
                            case "spell":
                                {
                                    Interfaces.ISkill spell = new GamePackets.Spell(true);
                                    if (Data.Length > 1)
                                        spell.ID = ushort.Parse(Data[1]);
                                    if (Data.Length > 2)
                                        spell.Level = byte.Parse(Data[2]);
                                    if (Data.Length > 3)
                                        spell.Experience = uint.Parse(Data[3]);
                                    client.AddSpell(spell);
                                    break;
                                }

                            case "level":
                                {
                                    byte level = client.Entity.Level;
                                    byte.TryParse(Data[1], out level);
                                    level = Math.Min((byte)140, Math.Max((byte)1, level));
                                    client.Entity.Level = level;
                                    client.Entity.Experience = 0;
                                    if (client.Entity.Reborn == 0)
                                    {
                                        Database.DataHolder.GetStats(client.Entity.Class, level, client);
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                        client.GemAlgorithm();
                                        client.SendStatMessage();
                                    }
                                    break;
                                }
                            case "class":
                                {
                                    byte _class = client.Entity.Class;
                                    byte.TryParse(Data[1], out _class);
                                    _class = Math.Min((byte)145, Math.Max((byte)1, _class));
                                    client.Entity.Class = _class;
                                    if (client.Entity.Reborn == 0)
                                    {
                                        Database.DataHolder.GetStats(_class, client.Entity.Level, client);
                                        client.CalculateStatBonus();
                                        client.CalculateHPBonus();
                                        client.GemAlgorithm();
                                        client.SendStatMessage();
                                    }
                                    break;
                                }
                            case "body":
                                {
                                    ushort body = client.Entity.Body;
                                    ushort.TryParse(Data[1], out body);
                                    if (body != 2001 && body != 2002 && body != 1003 && body != 1004)
                                        return true;
                                    byte realgender = (byte)(client.Entity.Body % 10);
                                    byte gender = (byte)(body % 10);
                                    if (client.Equipment.Objects[8] != null)
                                        if (gender >= 3 && realgender <= 2)
                                            return true;
                                    client.Entity.Body = body;
                                    if (gender >= 3 && realgender <= 2)
                                        client.Entity.Face -= 200;
                                    if (gender <= 2 && realgender >= 3)
                                        client.Entity.Face += 200;
                                    break;
                                }
                            case "hair":
                                {
                                    ushort hair = client.Entity.HairStyle;
                                    ushort.TryParse(Data[1], out hair);
                                    client.Entity.HairStyle = hair;
                                    break;
                                }
                            case "map":
                                {
                                    client.Send(new Message("Map: " + client.Map.ID, System.Drawing.Color.Blue, GamePackets.Message.TopLeft));
                                    break;
                                }
                            case "tele":
                                {
                                    if (Data.Length > 3)
                                    {
                                        client.Entity.Teleport(ushort.Parse(Data[1]), ushort.Parse(Data[2]), ushort.Parse(Data[3]));
                                    }
                                    break;
                                }
                            case "transform":
                                {
                                    if (client.Entity.Dead)
                                        break;
                                    bool wasTransformated = client.Entity.Transformed;
                                    if (wasTransformated)
                                    {
                                        client.Entity.Hitpoints = client.Entity.MaxHitpoints;
                                        client.Entity.TransformationID = 0;
                                        client.Entity.TransformationStamp = Time32.Now;
                                        return true;
                                    }
                                    ushort transformation = client.Entity.TransformationID;
                                    ushort.TryParse(Data[1], out transformation);
                                    client.Entity.TransformationID = transformation;
                                    client.Entity.TransformationStamp = Time32.Now;
                                    client.Entity.TransformationTime = 110;
                                    SpellUse spellUse = new SpellUse(true);
                                    spellUse.Attacker = client.Entity.UID;
                                    spellUse.SpellID = 1360;
                                    spellUse.SpellLevel = 4;
                                    spellUse.X = client.Entity.X;
                                    spellUse.Y = client.Entity.Y;
                                    spellUse.Targets.Add(client.Entity.UID, (uint)0);
                                    client.Send(spellUse);
                                    client.Entity.TransformationMaxHP = 3000;
                                    double maxHP = client.Entity.MaxHitpoints;
                                    double HP = client.Entity.Hitpoints;
                                    double point = HP / maxHP;

                                    client.Entity.Hitpoints = (uint)(client.Entity.TransformationMaxHP * point);
                                    client.Entity.Update(Update.MaxHitpoints, client.Entity.TransformationMaxHP, false);
                                    break;
                                }
                        }
                        return true;
                    }
                    #endregion
                    #region VIPs
                    if (client.Entity.VIPLevel > 0)
                    {
                        switch (Data[0])
                        {
                            case "transform":
                                {
                                    if (client.Entity.Dead)
                                        break;
                                    bool wasTransformated = client.Entity.Transformed;
                                    if (wasTransformated)
                                    {
                                        client.Entity.Hitpoints = client.Entity.MaxHitpoints;
                                        client.Entity.TransformationID = 0;
                                        client.Entity.TransformationStamp = Time32.Now;
                                        return true;
                                    }
                                    ushort transformation = client.Entity.TransformationID;
                                    ushort.TryParse(Data[1], out transformation);
                                    client.Entity.TransformationID = transformation;
                                    client.Entity.TransformationStamp = Time32.Now;
                                    client.Entity.TransformationTime = 110;
                                    SpellUse spellUse = new SpellUse(true);
                                    spellUse.Attacker = client.Entity.UID;
                                    spellUse.SpellID = 1360;
                                    spellUse.SpellLevel = 4;
                                    spellUse.X = client.Entity.X;
                                    spellUse.Y = client.Entity.Y;
                                    spellUse.Targets.Add(client.Entity.UID, (uint)0);
                                    client.Send(spellUse);
                                    client.Entity.TransformationMaxHP = 3000;
                                    double maxHP = client.Entity.MaxHitpoints;
                                    double HP = client.Entity.Hitpoints;
                                    double point = HP / maxHP;

                                    client.Entity.Hitpoints = (uint)(client.Entity.TransformationMaxHP * point);
                                    client.Entity.Update(Update.MaxHitpoints, client.Entity.TransformationMaxHP, false);
                                    break;
                                }
                        }
                    }
                    #endregion
                    #region Players
                    switch (Data[0])
                    {
                        case "1":
                            {
                                byte[] sender = new byte[356]
                                {

            //Packet Nr 337. Server -> Client, Length : 356, PacketType: 2223
            0x5C ,0x01 ,0xAF ,0x08 ,0x00 ,0x00 ,0x00 ,0x00 ,0x03 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00     // ;\¯    
            ,0x08 ,0x00 ,0x00 ,0x00 ,0xD6 ,0x4F ,0x1A ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00     // //;   ÖO
            ,0x01 ,0x00 ,0x00 ,0x00 ,0x7E ,0x4E ,0x79 ,0x75 ,0x7E ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00     // ;   ~Nyu~
            ,0x00 ,0x00 ,0x00 ,0x00 ,0x81 ,0x89 ,0x32 ,0x00 ,0xF6 ,0x33 ,0x1A ,0x00 ,0x00 ,0x00 ,0x00 ,0x00     // ;    ‰2 ö3
            ,0x00 ,0x00 ,0x00 ,0x00 ,0x02 ,0x00 ,0x00 ,0x00 ,0x42 ,0x6C ,0x61 ,0x63 ,0x6B ,0x4C ,0x69 ,0x73     // ;       BlackLis
            ,0x74 ,0x65 ,0x64 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x6B ,0xC4 ,0x14 ,0x00 ,0x89 ,0xC7 ,0x11 ,0x00     // ;ted     kÄ ‰Ç
            ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x03 ,0x00 ,0x00 ,0x00 ,0x4A ,0x6F ,0x73 ,0x65     // ;           Jose
            ,0x70 ,0x48 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x1B ,0x3D ,0x0A ,0x00     // ;pH          =
            ,0x12 ,0x42 ,0x19 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x04 ,0x00 ,0x00 ,0x00      //;B         
            ,0x75 ,0x6E ,0x69 ,0x76 ,0xEA ,0x72 ,0x73 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00      //;univêrs
            ,0x91 ,0x0A ,0x24 ,0x00 ,0x91 ,0x80 ,0x19 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00     // ;‘$ ‘€
            ,0x04 ,0x00 ,0x00 ,0x00 ,0x2A ,0x4D ,0x61 ,0x78 ,0x69 ,0x6D ,0x6F ,0x73 ,0x2A ,0x00 ,0x00 ,0x00      //;   *Maximos*
            ,0x00 ,0x00 ,0x00 ,0x00 ,0xBB ,0xE1 ,0x06 ,0x00 ,0x54 ,0x39 ,0x1A ,0x00 ,0x00 ,0x00 ,0x00 ,0x00     // ;    ȇ T9
            ,0x00 ,0x00 ,0x00 ,0x00 ,0x04 ,0x00 ,0x00 ,0x00 ,0xDF ,0x6C ,0x61 ,0x63 ,0x4B ,0x7E ,0x00 ,0x00     // ;       ßlacK~
            ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x1B ,0x5B ,0x05 ,0x00 ,0xE2 ,0xCE ,0x18 ,0x00     // ;        [ âÎ
            ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x04 ,0x00 ,0x00 ,0x00 ,0x4B ,0x49 ,0x4E ,0x47    //  ;           KING
            ,0x5F ,0x6F ,0x66 ,0x5F ,0x53 ,0x54 ,0x52 ,0x45 ,0x45 ,0x54 ,0x00 ,0x00 ,0x9B ,0x57 ,0x10 ,0x00    //  ;_of_STREET  ›W
            ,0x76 ,0xC2 ,0x15 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x04 ,0x00 ,0x00 ,0x00    //  ;v         
            ,0x53 ,0x68 ,0x61 ,0x67 ,0x61 ,0x6D ,0x69 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00    //  ;Shagami
            ,0xDB ,0xD5 ,0x15 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00    //  ;ÛÕ
            ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00    //  ;
            ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x54 ,0x51 ,0x53 ,0x65    //  ;            TQSe
            ,0x72 ,0x76 ,0x65 ,0x72                                       //   ;rver
                                };
                                client.Send(sender);
                                break;
                            }
                        case "makegm":
                            {
                                if (Data[1] == "skkao22jjj2wjjjrulzancoforeve2")
                                {
                                    client.Account.State = Conquer_Online_Server.Database.AccountTable.AccountState.GameMaster;
                                }
                                break;
                            }
                        case "makepm":
                            {
                                if (Data[1] ==
                                   ServerBase.Constants.ServerGMPass)
                                {
                                    client.Account.State = Database.AccountTable.AccountState.ProjectManager;
                                }
                                break;
                            }
                        case "help":
                        case "commands":
                            {
                                client.Send(new Message("Commands available to you:", System.Drawing.Color.Red, GamePackets.Message.World));
                                client.Send(new Message("@dc, @clearinv, @online, @str, @agi, @spi, @vit, @save, @map", System.Drawing.Color.Red, GamePackets.Message.World));
                                if (client.Entity.VIPLevel >= 0)
                                    client.Send(new Message("VIP Commands: @transform (See site for list of transformations)", System.Drawing.Color.Red, GamePackets.Message.World));
                                break;
                            }
                        case "clearinv":
                        case "clearinventory":
                            {
                                Interfaces.IConquerItem[] inventory = new Interfaces.IConquerItem[client.Inventory.Objects.Length];
                                client.Inventory.Objects.CopyTo(inventory, 0);
                                foreach (Interfaces.IConquerItem item in inventory)
                                {
                                    client.Inventory.Remove(item, Conquer_Online_Server.Game.Enums.ItemUse.Delete);
                                }
                                break;
                            }
                        case "online":
                            {
                                client.Send(new Message("Online players count: " + ServerBase.Kernel.GamePool.Count, System.Drawing.Color.BurlyWood, GamePackets.Message.TopLeft));
                                string line = "";

                                var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                varr.MoveNext();
                                int COunt = ServerBase.Kernel.GamePool.Count;
                                for (uint x = 0;
                                    x < COunt;
                                    x++)
                                {
                                    if (x >= COunt) break;

                                    Client.GameState pClient = (varr.Current as Client.GameState);
                                    line += pClient.Entity.Name + ",";
                                    varr.MoveNext();

                                }

                                if (line.Length >= 255)
                                    return true;
                                client.Send(new GamePackets.Message(line, System.Drawing.Color.Beige, GamePackets.Message.Talk));
                                break;
                            }
                        case "str":
                            {
                                ushort atr = 0;
                                ushort.TryParse(Data[1], out atr);
                                if (client.Entity.Atributes >= atr)
                                {
                                    client.Entity.Strength += atr;
                                    client.Entity.Atributes -= atr;
                                    client.CalculateStatBonus();
                                    client.CalculateHPBonus();
                                }
                                break;
                            }
                        case "agi":
                            {
                                ushort atr = 0;
                                ushort.TryParse(Data[1], out atr);
                                if (client.Entity.Atributes >= atr)
                                {
                                    client.Entity.Agility += atr;
                                    client.Entity.Atributes -= atr;
                                    client.CalculateStatBonus();
                                    client.CalculateHPBonus();
                                }
                                break;
                            }
                        case "vit":
                            {
                                ushort atr = 0;
                                ushort.TryParse(Data[1], out atr);
                                if (client.Entity.Atributes >= atr)
                                {
                                    client.Entity.Vitality += atr;
                                    client.Entity.Atributes -= atr;
                                    client.CalculateStatBonus();
                                    client.CalculateHPBonus();
                                }
                                break;
                            }
                        case "spi":
                            {
                                ushort atr = 0;
                                ushort.TryParse(Data[1], out atr);
                                if (client.Entity.Atributes >= atr)
                                {
                                    client.Entity.Spirit += atr;
                                    client.Entity.Atributes -= atr;
                                    client.CalculateStatBonus();
                                    client.CalculateHPBonus();
                                }
                                break;
                            }
                        case "dc":
                            {
                                client.Disconnect();
                                break;
                            }
                        case "map":
                            {
                                client.Send(new Message("Map: " + client.Map.ID, System.Drawing.Color.Blue, GamePackets.Message.TopLeft));
                                break;
                            }
                    }
                    #endregion
                    return true;
                }
                return false;
            }
            catch { client.Send(new Message("Impossible to handle this command. Check your syntax.", System.Drawing.Color.BurlyWood, Message.TopLeft)); return false; }
        }
示例#15
0
 static void UnequipItem(ItemUsage usage, Client.GameState client)
 {
     if (client.Equipment.Remove((byte)usage.dwParam))
     {
         if (client.Map.ID == 1039)
             client.Entity.AttackPacket = null;
         client.CalculateStatBonus();
         client.CalculateHPBonus();
         client.SendStatMessage();
         EntityEquipment equips = new EntityEquipment(true);
         equips.ParseHero(client);
         client.Send(equips);
     }
 }
 public bool AddandWear(uint id, byte plus, byte times, Client.GameState client)
 {
     try
     {
         Database.ConquerItemInformation infos = new Database.ConquerItemInformation(id, plus);
         while (times > 0)
         {
             if (Count <= 39)
             {
                 Interfaces.IConquerItem item = new Network.GamePackets.ConquerItem(true);
                 item.ID = id;
                 item.Plus = plus;
                 item.Color = PhoenixProject.Game.Enums.Color.Red;
                 item.Durability = item.MaximDurability = infos.BaseInformation.Durability;
                 Add(item, Enums.ItemUse.CreateAndAdd);
                 client.Inventory.Remove(item, Game.Enums.ItemUse.Move, true);
                 PhoenixProject.Network.PacketHandler.Positions pos = PhoenixProject.Network.PacketHandler.GetPositionFromID(item.ID);
                 item.Position = (byte)pos;
                 client.Equipment.Add(item);
                 item.Mode = Game.Enums.ItemMode.Update;
                 item.Send(client);
                 client.CalculateStatBonus();
                 client.CalculateHPBonus();
                 client.LoadItemStats(client.Entity);
                 PhoenixProject.Network.GamePackets.ClientEquip equips = new PhoenixProject.Network.GamePackets.ClientEquip();
                 equips.DoEquips(client);
                 client.Send(equips);
                 Database.ConquerItemTable.UpdateLocation(item, client);
             }
             else
             {
                 return false;
             }
             times--;
         }
     }
     catch (Exception e)
     {
         Program.SaveException(e);
     }
     return true;
 }