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);
            }
        }
 static void LockItem(ItemLock itemLock, Client.GameState client)
 {
     Interfaces.IConquerItem item = null;
     if (client.Inventory.TryGetItem(itemLock.UID, out item))
     {
         itemLock.ID = 1;
         item.Lock = 1;
         item.Mode = Game.Enums.ItemMode.Update;
         client.Send(itemLock);
         item.Send(client);
         Database.ConquerItemTable.UpdateLock(item);
     }
     else if (client.Equipment.TryGetItem(itemLock.UID) != null)
     {
         item = client.Equipment.TryGetItem(itemLock.UID);
         itemLock.ID = 1;
         item.Lock = 1;
         item.Mode = Game.Enums.ItemMode.Update;
         client.Send(itemLock);
         item.Send(client);
         Database.ConquerItemTable.UpdateLock(item);
     }
 }
 static void UnlockItem(ItemLock itemLock, Client.GameState client)
 {
     Interfaces.IConquerItem item = null;
     if (client.Inventory.TryGetItem(itemLock.UID, out item))
     {
         if (item.Lock == 1)
         {
             item.Lock = 2;
             item.UnlockEnd = DateTime.Now.AddDays(5);
             item.Mode = Game.Enums.ItemMode.Update;
             item.Send(client);
             Database.ConquerItemTable.UpdateLock(item);
         }
         else
             client.Send(new Message("Can't unlock an item that is in progress of unlocking.", System.Drawing.Color.FloralWhite, Message.TopLeft));
     }
 }
        public void SendExtras(Client.GameState client)
        {
            if (client == null)
                return;

            if (RefineItem != 0)
            {
                Refinery.RefineryItem rI = RefineStats;
                if (rI != null)
                {
                    client.Send(new Game_ItemSoul()
                    {
                        ID = rI.Identifier,
                        Identifier = UID,
                        Level = rI.Level,
                        Mode = Game_ItemSoul.Types.Refine,
                        Percent = rI.Percent,
                        Type = 1,
                        Time = (UInt32)(RefineryTime.Subtract(DateTime.Now).TotalSeconds)
                    });
                }
            }

            ItemAdding add = new ItemAdding(true);
            if (Purification.Available)
                add.Append(Purification);
            if (ExtraEffect.Available)
                add.Append(ExtraEffect);
            if (Purification.Available || ExtraEffect.Available)
                client.Send(add);

            if (Lock == 2)
            {
                ItemLock itemLock = new ItemLock(true);
                itemLock.UID = UID;
                itemLock.ID = ItemLock.UnlockDate;
                itemLock.dwParam = (uint)(UnlockEnd.Year * 10000 + UnlockEnd.Month * 100 + UnlockEnd.Day);
                client.Send(itemLock);
            }
        }