Ejemplo n.º 1
0
        public GUIconfirm(GUImain gui, RCon rcon)
        {
            InitializeComponent();

            this.gui  = gui;
            this.rcon = rcon;
        }
Ejemplo n.º 2
0
        public GUIconfirm(GUImain gui, RCon rcon)
        {
            InitializeComponent();

            this.gui = gui;
            this.rcon = rcon;
        }
Ejemplo n.º 3
0
        public GUIhosts(GUImain gui, SqliteConnection connection, SqliteCommand command)
        {
            InitializeComponent();
            InitializeList();

            this.gui = gui;
            _connection = connection;
            _command = command;

            using (_command = new SqliteCommand("SELECT host, port, password FROM hosts ORDER BY id DESC", _connection))
            {

                using (SqliteDataReader reader = _command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        String host = gui.GetSafeString(reader, 0);
                        String port = gui.GetSafeString(reader, 1);
                        String password = gui.GetSafeString(reader, 2);

                        String[] items = { host, port, password };
                        ListViewItem item = new ListViewItem(items);
                        list.Items.Add(item);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public GUIhosts(GUImain gui, SqliteConnection connection)
        {
            InitializeComponent();
            InitializeList();

            this.gui    = gui;
            _connection = connection;

            using (SqliteCommand command = new SqliteCommand("SELECT host, port, password FROM hosts ORDER BY id DESC", _connection))
            {
                using (SqliteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        String host     = gui.GetSafeString(reader, 0);
                        String port     = gui.GetSafeString(reader, 1);
                        String password = gui.GetSafeString(reader, 2);

                        String[]     items = { host, port, password };
                        ListViewItem item  = new ListViewItem(items);
                        list.Items.Add(item);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public void Comment(GUImain gui, String name, String guid, String mode)
 {
     this.gui   = gui;
     this.Text  = Resources.Strings.Comment + " " + name;
     this.guid  = guid;
     this.mode  = mode;
     input.Text = gui.GetComment(guid);
 }
Ejemplo n.º 6
0
        public GUIkick(GUImain gui, int id, String name)
        {
            InitializeComponent();

            this.gui = gui;
            this.id = id;
            this.name = name;
            this.Text = "Kick " + name;
        }
Ejemplo n.º 7
0
        public GUImessage(GUImain gui, int id, String name)
        {
            InitializeComponent();

            this.gui = gui;
            this.id = id;
            this.name = name;
            this.Text = "Talk to " + name;
        }
Ejemplo n.º 8
0
        public GUIkick(GUImain gui, int id, String name)
        {
            InitializeComponent();

            this.gui  = gui;
            this.id   = id;
            this.name = name;
            this.Text = "Kick " + name;
        }
Ejemplo n.º 9
0
        public GUIkick(GUImain gui, int id, String name)
        {
            InitializeComponent();

            this.gui  = gui;
            this.id   = id;
            this.name = name;
            this.Text = Resources.Strings.Kick + " " + name;
        }
Ejemplo n.º 10
0
        public GUImessage(GUImain gui, int id, String name)
        {
            InitializeComponent();

            this.gui  = gui;
            this.id   = id;
            this.name = name;
            this.Text = "Talk to " + name;
        }
Ejemplo n.º 11
0
        public GUIreport(GUImain gui, String reporter, String ip, String port, String guid, String name)
        {
            InitializeComponent();

            this.gui = gui;
            this.reporter = reporter;
            this.ip = ip;
            this.port = port;
            this.guid = guid;
            this.name = name;
            this.Text = "Reporting " + name + " to DaRTBans";
        }
Ejemplo n.º 12
0
        public RCon(GUImain form)
        {
            _form = form;

            // Initializing date
            this.lastsent = new DateTime();

            // Initializing filters
            _filters = new HashSet <string>();

            string[] filters = Settings.Default.filters.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string filter in filters)
            {
                _filters.Add(filter);
            }
        }
Ejemplo n.º 13
0
        public RCon(GUImain form)
        {
            _form = form;

            // Initializing date
            this.lastsent = new DateTime();

            // Initializing filters
            _filters = new HashSet<string>();

            string[] filters = Settings.Default.filters.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string filter in filters)
            {
                _filters.Add(filter);
            }
        }
Ejemplo n.º 14
0
        public GUIcrash(Exception e, String version, GUImain gui)
        {
            InitializeComponent();

            this.gui = gui;

            Process p = Process.GetCurrentProcess();
            PerformanceCounter memUsage = new PerformanceCounter("memory", "Available MBytes");

            exception.Text += "---------- Info ----------\r\n";
            exception.Text += "DaRT " + version + "\r\n";
            exception.Text += "Time of crash: " + System.DateTime.Now + "\r\n";
            exception.Text += "Total used memory: " + p.PrivateMemorySize64 / 1024 / 1024 + " MB / " + memUsage.NextValue() + " MB\r\n";
            exception.Text += "Threads: " + p.Threads.Count + "\r\n";
            exception.Text += "---------- Error ----------\r\n";
            exception.Text += e.Message + "\r\n";
            exception.Text += "---------- StackTrace ----------\r\n";
            exception.Text += e.StackTrace;
        }
Ejemplo n.º 15
0
        public GUIcrash(Exception e, String version, GUImain gui)
        {
            InitializeComponent();

            this.gui = gui;

            Process            p        = Process.GetCurrentProcess();
            PerformanceCounter memUsage = new PerformanceCounter("memory", "Available MBytes");

            exception.Text += "---------- Info ----------\r\n";
            exception.Text += "DaRT " + version + "\r\n";
            exception.Text += "Time of crash: " + System.DateTime.Now + "\r\n";
            exception.Text += "Total used memory: " + p.PrivateMemorySize64 / 1024 / 1024 + " MB / " + memUsage.NextValue() + " MB\r\n";
            exception.Text += "Threads: " + p.Threads.Count + "\r\n";
            exception.Text += "---------- Error ----------\r\n";
            exception.Text += e.Message + "\r\n";
            exception.Text += "---------- StackTrace ----------\r\n";
            exception.Text += e.StackTrace;
        }
Ejemplo n.º 16
0
        public void Comment(GUImain gui, SqliteConnection connection, String name, String guid, String mode)
        {
            this.gui = gui;
            this.connection = connection;
            this.Text = "Comment " + name;
            this.guid = guid;
            this.mode = mode;

            SqliteCommand command = new SqliteCommand(connection);
            command.CommandText = "SELECT comment FROM comments WHERE guid = @guid";
            command.Parameters.Add(new SqliteParameter("@guid", guid));

            SqliteDataReader reader = command.ExecuteReader();

            if (reader.Read())
                input.Text = gui.GetSafeString(reader, 0);

            reader.Close();
            reader.Dispose();
            command.Dispose();
        }
Ejemplo n.º 17
0
        public void Comment(GUImain gui, SqliteConnection connection, String name, String guid, String mode)
        {
            this.gui        = gui;
            this.connection = connection;
            this.Text       = "Comment " + name;
            this.guid       = guid;
            this.mode       = mode;

            SqliteCommand command = new SqliteCommand(connection);

            command.CommandText = "SELECT comment FROM comments WHERE guid = @guid";
            command.Parameters.Add(new SqliteParameter("@guid", guid));

            SqliteDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                input.Text = gui.GetSafeString(reader, 0);
            }

            reader.Close();
            reader.Dispose();
            command.Dispose();
        }
        public GUIsettings(GUImain gui)
        {
            InitializeComponent();

            this.gui = gui;

            ToolTip tooltip = new ToolTip();

            tooltip.AutoPopDelay = 30000;

            tooltip.SetToolTip(savePlayers, "Should DaRT store all players in a database?");
            tooltip.SetToolTip(saveHosts, "Should DaRT save the hosts you connected to?");
            tooltip.SetToolTip(showTimestamps, "Would you like to have timestamps in your log window?");
            tooltip.SetToolTip(colorChat, "Should the chat be colored in all tab?");
            tooltip.SetToolTip(colorFilters, "Should the filter logs be colored in all tab?");
            tooltip.SetToolTip(refreshOnJoin, "Do you want DaRT to automatically refresh everytime a player joins or leaves?");
            tooltip.SetToolTip(showGlobalChat, "Should the global chat be shown in your log?\r\nIMPORTANT: The global chat will always be transmitted to the server.");
            tooltip.SetToolTip(showSideChat, "Should the side chat be shown in your log?\r\nIMPORTANT: The side chat will only be transmitted to the server if atleast two players are online and in the same team.");
            tooltip.SetToolTip(showDirectChat, "Should the direct chat be shown in your log?\r\nIMPORTANT: Direct chat will only be transmitted to the server if atleast two players are in a range of 40 meters.");
            tooltip.SetToolTip(showVehicleChat, "Should the vehicle chat be shown in your log?\r\nIMPORTANT: Vehicle chat will only be transmitted to the server if atleast two players are in the same vehicle.");
            tooltip.SetToolTip(showCommandChat, "Should the command chat be shown in your log?");
            tooltip.SetToolTip(showUnknownChat, "Should any unknown chat be shown?\r\n(Unknown chats are usually added by mission. For example: Altis Life)");
            tooltip.SetToolTip(showGroupChat, "Should the group chat be shown in your log?\r\nIMPOTANT: Two players are required in order for this channel to be transmitted to the server.");
            tooltip.SetToolTip(showConnectMessages, "If checked, DaRT will show confirmation messages when you are connecting, disconnecting or reconnecting.");
            tooltip.SetToolTip(showDebug, "Should debug messages be enabled? Enable this if you want to send me a error report, so I can see what is going on.");
            tooltip.SetToolTip(showPlayerConnectMessages, "If checked connecting and disconnecting players will be shown.");
            tooltip.SetToolTip(showRefreshMessages, "Should DaRT give you a confirmation on each refresh?");
            tooltip.SetToolTip(showVerificationMessages, "Show verification messages for players? (Verfied GUID of...)");
            tooltip.SetToolTip(showAdminMessages, "Show admin logins?");
            tooltip.SetToolTip(showAdminChat, "Show global admin chat in log?");
            tooltip.SetToolTip(saveLog, "Should DaRT save a log file to console.txt?");
            tooltip.SetToolTip(requestOnConnect, "If checked, DaRT will automatically request your player and ban list on connecting to a server.");
            tooltip.SetToolTip(showAdminCalls, "Should DaRT highlight calls for admins in chat?");
            tooltip.SetToolTip(useNameForAdminCalls, "Should DaRT use your own name (set above) for admin calls? (for example: I need help, <yourname>!)");
            tooltip.SetToolTip(flash, "Should DaRT flash its window when a admin call was detected?");
            tooltip.SetToolTip(dartbrs, "Is a Ban Relay Server configured on the server?\r\nCheck DaRT thread for more details.");
            tooltip.SetToolTip(quickBan, "The duration a player is banned for when using the Quick Ban feature.");
            tooltip.SetToolTip(interval, "The time betweeen automatic refreshes.");
            tooltip.SetToolTip(playerTicks, "This is the tick amount that DaRT waits for a response from the server to arrive when requesting the player list.\r\n(lower = faster but unreliable)\r\n(higher = slower but more reliable)");
            tooltip.SetToolTip(banTicks, "This is the tick amount that DaRT waits for a response from the server to arrive when requesting the ban list.\r\n(lower = faster but unreliable)\r\n(higher = slower but more reliable)\r\n(should usually be higher then player ticks)");
            tooltip.SetToolTip(name, "Your name to be used when you chat ingame.\r\nfor example: [Name]: Your message here\r\nLeave empty to disable.");
            tooltip.SetToolTip(connectOnStartup, "If checked, DaRT will automatically connect to your last server on startup.");
            tooltip.SetToolTip(announcePlayers, "If checked, DaRT will send an announcement in global chat for login and logout of each player.");

            tooltip.SetToolTip(fontChooser, "You can choose a custom font for your log here.");

            savePlayers.Checked               = Settings.Default.savePlayers;
            saveHosts.Checked                 = Settings.Default.saveHosts;
            showTimestamps.Checked            = Settings.Default.showTimestamps;
            colorChat.Checked                 = Settings.Default.colorChat;
            colorFilters.Checked              = Settings.Default.colorFilters;
            refreshOnJoin.Checked             = Settings.Default.refreshOnJoin;
            showGlobalChat.Checked            = Settings.Default.showGlobalChat;
            showSideChat.Checked              = Settings.Default.showSideChat;
            showDirectChat.Checked            = Settings.Default.showDirectChat;
            showVehicleChat.Checked           = Settings.Default.showVehicleChat;
            showCommandChat.Checked           = Settings.Default.showCommandChat;
            showGroupChat.Checked             = Settings.Default.showGroupChat;
            showUnknownChat.Checked           = Settings.Default.showUnknownChat;
            showConnectMessages.Checked       = Settings.Default.showConnectMessages;
            showDebug.Checked                 = Settings.Default.showDebug;
            showPlayerConnectMessages.Checked = Settings.Default.showPlayerConnectMessages;
            showRefreshMessages.Checked       = Settings.Default.showRefreshMessages;
            showVerificationMessages.Checked  = Settings.Default.showVerificationMessages;
            showAdminMessages.Checked         = Settings.Default.showAdminMessages;
            showAdminChat.Checked             = Settings.Default.showAdminChat;
            saveLog.Checked              = Settings.Default.saveLog;
            requestOnConnect.Checked     = Settings.Default.requestOnConnect;
            showAdminCalls.Checked       = Settings.Default.showAdminCalls;
            useNameForAdminCalls.Checked = Settings.Default.useNameForAdminCalls;
            flash.Checked            = Settings.Default.flash;
            dartbrs.Checked          = Settings.Default.dartbrs;
            quickBan.Text            = Settings.Default.quickBan.ToString();
            interval.Text            = Settings.Default.interval.ToString();
            playerTicks.Text         = Settings.Default.playerTicks.ToString();
            banTicks.Text            = Settings.Default.banTicks.ToString();
            buffer.Text              = Settings.Default.buffer.ToString();
            name.Text                = Settings.Default.name;
            connectOnStartup.Checked = Settings.Default.connectOnStartup;

            showLogErrors.Checked            = Settings.Default.showLogErrors;
            showScriptsLog.Checked           = Settings.Default.showScriptsLog;
            showCreateVehicleLog.Checked     = Settings.Default.showCreateVehicleLog;
            showDeleteVehicleLog.Checked     = Settings.Default.showDeleteVehicleLog;
            showPublicVariableLog.Checked    = Settings.Default.showPublicVariableLog;
            showPublicVariableValLog.Checked = Settings.Default.showPublicVariableValLog;
            showRemoteExecLog.Checked        = Settings.Default.showRemoteExecLog;
            showRemoteControlLog.Checked     = Settings.Default.showRemoteControlLog;
            showSetDamageLog.Checked         = Settings.Default.showSetDamageLog;
            showSetPosLog.Checked            = Settings.Default.showSetPosLog;
            showSetVariableLog.Checked       = Settings.Default.showSetVariableLog;
            showSetVariableValLog.Checked    = Settings.Default.showSetVariableValLog;
            showAddBackpackCargoLog.Checked  = Settings.Default.showAddBackpackCargoLog;
            showAddMagazineCargoLog.Checked  = Settings.Default.showAddMagazineCargoLog;
            showAddWeaponCargoLog.Checked    = Settings.Default.showAddWeaponCargoLog;
            showAttachToLog.Checked          = Settings.Default.showAttachToLog;
            showMPEventHandlerLog.Checked    = Settings.Default.showMPEventHandlerLog;
            showSelectPlayerLog.Checked      = Settings.Default.showSelectPlayerLog;
            showTeamSwitchLog.Checked        = Settings.Default.showTeamSwitchLog;
            showWaypointConditionLog.Checked = Settings.Default.showWaypointConditionLog;
            showWaypointStatementLog.Checked = Settings.Default.showWaypointStatementLog;
            filters.Text            = Settings.Default.filters;
            announcePlayers.Checked = Settings.Default.announcePlayers;

            font = Settings.Default.font;
        }
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                if (Debugger.IsAttached)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    gui = new GUImain(version);
                    Application.Run(gui);
                    return;
                }
                Application.ThreadException += CatchThreadException;
                AppDomain.CurrentDomain.UnhandledException += CatchUnhandledException;

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                gui = new GUImain(version);
                Application.Run(gui);
            }
            else
            {
                AllocConsole();

                #region Read Config
                String ip = "127.0.0.1";
                int port = 2302;
                String password = "******";
                String command = "";
                String output = "";
                String script = "";
                int loop = 0;
                bool close = false;

                foreach (String arg in args)
                {
                    if (arg.StartsWith("-ip="))
                    {
                        ip = arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1]; ;
                    }
                    else if (arg.StartsWith("-port="))
                    {
                        try
                        {
                            port = Int32.Parse(arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1]);
                        }
                        catch
                        {
                            port = 2302;
                        }
                    }
                    else if (arg.StartsWith("-password="******"-pass="******"-pw="))
                    {
                        password = arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1];
                    }
                    else if (arg.StartsWith("-command="))
                    {
                        command = arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1];
                    }
                    else if (arg.StartsWith("-output="))
                    {
                        output = arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1];
                    }
                    else if(arg.StartsWith("-close"))
                    {
                        close = true;
                    }
                    else if (arg.StartsWith("-script="))
                    {
                        script = arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1];
                    }
                    else if (arg.StartsWith("-loop="))
                    {
                        loop = Int32.Parse(arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1]);
                    }
                }
                #endregion

                #region Establish Connection
                RCon rcon = new RCon(null);
                rcon.Connect(IPAddress.Parse(ip), port, password);
                #endregion

                #region Writing header
                if (output != "")
                    writer = File.CreateText(output);

                Write("DaRT " + version + " - DayZ RCon Tool");
                if (command != "")
                    Write("Running in command mode.");
                else if (script != "")
                    Write("Running in script mode.");
                Write("---------------------");
                Write("Supplied arguments:");
                foreach (String arg in args)
                {
                    Write(arg);
                }
                Write("---------------------");
                Write("Output:");
                #endregion

                if (command != "")
                {
                    #region Command mode
                    if (command == "players")
                    {
                        List<String> players = rcon.getRawPlayers();
                        foreach (String player in players)
                            Write(player);
                    }
                    else if (command == "bans")
                    {
                        List<String> bans = rcon.getRawBans();
                        foreach (String ban in bans)
                            Write(ban);
                    }
                    else if (command == "admins")
                    {
                        List<String> admins = rcon.getRawAdmins();
                        foreach (String admin in admins)
                            Write(admin);
                    }
                    else
                    {
                        rcon.execute(command);
                        Write("Command executed successfully!");
                    }
                    #endregion
                }
                else if (script != "")
                {
                    #region Script mode
                    Write("Running " + script);

                    String[] lines = File.ReadAllLines(script);
                    List<String> commands = new List<String>();

                    foreach (String line in lines)
                    {
                        if (line != "")
                        {
                            if (!line.StartsWith("//"))
                            {
                                commands.Add(line);
                            }
                        }
                    }

                    bool looping = true;
                    int run = 0;
                    do
                    {
                        foreach (String c in commands)
                        {
                            if (c.StartsWith("wait="))
                            {
                                int amount = Int32.Parse(c.Split('=')[1]);
                                Write("Waiting " + (amount / 1000) + "s");
                                Thread.Sleep(amount);
                                continue;
                            }
                            else if (c.StartsWith("exit") || c.StartsWith("quit") || c.StartsWith("close"))
                            {
                                Write("Stopped script.");
                                break;
                            }

                            String exec = c;

                            int players;
                            int admins;
                            int bans;
                            String randomPlayer;
                            if (c.Contains("%p"))
                            {
                                players = rcon.getPlayers().Count;
                                exec = c.Replace("%p", players.ToString());
                            }
                            if (c.Contains("%a"))
                            {
                                admins = rcon.getAdmins();
                                exec = c.Replace("%a", admins.ToString());
                            }
                            if (c.Contains("%b"))
                            {
                                bans = rcon.getBans().Count;
                                exec = c.Replace("%b", bans.ToString());
                            }
                            if (c.Contains("%r"))
                            {
                                List<Player> p = rcon.getPlayers();
                                if (p.Count > 0)
                                {
                                    Random random = new Random();
                                    randomPlayer = p[random.Next(0, p.Count)].name;
                                    exec = c.Replace("%r", randomPlayer);
                                }
                            }
                            if (c.Contains("%l"))
                            {
                                exec = c.Replace("%l", run.ToString());
                            }

                            if (c.StartsWith("if"))
                            {
                                String[] items = exec.Split(new char[] { ':' }, 3, StringSplitOptions.RemoveEmptyEntries);

                                String[] flags = items[0].Split(new char[] { ' ' }, 4, StringSplitOptions.RemoveEmptyEntries);
                                String param1 = flags[1];
                                String op = flags[2];
                                String param2 = flags[3];

                                bool fulfilled = false;

                                if (op == ">")
                                {
                                    if (Int32.Parse(param1) > Int32.Parse(param2))
                                        fulfilled = true;
                                }
                                else if (op == "<")
                                {
                                    if (Int32.Parse(param1) < Int32.Parse(param2))
                                        fulfilled = true;
                                }
                                else if (op == "=" || op == "==")
                                {
                                    if (param1 == param2)
                                        fulfilled = true;
                                }
                                else
                                {
                                }

                                if (fulfilled)
                                    exec = items[1];
                                else if (items.Length == 3)
                                    exec = items[2];
                                else
                                    continue;
                            }

                            if (exec.StartsWith("kickAll"))
                            {
                                Write("Kicking all players...");
                                String reason;
                                if (exec.Contains("="))
                                    reason = exec.Split('=')[1];
                                else
                                    reason = "Admin Kick";

                                List<Player> p = rcon.getPlayers();

                                foreach (Player player in p)
                                {
                                    rcon.kick(new Kick(player.number, player.name, reason));
                                }
                            }
                            else if (exec.StartsWith("banAll"))
                            {
                                Write("Banning all players...");
                                String reason;
                                if (exec.Contains("="))
                                    reason = exec.Split('=')[1];
                                else
                                    reason = "Admin Ban";

                                List<Player> p = rcon.getPlayers();

                                foreach (Player player in p)
                                {
                                    rcon.Ban(new Ban(player.number.ToString(), player.name, "0", reason));
                                }
                            }
                            else if (exec.StartsWith("exec"))
                            {
                                String execute = exec.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1];
                                Write(execute);
                                rcon.execute(execute);
                            }
                        }

                        if (run == loop)
                            looping = false;

                        if (loop != -1)
                            run++;
                    } while (looping);
                    #endregion
                }
                else
                {
                    Write("You need to run atleast one command or one script.");
                }
                
                rcon.Disconnect();
                if (writer != null)
                {
                    writer.Close();
                    writer.Dispose();
                }
                if (!close)
                {
                    Console.WriteLine("All done. Press any key to close.");
                    Console.ReadKey();
                    Console.WriteLine("Closing...");
                }
            }
        }
Ejemplo n.º 20
0
        public GUIsettings(GUImain gui)
        {
            InitializeComponent();

            this.gui = gui;

            ToolTip tooltip = new ToolTip();
            tooltip.AutoPopDelay = 30000;

            tooltip.SetToolTip(savePlayers, "Should DaRT store all players in a database?");
            tooltip.SetToolTip(saveHosts, "Should DaRT save the hosts you connected to?");
            tooltip.SetToolTip(showTimestamps, "Would you like to have timestamps in your log window?");
            tooltip.SetToolTip(colorChat, "Should the chat be colored in all tab?");
            tooltip.SetToolTip(colorFilters, "Should the filter logs be colored in all tab?");
            tooltip.SetToolTip(refreshOnJoin, "Do you want DaRT to automatically refresh everytime a player joins or leaves?");
            tooltip.SetToolTip(showGlobalChat, "Should the global chat be shown in your log?\r\nIMPORTANT: The global chat will always be transmitted to the server.");
            tooltip.SetToolTip(showSideChat, "Should the side chat be shown in your log?\r\nIMPORTANT: The side chat will only be transmitted to the server if atleast two players are online and in the same team.");
            tooltip.SetToolTip(showDirectChat, "Should the direct chat be shown in your log?\r\nIMPORTANT: Direct chat will only be transmitted to the server if atleast two players are in a range of 40 meters.");
            tooltip.SetToolTip(showVehicleChat, "Should the vehicle chat be shown in your log?\r\nIMPORTANT: Vehicle chat will only be transmitted to the server if atleast two players are in the same vehicle.");
            tooltip.SetToolTip(showCommandChat, "Should the command chat be shown in your log?");
            tooltip.SetToolTip(showUnknownChat, "Should any unknown chat be shown?\r\n(Unknown chats are usually added by mission. For example: Altis Life)");
            tooltip.SetToolTip(showGroupChat, "Should the group chat be shown in your log?\r\nIMPOTANT: Two players are required in order for this channel to be transmitted to the server.");
            tooltip.SetToolTip(showConnectMessages, "If checked, DaRT will show confirmation messages when you are connecting, disconnecting or reconnecting.");
            tooltip.SetToolTip(showDebug, "Should debug messages be enabled? Enable this if you want to send me a error report, so I can see what is going on.");
            tooltip.SetToolTip(showPlayerConnectMessages, "If checked connecting and disconnecting players will be shown.");
            tooltip.SetToolTip(showRefreshMessages, "Should DaRT give you a confirmation on each refresh?");
            tooltip.SetToolTip(showVerificationMessages, "Show verification messages for players? (Verfied GUID of...)");
            tooltip.SetToolTip(showAdminMessages, "Show admin logins?");
            tooltip.SetToolTip(showAdminChat, "Show global admin chat in log?");
            tooltip.SetToolTip(saveLog, "Should DaRT save a log file to console.txt?");
            tooltip.SetToolTip(requestOnConnect, "If checked, DaRT will automatically request your player and ban list on connecting to a server.");
            tooltip.SetToolTip(showAdminCalls, "Should DaRT highlight calls for admins in chat?");
            tooltip.SetToolTip(useNameForAdminCalls, "Should DaRT use your own name (set above) for admin calls? (for example: I need help, <yourname>!)");
            tooltip.SetToolTip(flash, "Should DaRT flash its window when a admin call was detected?");
            tooltip.SetToolTip(dartbrs, "Is a Ban Relay Server configured on the server?\r\nCheck DaRT thread for more details.");
            tooltip.SetToolTip(quickBan, "The duration a player is banned for when using the Quick Ban feature.");
            tooltip.SetToolTip(interval, "The time betweeen automatic refreshes.");
            tooltip.SetToolTip(playerTicks, "This is the tick amount that DaRT waits for a response from the server to arrive when requesting the player list.\r\n(lower = faster but unreliable)\r\n(higher = slower but more reliable)");
            tooltip.SetToolTip(banTicks, "This is the tick amount that DaRT waits for a response from the server to arrive when requesting the ban list.\r\n(lower = faster but unreliable)\r\n(higher = slower but more reliable)\r\n(should usually be higher then player ticks)");
            tooltip.SetToolTip(name, "Your name to be used when you chat ingame.\r\nfor example: [Name]: Your message here\r\nLeave empty to disable.");
            tooltip.SetToolTip(connectOnStartup, "If checked, DaRT will automatically connect to your last server on startup.");

            tooltip.SetToolTip(fontChooser, "You can choose a custom font for your log here.");

            savePlayers.Checked = Settings.Default.savePlayers;
            saveHosts.Checked = Settings.Default.saveHosts;
            showTimestamps.Checked = Settings.Default.showTimestamps;
            colorChat.Checked = Settings.Default.colorChat;
            colorFilters.Checked = Settings.Default.colorFilters;
            refreshOnJoin.Checked = Settings.Default.refreshOnJoin;
            showGlobalChat.Checked = Settings.Default.showGlobalChat;
            showSideChat.Checked = Settings.Default.showSideChat;
            showDirectChat.Checked = Settings.Default.showDirectChat;
            showVehicleChat.Checked = Settings.Default.showVehicleChat;
            showCommandChat.Checked = Settings.Default.showCommandChat;
            showGroupChat.Checked = Settings.Default.showGroupChat;
            showUnknownChat.Checked = Settings.Default.showUnknownChat;
            showConnectMessages.Checked = Settings.Default.showConnectMessages;
            showDebug.Checked = Settings.Default.showDebug;
            showPlayerConnectMessages.Checked = Settings.Default.showPlayerConnectMessages;
            showRefreshMessages.Checked = Settings.Default.showRefreshMessages;
            showVerificationMessages.Checked = Settings.Default.showVerificationMessages;
            showAdminMessages.Checked = Settings.Default.showAdminMessages;
            showAdminChat.Checked = Settings.Default.showAdminChat;
            saveLog.Checked = Settings.Default.saveLog;
            requestOnConnect.Checked = Settings.Default.requestOnConnect;
            showAdminCalls.Checked = Settings.Default.showAdminCalls;
            useNameForAdminCalls.Checked = Settings.Default.useNameForAdminCalls;
            flash.Checked = Settings.Default.flash;
            dartbrs.Checked = Settings.Default.dartbrs;
            quickBan.Text = Settings.Default.quickBan.ToString();
            interval.Text = Settings.Default.interval.ToString();
            playerTicks.Text = Settings.Default.playerTicks.ToString();
            banTicks.Text = Settings.Default.banTicks.ToString();
            buffer.Text = Settings.Default.buffer.ToString();
            name.Text = Settings.Default.name;
            connectOnStartup.Checked = Settings.Default.connectOnStartup;

            showLogErrors.Checked = Settings.Default.showLogErrors;
            showScriptsLog.Checked = Settings.Default.showScriptsLog;
            showCreateVehicleLog.Checked = Settings.Default.showCreateVehicleLog;
            showDeleteVehicleLog.Checked = Settings.Default.showDeleteVehicleLog;
            showPublicVariableLog.Checked = Settings.Default.showPublicVariableLog;
            showPublicVariableValLog.Checked = Settings.Default.showPublicVariableValLog;
            showRemoteExecLog.Checked = Settings.Default.showRemoteExecLog;
            showRemoteControlLog.Checked = Settings.Default.showRemoteControlLog;
            showSetDamageLog.Checked = Settings.Default.showSetDamageLog;
            showSetPosLog.Checked = Settings.Default.showSetPosLog;
            showSetVariableLog.Checked = Settings.Default.showSetVariableLog;
            showSetVariableValLog.Checked = Settings.Default.showSetVariableValLog;
            showAddBackpackCargoLog.Checked = Settings.Default.showAddBackpackCargoLog;
            showAddMagazineCargoLog.Checked = Settings.Default.showAddMagazineCargoLog;
            showAddWeaponCargoLog.Checked = Settings.Default.showAddWeaponCargoLog;
            showAttachToLog.Checked = Settings.Default.showAttachToLog;
            showMPEventHandlerLog.Checked = Settings.Default.showMPEventHandlerLog;
            showSelectPlayerLog.Checked = Settings.Default.showSelectPlayerLog;
            showTeamSwitchLog.Checked = Settings.Default.showTeamSwitchLog;
            showWaypointConditionLog.Checked = Settings.Default.showWaypointConditionLog;
            showWaypointStatementLog.Checked = Settings.Default.showWaypointStatementLog;
            filters.Text = Settings.Default.filters;

            font = Settings.Default.font;
        }
Ejemplo n.º 21
0
        static void Main(string[] args)
        {
            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
            FileVersionInfo            fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);

            version = fvi.FileVersion;
            if (args.Length == 0)
            {
                if (Debugger.IsAttached)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    gui = new GUImain(version);
                    Application.Run(gui);
                    return;
                }
                Application.ThreadException += CatchThreadException;
                AppDomain.CurrentDomain.UnhandledException += CatchUnhandledException;

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                gui = new GUImain(version);
                Application.Run(gui);
            }
            else
            {
                #region Read Config
                String ip       = "127.0.0.1";
                int    port     = 2302;
                String password = "******";
                String command  = "";
                String output   = "";
                String script   = "";
                int    loop     = 0;
                bool   close    = false;
                bool   window   = true;

                foreach (String arg in args)
                {
                    if (arg.StartsWith("-ip="))
                    {
                        ip = arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1];;
                    }
                    else if (arg.StartsWith("-port="))
                    {
                        try
                        {
                            port = Int32.Parse(arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1]);
                        }
                        catch
                        {
                            port = 2302;
                        }
                    }
                    else if (arg.StartsWith("-password="******"-pass="******"-pw="))
                    {
                        password = arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1];
                    }
                    else if (arg.StartsWith("-command=") || arg.StartsWith("-cmd="))
                    {
                        command = arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1];
                    }
                    else if (arg.StartsWith("-output="))
                    {
                        output = arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1];
                    }
                    else if (arg.StartsWith("-close"))
                    {
                        close = true;
                    }
                    else if (arg.StartsWith("-nowindow"))
                    {
                        window = false;
                    }
                    else if (arg.StartsWith("-script="))
                    {
                        script = arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1];
                    }
                    else if (arg.StartsWith("-loop="))
                    {
                        loop = Int32.Parse(arg.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1]);
                    }
                }
                #endregion

                #region Establish Connection
                RCon rcon = new RCon(null);
                rcon.Connect(IPAddress.Parse(ip), port, password);
                #endregion

                if (window)
                {
                    AllocConsole();
                }

                #region Writing header
                if (output != "")
                {
                    writer = File.CreateText(output);
                }

                Write("DaRT " + version + " - DayZ RCon Tool");
                if (command != "")
                {
                    Write("Running in command mode.");
                }
                else if (script != "")
                {
                    Write("Running in script mode.");
                }
                Write("---------------------");
                Write("Supplied arguments:");
                foreach (String arg in args)
                {
                    Write(arg);
                }
                Write("---------------------");
                Write("Output:");
                #endregion

                if (command != "")
                {
                    #region Command mode
                    if (command == "players")
                    {
                        List <Player> players = rcon.getPlayers();
                        foreach (Player player in players)
                        {
                            Write(player.ToString());
                        }
                    }
                    else if (command == "bans")
                    {
                        List <Ban> bans = rcon.getBans();
                        foreach (Ban ban in bans)
                        {
                            Write(ban.ToString());
                        }
                    }
                    else if (command == "admins")
                    {
                        List <String> admins = rcon.getAdmins();
                        foreach (String admin in admins)
                        {
                            Write(admin);
                        }
                    }
                    else
                    {
                        rcon.execute(command);
                        Write("Command executed successfully!");
                    }
                    #endregion
                }
                else if (script != "")
                {
                    #region Script mode
                    Write("Running " + script);

                    String[]      lines    = File.ReadAllLines(script);
                    List <String> commands = new List <String>();

                    foreach (String line in lines)
                    {
                        if (line != "")
                        {
                            if (!line.StartsWith("//"))
                            {
                                commands.Add(line);
                            }
                        }
                    }

                    bool looping = true;
                    int  run     = 0;
                    do
                    {
                        foreach (String c in commands)
                        {
                            if (c.StartsWith("wait="))
                            {
                                int amount = Int32.Parse(c.Split('=')[1]);
                                Write("Waiting " + (amount / 1000) + "s");
                                Thread.Sleep(amount);
                                continue;
                            }
                            else if (c.StartsWith("exit") || c.StartsWith("quit") || c.StartsWith("close"))
                            {
                                Write("Stopped script.");
                                break;
                            }

                            String exec = c;

                            int    players;
                            int    admins;
                            int    bans;
                            String randomPlayer;
                            if (c.Contains("%p"))
                            {
                                players = rcon.getPlayers().Count;
                                exec    = c.Replace("%p", players.ToString());
                            }
                            if (c.Contains("%a"))
                            {
                                admins = rcon.getAdmins().Count;
                                exec   = c.Replace("%a", admins.ToString());
                            }
                            if (c.Contains("%b"))
                            {
                                bans = rcon.getBans().Count;
                                exec = c.Replace("%b", bans.ToString());
                            }
                            if (c.Contains("%r"))
                            {
                                List <Player> p = rcon.getPlayers();
                                if (p.Count > 0)
                                {
                                    Random random = new Random();
                                    randomPlayer = p[random.Next(0, p.Count)].name;
                                    exec         = c.Replace("%r", randomPlayer);
                                }
                            }
                            if (c.Contains("%l"))
                            {
                                exec = c.Replace("%l", run.ToString());
                            }

                            if (c.StartsWith("if"))
                            {
                                String[] items = exec.Split(new char[] { ':' }, 3, StringSplitOptions.RemoveEmptyEntries);

                                String[] flags  = items[0].Split(new char[] { ' ' }, 4, StringSplitOptions.RemoveEmptyEntries);
                                String   param1 = flags[1];
                                String   op     = flags[2];
                                String   param2 = flags[3];

                                bool fulfilled = false;

                                if (op == ">")
                                {
                                    if (Int32.Parse(param1) > Int32.Parse(param2))
                                    {
                                        fulfilled = true;
                                    }
                                }
                                else if (op == "<")
                                {
                                    if (Int32.Parse(param1) < Int32.Parse(param2))
                                    {
                                        fulfilled = true;
                                    }
                                }
                                else if (op == "=" || op == "==")
                                {
                                    if (param1 == param2)
                                    {
                                        fulfilled = true;
                                    }
                                }
                                else
                                {
                                }

                                if (fulfilled)
                                {
                                    exec = items[1];
                                }
                                else if (items.Length == 3)
                                {
                                    exec = items[2];
                                }
                                else
                                {
                                    continue;
                                }
                            }

                            if (exec.StartsWith("kickAll"))
                            {
                                Write("Kicking all players...");
                                String reason;
                                if (exec.Contains("="))
                                {
                                    reason = exec.Split('=')[1];
                                }
                                else
                                {
                                    reason = "Admin Kick";
                                }

                                List <Player> p = rcon.getPlayers();

                                foreach (Player player in p)
                                {
                                    rcon.kick(new Kick(player.number, player.name, reason));
                                }
                            }
                            else if (exec.StartsWith("banAll"))
                            {
                                Write("Banning all players...");
                                String reason;
                                if (exec.Contains("="))
                                {
                                    reason = exec.Split('=')[1];
                                }
                                else
                                {
                                    reason = "Admin Ban";
                                }

                                List <Player> p = rcon.getPlayers();

                                foreach (Player player in p)
                                {
                                    rcon.Ban(new Ban(player.number, player.name, player.guid, player.ip, 0, reason, true));
                                }
                            }
                            else if (exec.StartsWith("exec"))
                            {
                                String execute = exec.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)[1];
                                Write(execute);
                                rcon.execute(execute);
                            }
                        }

                        if (run == loop)
                        {
                            looping = false;
                        }

                        if (loop != -1)
                        {
                            run++;
                        }
                    } while (looping);
                    #endregion
                }
                else
                {
                    Write("Params: -port=2302 ,-password= (-pass= -pw=), -command= (-cmd=), -output=file, -close, -nowindow, -loop=[-1,count], -script=file");
                }

                rcon.Disconnect();
                if (writer != null)
                {
                    writer.Close();
                    writer.Dispose();
                }
                if (!close && window)
                {
                    Console.WriteLine("All done. Press any key to close.");
                    Console.ReadKey();
                    Console.WriteLine("Closing...");
                }
            }
        }