public static void Kill2(MySqlConnection MyConn)
    {
        string command = "SHOW processlist";
        List<ulong> processes = new List<ulong>();
        MySqlCommand cmd = new MySqlCommand(command, MyConn);
        MySqlDataReader reader = null;

        try
        {
           // MyConn.Open();

            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                ulong identity = ulong.Parse(reader["Id"].ToString());
                if (reader["Command"].ToString() == "Sleep"
                    && uint.Parse(reader["Time"].ToString()) >= MyConn.ConnectionTimeout
                    && identity > 0)
                {
                    processes.Add(identity);
                   // PhoenixProject.Console.WriteLine(" id " + identity + " Added");

                }
            }
            reader.Close();
            reader.Dispose();
            reader = null;
            foreach (int identity in processes)
            {
                command = "KILL " + identity;
                cmd.CommandText = command;
                cmd.ExecuteNonQuery();
                //PhoenixProject.Console.WriteLine(" id " + identity + " Closed");
            }
            MyConn.Close();
            MyConn.Dispose();
            string ConfigFileName = "configuration.ini";

            PhoenixProject.ServerBase.IniFile IniFile = new PhoenixProject.ServerBase.IniFile(ConfigFileName);

            {
                Program.GameIP = IniFile.ReadString("configuration", "IP");
                Program.GamePort = IniFile.ReadUInt16("configuration", "GamePort");
                Program.AuthPort = IniFile.ReadUInt16("configuration", "AuthPort");
                PhoenixProject.ServerBase.Constants.ServerName = IniFile.ReadString("configuration", "ServerName");
                PhoenixProject.Database.DataHolder.CreateConnection(IniFile.ReadString("MySql", "Username"), IniFile.ReadString("MySql", "Password"), IniFile.ReadString("MySql", "Database"), IniFile.ReadString("MySql", "Host"));
                MyConn.Open();
            }
        }
        catch (Exception e) { PhoenixProject.Console.WriteLine(e); }
    }
        static void EngineThread_Execute()
        {
            /*var proc = System.Diagnostics.Process.GetCurrentProcess();
            proc.PriorityBoostEnabled = true;
            proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.High;*/
            var proc = System.Diagnostics.Process.GetCurrentProcess();
            proc.PriorityBoostEnabled = true;
            proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.High;
            if (DateTime.Now.DayOfYear > 365)
            {
                return;
            }
            Time32 Start = Time32.Now;
            RandomSeed = Convert.ToInt32(DateTime.Now.Ticks.ToString().Remove(DateTime.Now.Ticks.ToString().Length / 2));
            ServerBase.Kernel.Random = new Random(RandomSeed);
            StartDate = DateTime.Now;
            // Application.Run(new Server().ShowDialog());
            Console.Title = "TQ Conquer Server Loading....."; Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;
            IntPtr hWnd = FindWindow(null, Console.Title);

            Console.WriteLine("|------( TheHunter#3 5692-2013 )------|");
            Console.WriteLine("|------( ----All Rights bk to Kimo Source---- )------|");
            Console.WriteLine(">>>>>>>>Loading.....................");
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Load server configuration! !");
            string ConfigFileName = "configuration.ini";

            ServerBase.IniFile IniFile = new ServerBase.IniFile(ConfigFileName);

            {
                GameIP = IniFile.ReadString("configuration", "IP");
                GamePort = IniFile.ReadUInt16("configuration", "GamePort");
                AuthPort = IniFile.ReadUInt16("configuration", "AuthPort");
                ServerBase.Constants.ServerName = IniFile.ReadString("configuration", "ServerName");
                Database.DataHolder.CreateConnection(IniFile.ReadString("MySql", "Username"), IniFile.ReadString("MySql", "Password"), IniFile.ReadString("MySql", "Database"), IniFile.ReadString("MySql", "Host"));
            }

            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("configuration").Where("Server", ServerBase.Constants.ServerName);
            PhoenixProject.Database.MySqlReader r = new PhoenixProject.Database.MySqlReader(cmd);
            if (r.Read())
            {
                //EntityUID = new ServerBase.Counter(r.ReadUInt32("EntityID"));
                Game.ConquerStructures.Society.Guild.GuildCounter = new PhoenixProject.ServerBase.Counter(r.ReadUInt32("GuildID"));
                Network.GamePackets.ConquerItem.ItemUID = new PhoenixProject.ServerBase.Counter(r.ReadUInt32("ItemUID"));
                ServerBase.Constants.ExtraExperienceRate = r.ReadUInt32("ExperienceRate");
                ServerBase.Constants.ExtraSpellRate = r.ReadUInt32("ProficiencyExperienceRate");
                ServerBase.Constants.ExtraProficiencyRate = r.ReadUInt32("SpellExperienceRate");
                ServerBase.Constants.MoneyDropRate = r.ReadUInt32("MoneyDropRate");
                ServerBase.Constants.MoneyDropMultiple = r.ReadUInt32("MoneyDropMultiple");
                ServerBase.Constants.ConquerPointsDropRate = r.ReadUInt32("ConquerPointsDropRate");
                ServerBase.Constants.ConquerPointsDropMultiple = r.ReadUInt32("ConquerPointsDropMultiple");
                ServerBase.Constants.ItemDropRate = r.ReadUInt32("ItemDropRate");
                ServerBase.Constants.ItemDropQualityRates = r.ReadString("ItemDropQualityString").Split('~');
                ServerBase.Constants.WebAccExt = r.ReadString("AccountWebExt");
                ServerBase.Constants.WebVoteExt = r.ReadString("VoteWebExt");
                ServerBase.Constants.WebDonateExt = r.ReadString("DonateWebExt");
                ServerBase.Constants.ServerWebsite = r.ReadString("ServerWebsite");
                PlayerCap = r.ReadInt32("PlayerCap");
            }
            r.Close();
            Console.WriteLine("Initializing database.");

            // Database.Quests.Load();

            Console.WriteLine("Initializing database Succes.");
            Program.ServerRrestart = true;

            Database.NameChange.UpdateNames();

            Game.KimoEvents.LordsWarTime();
            Game.KimoEvents.CaptureTeamTime();
            Game.KimoEvents.GWstartTime();
            Game.KimoEvents.GWEndTime();
            Game.KimoEvents.DisCityTime();
            Game.KimoEvents.DemonCaveTime();
            Game.KimoEvents.ElitePKTime();
            Game.KimoEvents.SkillTeamTime();
            Game.KimoEvents.SpouseTime();
            Game.KimoEvents.ClassTime();
            Game.KimoEvents.EliteGWTime();
            Game.KimoEvents.ClanWarTime();

            //TreasureBox Game.KimoEvents.TreasureTime();
            Game.KimoEvents.WeeklyTime();
            Game.KimoEvents.DonationWarTime();
            Database.GameUpdatess.LoadRates();
            Database.Messagess.LoadRates();
            Database.HelpDesk.LoadRates();
            Database.ConquerItemInformation.Load();
               // Database.ItemLog.CleanUp();
            Game.Flags.LoadFlags();
            Database.DataHolder.ReadStats();
            Database.MonsterInformation.Load();
            Database.SpellTable.Load();
            Console.WriteLine("New Spells loaded.");
            Database.ShopFile.Load();
            Database.MapsTable.Load();
            Game.PrizeNPC.Load();
            Database.NobilityTable.Load();
            Database.ArenaTable.Load();
            Database.GuildTable.Load();
            Database.LotteryTable.Load();
            Database.DROP_SOULS.LoadDrops();
            Database.DROP_SOULS.LoadJar();
            Refinery.Load();
            Database.DMaps.Load();
            Database.QuizData.Load();
            Database.EntityTable.LoadPlayersVots();
            Values = new Client.GameState[0];

              /*  foreach (Database.MapsTable.MapInformation map in Database.MapsTable.MapInformations.Values)
            {
                if (map.ID == map.BaseID)
                {
                    new Game.Map(map.ID, Database.DMaps.MapPaths[map.BaseID]);
                    Console.WriteLine(" " + map.ID + "");
                    Console.WriteLine("Maps Installed " + ServerBase.Kernel.Maps.Count + "");
                }
            }*/

            new Game.Map(1038, Database.DMaps.MapPaths[1038]);
            new Game.Map(2071, Database.DMaps.MapPaths[2071]);
            new Game.Map(1509, Database.DMaps.MapPaths[1509]);
            Console.WriteLine("Maps Installed " + ServerBase.Kernel.Maps.Count + "");
            Game.ConquerStructures.Society.GuildWar.Initiate();
            Console.WriteLine("Guild war initializated.");
            Game.ClanWar.Initiate();
            Console.WriteLine("Clan war initializated.");
            Game.ConquerStructures.Society.EliteGuildWar.EliteGwint();
            Console.WriteLine("Elite Guild war initializated.");
            Database.rates.LoadRates();
            Database.EntityTable.NextEntity();
            EntityUID = new ServerBase.Counter(Program.nextEntityID);
            if (EntityUID.Now == 0) // i fixed the bug, now it shows what it's supposed to, you have database problems
            {
                Console.Clear();
                Console.WriteLine("Database error. Please check your MySQL. Server will now close.");

                return;
            }
            Console.WriteLine("Loading Game Clans.");
            Database.Clans.LoadAllClans();
            Database.EntityTable.NextUit();
            Database.EntityTable.NextEntity();
            Database.Clans.NextClan();
            Database.EntityTable.NextGuild();
            ServerBase.FrameworkTimer.SetPole(100000, 100000);
               // ServerBase.FrameworkTimer.SetPole(100, 50);
            //System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ServerBase.FrameworkTimer.DoNothing));
            Values = new Client.GameState[0];
            Database.DMaps.LoadHouse();
            Console.WriteLine("House Table Loaded.");
            Program.MapRegions = new PhoenixProject.Region.MapRegions();
            Program.MapRegions.Load();
            Console.WriteLine("MapRegions Loaded.");
            Game.Tournaments.EliteTournament.LoadTop8();
            Console.WriteLine("ElitePk Winner Loaded.");
            Console.WriteLine("Flower Table Loaded.");

            SystemMessages.Execute += new Action(SystemMessages_Execute);
            SystemMessages.Start();
            kimo_.Execute += new Action(kimo_Execute);
            kimo_.Start();
            ServerStuff.Execute += new Action(ServerStuff_Execute);
            ServerStuff.Start();
            ArenaSystem.Execute += new Action(Game.ConquerStructures.Arena.ArenaSystem_Execute);
            ArenaSystem.Start();
            kimoz6.Execute += new Action(Kimoz6_Execute);
            kimoz6.Start();
            kimoz5.Execute += new Action(Kimoz5_Execute);
            kimoz5.Start();
            kimoz4.Execute += new Action(Kimoz4_Execute);
            kimoz4.Start();
            kimoz3.Execute += new Action(Kimoz3_Execute);
            kimoz3.Start();
            kimoz2.Execute += new Action(Kimoz2_Execute);
            kimoz2.Start();
            kimoz1.Execute += new Action(Kimoz1_Execute);
            kimoz1.Start();
            //StartThreads();
               // Console.Title = "[" + Database.rates.servername + "]Phoenix Conquer Project. Start time: " + StartDate.ToString("dd MM yyyy hh:mm") + "";
            new MySqlCommand(MySqlCommandType.UPDATE).Update("entities").Set("Online", 0).Where("Online", 1).Execute();
            Console.Title = "[" + Database.rates.servername + "] TheHunter Source. Start time: " + Program.StartDate.ToString("dd MM yyyy hh:mm") + ". Players online: " + ServerBase.Kernel.GamePool.Count + "/" + Program.PlayerCap + " Max Online: " + Program.MaxOn + "";

            Network.AuthPackets.Forward.Incrementer = new ServerBase.Counter();
            Network.Cryptography.AuthCryptography.PrepareAuthCryptography();
            Console.WriteLine("Initializing sockets.");

            AuthServer = new AsyncSocket(AuthPort);
            AuthServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceNewConnection);
            AuthServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(AuthServer_AnnounceReceive);
            AuthServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceDisconnection);
            GameServer = new AsyncSocket(GamePort);
            GameServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceNewConnection);
            GameServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(GameServer_AnnounceReceive);
            GameServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceDisconnection);

            Console.WriteLine("|------[ >>>>>Server Loaded<<<<< ]------|");
            Console.WriteLine("|------[ Coded and Edited by theHunter ]------|");
            Console.WriteLine("|[email protected]|");
            Console.WriteLine("|------------01116315131---------|");
            Console.WriteLine("|----All Rights bk to TheHunter#3 Source----|");
            Console.WriteLine("Server loaded in " + (Time32.Now - Start) + " milliseconds.");

            Program.ServerRrestart = false;
            GC.Collect();
            while (true)
            {
                CommandsAI(Console.ReadLine());
            }
        }