private static void TaskTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (Tasks.Count >= 1)
     {
         var _task = Tasks[currentID];
         if (RemoveTask(currentID))
         {
             var nextTask = Tasks.Values.ToArray()[0];
             currentID = nextTask.id;
             ChangeTask(nextTask.type);
             if (_task.type == "bm" && Tasks.Count > 0)
             {
                 BotSettings.leaveBM    = true;
                 BotSettings.autoJoinBM = false;
             }
             if (_task.type == "raid" && Tasks.Count > 0)
             {
                 BotSettings.leaveBM      = true;
                 BotSettings.autoJoinRaid = false;
             }
             BotMethods.WriteLine("Finished Task. Starting " + Tasks[currentID].type + " Task.");
             Thread.Sleep(100);
         }
     }
     else
     {
         StopTaskSystem();
         if (BotSettings.tasksDoneLogout)
         {
             BotMethods.WriteLine("Finished all Tasks. Logging out.");
             BotLogic.StopBotThread();
             var point = Bot.MoveToCorner();
             BotMethods.MoveTo(point.X, point.Y);
             var counter = 60;
             Thread.Sleep(555);
             while (Account.Route.Count >= 3 && !Account.IsSunk && counter > 0)
             {
                 if (point.X == Account.Position.X && point.Y == Account.Position.Y)
                 {
                     break;
                 }
                 Thread.Sleep(1000);
                 counter--;
             }
             Thread.Sleep(new Random().Next(175, 385));
             BotMethods.Logout(0);
             LogginOut = true;
             while (Server.Connected)
             {
                 Thread.Sleep(100);
             }
             BotCalculator.StopThreads();
             BotMethods.WriteLine("Succesfully logged out.");
             return;
         }
         BotMethods.WriteLine("Finished all Tasks. Returning to default Settings.");
     }
 }
Beispiel #2
0
 private static void ConnectionThread()
 {
     try
     {
         DateTime dateTime_ = DateTime.Now;
         while (true)
         {
             TimeSpan ts = (DateTime.Now - Client.lastPacket);
             if (!Server.IsConnected() || ts.TotalSeconds > 70.0)
             {
                 BotSession.Sessionreconnects++;
                 break;
             }
             TimeSpan ts2 = (DateTime.Now - dateTime_);
             if (ts2.TotalMinutes >= 1.0)
             {
                 GC.Collect();
                 GC.WaitForPendingFinalizers();
                 HelpTools.ClearMemory(HelpTools.GetCurrentProcess());
                 dateTime_ = DateTime.Now;
             }
             TimeSpan ts3 = (DateTime.Now - BotSession.dailyQuestFinishTime);
             if (ts3.TotalHours >= 24 && ts3.TotalMinutes >= 1 && ts3.TotalSeconds >= 1 && !BotSession.Sessioncandodailyquest)
             {
                 BotSession.Sessioncandodailyquest = true;
             }
             Thread.Sleep(1000);
         }
         Thread.Sleep(2000);
         Bot.Running = false;
         if (Server._targetSocket != null && Server._targetSocket.Connected)
         {
             Server._targetSocket.Close();
         }
         if (Bot.Running)
         {
             BotLogic.StopBotThread();
         }
         if (BotLogic.OnAttackRunning)
         {
             BotLogic.StoponAttackThrad();
         }
         Server.Connected = false;
         if (BotSettings.tasksDoneLogout && TaskSystem.TasksSystem.LogginOut)
         {
             return;
         }
         BotSession.lostConnection = true;
     }
     catch (Exception ex)
     {
         BotMethods.WriteLine("There was an error in the connection-Thread!\n\n" + ex.Message);
         ConnectionThread();
         return;
     }
 }
        public void LicenseThread()
        {
            var _restartCounter = 0;

IL_BEGIN:
            try
            {
                while (true)
                {
                    try
                    {
                        this.Authenticate();
                        var versionflag = CheckVersion();
                        if (!versionflag)
                        {
                            if (!Bot.Running && !BotLogic.OnAttackRunning && !BotSession.logginIn && !BotSession.loggedIn)
                            {
                                if (MessageBox.Show("A new version is available!\nDo you wish to visit the download-area now?", "New Version!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                                {
                                    Process.Start("https://www.elitepvpers.com/forum/seafight/4222822-release-boxybot.html");
                                }
                            }
                            BotMethods.WriteLine("A newer Version is available!");
                        }
                        if (status == "-4")
                        {
                            BotMethods.WriteLine("License Suspended!");
                            MessageBox.Show("Your License has been suspended!", "License suspended!");
                            Account.gClass = null;
                        }
                        else if (status == "-3")
                        {
                            BotMethods.WriteLine(string.Join("", new string[]
                            {
                                HelpTools.FromByteToString(32),
                                HelpTools.FromByteToString(45),
                                HelpTools.FromByteToString(32),
                                HelpTools.FromByteToString(76),
                                HelpTools.FromByteToString(105),
                                HelpTools.FromByteToString(99),
                                HelpTools.FromByteToString(101),
                                HelpTools.FromByteToString(110),
                                HelpTools.FromByteToString(115),
                                HelpTools.FromByteToString(01),
                                HelpTools.FromByteToString(32),
                                HelpTools.FromByteToString(69),
                                HelpTools.FromByteToString(120),
                                HelpTools.FromByteToString(112),
                                HelpTools.FromByteToString(105),
                                HelpTools.FromByteToString(114),
                                HelpTools.FromByteToString(101),
                                HelpTools.FromByteToString(100),
                                HelpTools.FromByteToString(33),
                            }));
                            try
                            {
                                if (Bot.Running)
                                {
                                    BotLogic.StopBotThread();
                                }
                                if (BotLogic.OnAttackRunning)
                                {
                                    BotLogic.StoponAttackThrad();
                                }
                            }
                            catch (Exception ex)
                            {
                                BotMethods.WriteLine("Could not shutdown Bot-Threads!\n" + ex);
                            }
                            Bot.Running = false;
                            BotLogic.OnAttackRunning = false;
                            Account.gClass           = null;
                            if (MessageBox.Show("Your License has expired!\nDo you want to buy a new one?", "License Expired!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                            {
                                Form1.form1.ShowPaymentForm();
                            }
                            Account.gClass = null;
                        }
                        else if (status == "-1")
                        {
                            BotMethods.WriteLine("There was an internal Server Error!\nPlease check your internet connection!\nRetrying in 3min!");
                            Account.gClass = null;
                        }
                        else if (status == "1")
                        {
                            if (Account.gClass == null)
                            {
                                Account.gClass = new UserInitMessage();
                            }
                        }
                        var ts = (validUntil - DateTime.Now);
                        if (ts.TotalHours < 25.0)
                        {
                            if (HelpTools.IsVirtualMachine())
                            {
                                try
                                {
                                    BotCalculator.StopThreads();
                                    if (Bot.Running)
                                    {
                                        BotLogic.StopBotThread();
                                    }
                                    if (BotLogic.OnAttackRunning)
                                    {
                                        BotLogic.StoponAttackThrad();
                                    }
                                }
                                catch (Exception)
                                {
                                }
                                Bot.Running = false;
                                BotLogic.OnAttackRunning = false;
                                Account.gClass           = null;
                                if (MessageBox.Show("This program does not work on a Virtual Machine unless you own a Premium License!", "VM Detected!", MessageBoxButtons.OK, MessageBoxIcon.Error) != DialogResult.None)
                                {
                                    Application.Exit();
                                    Process.GetCurrentProcess().Kill();
                                }
                            }
                        }
                        Thread.Sleep(180000);
                    }
                    catch (Exception ex)
                    {
                        BotMethods.WriteLine("There was an error while checking License!\nRetrying in a few seconds!\n" + ex.Message);
                        Thread.Sleep(50000);
                    }
                }
            } catch (Exception ex)
            {
                BotMethods.WriteLine("Restarting License-Thread, reason: " + ex.Message);
                _restartCounter++;
                if (_restartCounter > 14)
                {
                    MessageBox.Show("There seems to be an error with the License-Thread!\nReason: " + ex + "\nPlease report this!\nThe Bot will now stop!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                    Process.GetCurrentProcess().Kill();
                }
                goto IL_BEGIN;
            }
        }