private static void Main(string[] args) { BattlEyeLoginCredentials loginCredentials = new BattlEyeLoginCredentials(); #region loginCredentials.Host = args[0]; loginCredentials.Port = Convert.ToInt32(args[1]); loginCredentials.Password = args[2]; #endregion IBattleNET b = new BattlEyeClient(loginCredentials); b.MessageReceivedEvent += DumpMessage; b.DisconnectEvent += Disconnected; b.ReconnectOnPacketLoss(true); b.Connect(); if (b.IsConnected() == false) { Console.WriteLine("Couldnt connect to server"); Console.WriteLine("Failed to reload bans"); return; } b.SendCommandPacket(EBattlEyeCommand.loadBans); Thread.Sleep(1000); // wait 1 second for no reason... b.Disconnect(); }
public virtual bool ExecuteSingle() { var beClient = new BattlEyeClient(this.Context.Server.LoginCredentials) { ReconnectOnPacketLoss = true, DiscardConsoleMessages = true }; var connect = beClient.Connect(); if (connect != BattlEyeConnectionResult.Success) { beClient.Disconnect(); throw new RConException("ERROR: Could not connect to the server: " + connect); } this.Execute(beClient); beClient.Disconnect(); return true; // ~beClient() }
private static void Main(string[] args) { BattlEyeLoginCredentials loginCredentials = new BattlEyeLoginCredentials(); #region if (args.Length == 3) { loginCredentials.Host = args[0]; loginCredentials.Port = Convert.ToInt32(args[1]); loginCredentials.Password = args[2]; } else { Console.WriteLine("Wrong Number of Args"); Thread.Sleep(5000); Environment.Exit(0); } #endregion BattlEyeClient b = new BattlEyeClient(loginCredentials); b.BattlEyeMessageReceived += BattlEyeMessageReceived; b.BattlEyeConnected += BattlEyeConnected; b.BattlEyeDisconnected += BattlEyeDisconnected; b.ReconnectOnPacketLoss = true; b.Connect(); if (b.Connected) { b.SendCommand(BattlEyeCommand.LoadBans); while (b.CommandQueue > 0) { /* wait until server received packet */ }; Thread.Sleep(1000); // wait 1 second for no reason... } else { Console.WriteLine("Couldnt connect to server"); Console.WriteLine("Failed to reload bans"); Environment.Exit(0); } b.Disconnect(); }
private static void Main(string[] args) { Console.WriteLine( "BattleNET v1.3.3 - BattlEye Library and Client\n\n" + "Copyright (C) 2015 by it's authors.\n" + "Some rights reserved. See license.txt, authors.txt.\n" ); BattlEyeLoginCredentials loginCredentials; string command = ""; Console.OutputEncoding = Encoding.UTF8; if (args.Length > 0) { loginCredentials = GetLoginCredentials(args); for (int i = 0; i < args.Length; i++) { if (args[i] == "-command") { try { command = args[i + 1]; } catch { Console.WriteLine("No command given!"); loginCredentials.Host = null; } } } if (loginCredentials.Host == null || loginCredentials.Port == 0 || loginCredentials.Password == "") { Console.WriteLine("BattleNET client usage:"); Console.WriteLine("BattleNET client.exe -host 127.0.0.1 -port 2302 -password admin [-command shutdown]"); Console.Read(); Environment.Exit(0); } } else { loginCredentials = GetLoginCredentials(); } Console.Title = string.Format("BattleNET client v1.3.3 - {0}:{1}", loginCredentials.Host, loginCredentials.Port); BattlEyeClient b = new BattlEyeClient(loginCredentials); b.BattlEyeMessageReceived += BattlEyeMessageReceived; b.BattlEyeConnected += BattlEyeConnected; b.BattlEyeDisconnected += BattlEyeDisconnected; b.ReconnectOnPacketLoss = true; b.Connect(); if (command != "") { b.SendCommand(command); while (b.CommandQueue > 0) { /* wait until server received packet */ }; } else { while (true) { string cmd = Console.ReadLine(); if (cmd == "exit" || cmd == "logout") { break; } if (b.Connected) { b.SendCommand(cmd); } else { Environment.Exit(0); } } } b.Disconnect(); }
static void Main(string[] args) { string line; bool error = false; Console.ResetColor(); CommandLineArgs CommandLine = new CommandLineArgs(args); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("===================================="); Console.WriteLine("ZEDAR.COM.AR // RCon Kicker Started!"); Console.WriteLine("===================================="); Console.ForegroundColor = ConsoleColor.Red; BattlEyeLoginCredentials loginCredentials; loginCredentials = GetLoginCredentials(args); if (CommandLine["ip"] == null) { Console.WriteLine("IP is missing!"); error = true; } if (CommandLine["port"] == null) { Console.WriteLine("Port is missing!"); error = true; } if (CommandLine["password"] == null) { Console.WriteLine("Password is missing!"); error = true; } if (CommandLine["kickall"] != null) { string kam = "Restarting, reconnect in 2 minutes!"; int kamin = 2; if (CommandLine["kickallmsg"] != null) { kam = CommandLine["kickallmsg"]; } else { Console.WriteLine("kickall message is missing, using the default: " + kam); } if (CommandLine["kickallmin"] != null) { kamin = Convert.ToInt32(CommandLine["kickallmin"]); } else { Console.WriteLine("Minutes of ban missing, using the default: " + kamin); } if (!error) { BattlEyeClient b = new BattlEyeClient(loginCredentials); b.BattlEyeMessageReceived += BattlEyeMessageReceived; b.ReconnectOnPacketLoss = true; b.Connect(); // :) for (int i = 0; i <= 100; i++) { //b.SendCommandPacket(EBattlEyeCommand.Kick, Convert.ToString(i)); b.SendCommand("ban " + Convert.ToString(i) + " " + kamin + " " + kam); } b.Disconnect(); } Environment.Exit(0); } Console.ResetColor(); if (CommandLine["file"] != null) { if (!error) { try { System.IO.StreamReader file = new System.IO.StreamReader(CommandLine["file"]); BattlEyeClient b = new BattlEyeClient(loginCredentials); b.BattlEyeMessageReceived += BattlEyeMessageReceived; b.ReconnectOnPacketLoss = true; b.Connect(); while ((line = file.ReadLine()) != null) { Console.WriteLine(line); b.SendCommand("#kick " + line); } b.Disconnect(); file.Close(); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Error: " + ex); Console.ResetColor(); } } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("File path is missing!"); error = true; Console.ResetColor(); } // Console.ReadLine(); }
private static void Main(string[] args) { BattlEyeLoginCredentials loginCredentials; string command = ""; Console.OutputEncoding = Encoding.UTF8; if (args.Length > 0) { loginCredentials = GetLoginCredentials(args); for (int i = 0; i < args.Length; i++) { if (args[i] == "-command") { try { command = args[i + 1]; } catch { Console.WriteLine("No command given!"); loginCredentials.Host = null; } } } if (loginCredentials.Host == null || loginCredentials.Port == 0 || loginCredentials.Password == "") { Console.Read(); Environment.Exit(0); } } else { loginCredentials = GetLoginCredentials(); } Console.Title = string.Format("BattleNET client v1.2 - {0}:{1}", loginCredentials.Host, loginCredentials.Port); BattlEyeClient b = new BattlEyeClient(loginCredentials); b.MessageEvent += Message; b.ConnectEvent += Connect; b.DisconnectEvent += Disconnect; b.ReconnectOnPacketLoss = true; b.Connect(); if (command != "") { b.SendCommandPacket(command); while (b.CommandQueue > 0) { /* wait until server received packet */ }; } else { while (true) { string cmd = Console.ReadLine(); if (cmd == "exit" || cmd == "logout") { break; } if (b.Connected) { b.SendCommandPacket(cmd); } else { Environment.Exit(0); } } } b.Disconnect(); }
private void ExecCustomCmd(CommandExecContext commandCtx) { string command = commandCtx.CommandString; var beClient = new BattlEyeClient(commandCtx.Server.LoginCredentials) { ReconnectOnPacketLoss = true, DiscardConsoleMessages = true }; beClient.DisconnectEvent += this.Disconnected; beClient.Connect(); this.Log.Info("> " + command); BattlEyeCommandResult result = beClient.SendCommandPacket(command, false); this.Log.Info(result.ToString()); while (beClient.CommandQueue > 0) { /* wait until server received all packets */ } beClient.Disconnect(); // ~beClient(); }