public void GetMainCommand() { try { string reply = SendMessage(Server.ClientID, "main", Server.LastInfo); switch (reply) { case "Start": if (ClientApi.GetState() != ClientStates.Start) { Server.LoadedAccount = GetAccount(); if (Server.LoadedAccount == null) { Server.SetInfoText("Can't get account data."); } else { ClientApi.Start(); } } break; case "Login": ClientApi.SetState(ClientStates.Login); Logger.Log("Manager said: " + reply); break; case "Stop": ClientApi.Stop(); break; case "shutdown": break; } } catch (Exception x) { Logger.Log("Can't get commands. Details: " + x.Message); } }
private static void GameControlCallback(object state) { try { TimeSpan timeSpan = new TimeSpan(DateTime.Now.Ticks - GameSession.TimerTick); if (timeSpan.TotalSeconds > 260) { LCU = new LCU(); if (GameSession.GetPort() != 0) { try { var bmp = PixelCache.GetScreenshot(); bmp.Bitmap.Save("gs1.bmp"); if (bmp.GetPixel(485, 352) == Color.FromArgb(59, 45, 24)) // afk { Mouse.Move(485, 352); Thread.Sleep(600); Mouse.ButtonDown(Mouse.MouseKeys.Left); Thread.Sleep(50); Mouse.ButtonUp(Mouse.MouseKeys.Left); Thread.Sleep(300); Mouse.Move(490, 352); Thread.Sleep(100); Mouse.ButtonDown(Mouse.MouseKeys.Left); Thread.Sleep(50); Mouse.ButtonUp(Mouse.MouseKeys.Left); Thread.Sleep(1000); } if (bmp.GetPixel(798, 151) == Color.FromArgb(13, 26, 26)) // main menu { Mouse.Move(798, 151); Thread.Sleep(600); Mouse.ButtonDown(Mouse.MouseKeys.Left); Thread.Sleep(50); Mouse.ButtonUp(Mouse.MouseKeys.Left); Thread.Sleep(300); Mouse.Move(744, 596); // cancel button Thread.Sleep(100); Mouse.ButtonDown(Mouse.MouseKeys.Left); Thread.Sleep(50); Mouse.ButtonUp(Mouse.MouseKeys.Left); Thread.Sleep(3000); } if (bmp.GetPixel(495, 352) == Color.FromArgb(59, 45, 24) || bmp.GetPixel(507, 344) == Color.FromArgb(255, 255, 255)) { ListProcesses(); GameSession.TimerTick = DateTime.Now.Ticks; Logger.Log("gamesession (3) restart..." + timeSpan.ToString()); ClientApi.Stop(); Logger.Log("Connection lost. Trying to continue..."); Server.SetInfoText("Connection lost. Trying to continue..."); Thread.Sleep(5000); ClientApi.Restart = true; ClientApi.Start(); } else if (bmp.GetPixel(532, 765) != Color.FromArgb(78, 62, 29)) { ListProcesses(); GameSession.TimerTick = DateTime.Now.Ticks; Logger.Log("gamesession (1) restart..." + timeSpan.ToString()); GameSession.Start = 1; GameSession = null; GameSession = new GameSession(Server, Champions.RandomChamp()); } bmp.Dispose(); } catch (Exception x) { Logger.Log("gamesession (1) image error..." + x.Message); } } else //if(LCU != null && LCU.LeaverBuster() == 0) { bool flag = false; try { var bmp = PixelCache.GetScreenshot(); bmp.Bitmap.Save("kill1.bmp"); if (bmp.GetPixel(425, 362) == Color.FromArgb(205, 190, 145)) { GameSession.TimerTick = DateTime.Now.Ticks; ListProcesses(); flag = true; while (GameSession.GetPort() == 0) { GameSession.Control(); TryToContinue(); LogAndInfo("waiting for reconnect..."); } LogAndInfo("Reconnecting..."); State = ClientStates.InGame; Communication.SendMessageWithoutReply(Server.ClientID, "state", "ingame"); StartGameSession(Champions.RandomChamp()); KillTimers(); } else if (bmp.GetPixel(507, 344) == Color.FromArgb(255, 255, 255) || bmp.GetPixel(525, 125) == Color.FromArgb(17, 17, 17)) { ListProcesses(); GameSession.TimerTick = DateTime.Now.Ticks; Logger.Log("kill (3) restart..." + timeSpan.ToString()); ClientApi.Stop(); Logger.Log("Connection lost. Trying to continue..."); Server.SetInfoText("Connection lost. Trying to continue..."); Thread.Sleep(5000); ClientApi.Restart = true; ClientApi.Start(); } bmp.Dispose(); } catch (Exception x) { Logger.Log("kill (1) image error..." + x.Message); } if (!flag) { //425,362 = 205, 190, 145 GameSession.TimerTick = DateTime.Now.Ticks; Logger.Log("kill1 " + timeSpan.ToString()); Stop(); Logger.Log("Restarting bot..."); Server.SetInfoText("Restarting bot..."); Thread.Sleep(5000); if (Server.LoadedAccount != null) { Start(); } else { Logger.Log("no loaded account"); } } } } else { Logger.Log("check - OK: bot is working... (1)"); } } catch (Exception x) { Logger.Log("check - FAIL: gameControlTimer error: " + x.Message); } finally { TimerChange(gameControl, 60000); } }
private void ServerControlCallback(object state) { try { TimeSpan timeSpan = new TimeSpan(Math.Abs(DateTime.Now.Ticks - GameSession.TimerTick)); if (timeSpan.TotalMinutes > 10) { ClientApi.LCU = new LCU(); if (LCU.SummonerID == 0) { try { var bmp = PixelCache.GetScreenshot(); bmp.Bitmap.Save("kill2.bmp"); bmp.Dispose(); } catch (Exception x) { Logger.Log("kill (2) image error..." + x.Message); } Logger.Log("kill2 " + timeSpan.ToString()); ClientApi.Stop(); SetInfoText("Restarting bot..."); if (LoadedAccount != null) { ClientApi.Start(); } else { Logger.Log("no loaded account"); } } else { try { var bmp = PixelCache.GetScreenshot(); bmp.Bitmap.Save("gs2.bmp"); bmp.Dispose(); } catch (Exception x) { Logger.Log("gamesession (2) image error..." + x.Message); } Logger.Log("gamesession (2) restart..." + timeSpan.ToString()); GameSession.Start = 1; GameSession = new GameSession(this, Game.Champions.RandomChamp()); } } else { Logger.Log("check - OK: bot is working... (2)"); } } catch (Exception x) { Logger.Log("check - FAIL: serverControlTimer error: " + x.Message); } finally { ClientApi.TimerChange(serverControl, 30000); } }