static void Main(string[] args)
        {
            EnableCloseButton(false);

            Util.generatePlayerUpdateQueryString();

            LoadSettings();

            if (!File.Exists(Util.ini.IniReadValue("LOG", "path")))
            {
                Console.WriteLine("Couldn't load log file, check settings.ini and start me again!");
                Console.WriteLine("Press enter to exit...");
                Console.ReadLine();
                return;
            }

            db = new Database(
                Util.ini.IniReadValue("DATABASE", "host"),
                Util.ini.IniReadValue("DATABASE", "user"),
                Util.ini.IniReadValue("DATABASE", "database"),
                Util.ini.IniReadValue("DATABASE", "password"),
                players
            );

            if(!db.Connected())
            {
                Console.WriteLine("Could not connect to database, check settings.ini and start me again!");
                Console.WriteLine("Press enter to exit...");
                Console.ReadLine();
                return;
            }

            Console.WriteLine("Connected to database successfully!");

            LoadCachedPlayers();
            Util.ClearCacheStart(10);

            if (RCON.Connect(Util.ini.IniReadValue("RCON", "host"), Convert.ToInt16(Util.ini.IniReadValue("RCON", "port")), Util.ini.IniReadValue("RCON", "password")))
            {
                Util.StartAnnouncements(Convert.ToInt32(Util.ini.IniReadValue("ANNOUNCEMENTS", "delay")));
            }

            Tail tail = new Tail(Util.ini.IniReadValue("LOG", "path"), 1);
            tail.LineFilter = "Rx:";
            tail.Changed += new EventHandler<Tail.TailEventArgs>(NewLine);
            tail.Run();

            Console.CancelKeyPress += (sender, eventArgs) =>
            {
                var hWnd = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
                PostMessage(hWnd, WM_KEYDOWN, VK_RETURN, 0);
            };

            Console.ReadLine();

            ExitProgram(tail);
        }
        static void NewLine(object sender, Tail.TailEventArgs e)
        {
            Match join = Regex.Match(e.Line, "PLAYER:\\s\\\"(.*?)\\\".*?\\sentered\\sfrom\\s(.*?)\\ssteamid\\s(.*?)\\n", RegexOptions.IgnoreCase);
            Match chat = Regex.Match(e.Line, "CHAT:\\s\"(.*?)\".*?say\\s\"(.*?)\"", RegexOptions.IgnoreCase);
            Match quit = Regex.Match(e.Line, "PLAYER:\\s\"(.*?)\".*?disconnected", RegexOptions.IgnoreCase);
            Match kill = Regex.Match(e.Line, "GAME:\\s\"(.*?)\".*?\\skilled\\s\"(.*?)\".*?\\swith\\s\"(.*?)\"", RegexOptions.IgnoreCase);
            Match building = Regex.Match(e.Line, "GAME:\\s\"(.*?)\".*?\\sdestroyed_building\\s\"(.*?)\"\\swith\\s\"(.*?)\"", RegexOptions.IgnoreCase);
            Match destroyed = Regex.Match(e.Line, "GAME:\\s\"(.*?)\".*?\\sdestroyed\\s\"(.*?)\"\\swith\\s\"(.*?)\"",RegexOptions.IgnoreCase);

            if (kill.Success)
                OnPlayerKillPlayer(kill);
            else if (destroyed.Success)
                OnPlayerDestroyVehicle(destroyed);
            else if (building.Success)
                OnPlayerKillBuilding(building);
            else if (chat.Success)
                OnPlayerChat(chat);
            else if (join.Success)
                OnPlayerJoin(join);
            else if (quit.Success)
                OnPlayerQuit(quit);
        }
 private static void ExitProgram(Tail tail)
 {
     Console.WriteLine("Exiting program...");
     db.Close();
     tail.Stop();
     RCON.CloseDown();
 }