SendCommand() публичный метод

public SendCommand ( BattlEyeCommand command, string parameters = "" ) : int
command BattlEyeCommand
parameters string
Результат int
Пример #1
0
        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();
        }
Пример #2
0
        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();
        }
Пример #3
0
        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();
        }