Example #1
0
        private void copyHost_click(object sender, EventArgs e)
        {
            ListViewItem item = list.SelectedItems[0];
            String       host = item.SubItems[0].Text;

            try
            {
                gui.Invoke((MethodInvoker) delegate
                {
                    Clipboard.SetText(host);
                });
            }
            catch
            {
                gui.Invoke((MethodInvoker) delegate
                {
                    gui.Log(Resources.Strings.Error_occ, LogType.Debug, false);
                });
            }
        }
        private void done_Click(object sender, EventArgs e)
        {
            Settings.Default.savePlayers               = savePlayers.Checked;
            Settings.Default.saveHosts                 = saveHosts.Checked;
            Settings.Default.showTimestamps            = showTimestamps.Checked;
            Settings.Default.colorChat                 = colorChat.Checked;
            Settings.Default.colorFilters              = colorFilters.Checked;
            Settings.Default.refreshOnJoin             = refreshOnJoin.Checked;
            Settings.Default.showGlobalChat            = showGlobalChat.Checked;
            Settings.Default.showSideChat              = showSideChat.Checked;
            Settings.Default.showDirectChat            = showDirectChat.Checked;
            Settings.Default.showVehicleChat           = showVehicleChat.Checked;
            Settings.Default.showCommandChat           = showCommandChat.Checked;
            Settings.Default.showGroupChat             = showGroupChat.Checked;
            Settings.Default.showUnknownChat           = showUnknownChat.Checked;
            Settings.Default.showConnectMessages       = showConnectMessages.Checked;
            Settings.Default.showDebug                 = showDebug.Checked;
            Settings.Default.showPlayerConnectMessages = showPlayerConnectMessages.Checked;
            Settings.Default.showRefreshMessages       = showRefreshMessages.Checked;
            Settings.Default.showVerificationMessages  = showVerificationMessages.Checked;
            Settings.Default.showAdminMessages         = showAdminMessages.Checked;
            Settings.Default.showAdminChat             = showAdminChat.Checked;
            Settings.Default.saveLog              = saveLog.Checked;
            Settings.Default.requestOnConnect     = requestOnConnect.Checked;
            Settings.Default.showAdminCalls       = showAdminCalls.Checked;
            Settings.Default.useNameForAdminCalls = useNameForAdminCalls.Checked;
            Settings.Default.flash            = flash.Checked;
            Settings.Default.dartbrs          = dartbrs.Checked;
            Settings.Default.connectOnStartup = connectOnStartup.Checked;

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

            Settings.Default.name = name.Text;
            Settings.Default.font = font;

            try
            {
                Settings.Default.quickBan    = int.Parse(quickBan.Text);
                Settings.Default.interval    = UInt32.Parse(interval.Text);
                Settings.Default.playerTicks = UInt32.Parse(playerTicks.Text);
                Settings.Default.banTicks    = UInt32.Parse(banTicks.Text);
                Settings.Default.buffer      = UInt32.Parse(buffer.Text);
            }
            catch
            {
                gui.Log("An error occurred while applying the settings.", LogType.Debug, false);
            }
            Settings.Default.Save();

            this.Close();
        }
Example #3
0
        public List <Player> getPlayers()
        {
            List <Player> players = new List <Player>();

            int id = this.Send(BattlEyeCommand.Players);

            string response;
            int    ticks = 0;

            while ((response = this.GetResponse(id)) == null && ticks < Settings.Default.playerTicks)
            {
                Thread.Sleep(10);
                ticks++;
            }

            if (response == null)
            {
                if (!_reconnecting)
                {
                    _form.Log("Player request timed out.", LogType.Console, false);
                }
                return(players);
            }

            using (StringReader reader = new StringReader(response))
            {
                string line;
                int    row = 0;
                while ((line = reader.ReadLine()) != null)
                {
                    row++;
                    if (row > 3 && !line.StartsWith("(") && line.Length > 0)
                    {
                        String[] items = line.Split(new char[] { ' ' }, 5, StringSplitOptions.RemoveEmptyEntries);

                        if (items.Length == 5)
                        {
                            int    number = Int32.Parse(items[0]);
                            String ip     = items[1].Split(':')[0];
                            String ping   = items[2];
                            String guid   = items[3].Replace("(OK)", "").Replace("(?)", "");
                            String name   = items[4];
                            String status = "Unknown";

                            if (guid.Length == 32)
                            {
                                if (guid == "-")
                                {
                                    status = "Initializing";
                                }

                                if (name.EndsWith(" (Lobby)"))
                                {
                                    name   = name.Replace(" (Lobby)", "");
                                    status = "Lobby";
                                }
                                else
                                {
                                    status = "Ingame";
                                }

                                players.Add(new Player(number, ip, ping, guid, name, status));
                            }
                            else
                            {
                                // Received malformed player list
                                return(new List <Player>());
                            }
                        }
                        else
                        {
                            // Received malformed player list
                            return(new List <Player>());
                        }
                    }
                }
            }

            return(players);
        }
Example #4
0
        private void done_Click(object sender, EventArgs e)
        {
            Settings.Default.savePlayers               = savePlayers.Checked;
            Settings.Default.saveHosts                 = saveHosts.Checked;
            Settings.Default.showTimestamps            = showTimestamps.Checked;
            Settings.Default.colorChat                 = colorChat.Checked;
            Settings.Default.colorFilters              = colorFilters.Checked;
            Settings.Default.refreshOnJoin             = refreshOnJoin.Checked;
            Settings.Default.showGlobalChat            = showGlobalChat.Checked;
            Settings.Default.showSideChat              = showSideChat.Checked;
            Settings.Default.showDirectChat            = showDirectChat.Checked;
            Settings.Default.showVehicleChat           = showVehicleChat.Checked;
            Settings.Default.showCommandChat           = showCommandChat.Checked;
            Settings.Default.showGroupChat             = showGroupChat.Checked;
            Settings.Default.showUnknownChat           = showUnknownChat.Checked;
            Settings.Default.showConnectMessages       = showConnectMessages.Checked;
            Settings.Default.showDebug                 = showDebug.Checked;
            Settings.Default.showPlayerConnectMessages = showPlayerConnectMessages.Checked;
            Settings.Default.showRefreshMessages       = showRefreshMessages.Checked;
            Settings.Default.showVerificationMessages  = showVerificationMessages.Checked;
            Settings.Default.showAdminMessages         = showAdminMessages.Checked;
            Settings.Default.showAdminChat             = showAdminChat.Checked;
            Settings.Default.saveLog              = saveLog.Checked;
            Settings.Default.requestOnConnect     = requestOnConnect.Checked;
            Settings.Default.showAdminCalls       = showAdminCalls.Checked;
            Settings.Default.useNameForAdminCalls = useNameForAdminCalls.Checked;
            Settings.Default.flash            = flash.Checked;
            Settings.Default.dartbrs          = dartbrs.Checked;
            Settings.Default.connectOnStartup = connectOnStartup.Checked;
            Settings.Default.hilight.Clear();
            Settings.Default.hilight.AddRange(hilight.Lines);

            Settings.Default.autoBans  = autoBans.Checked;
            Settings.Default.autoKicks = autoKicks.Checked;
            Settings.Default.autoKick.Clear();
            Settings.Default.autoKick.AddRange(autoKick.Lines);
            Settings.Default.autoBan.Clear();
            Settings.Default.autoBan.AddRange(autoBan.Lines);

            Settings.Default.dbRemote   = dbRemote.Checked;
            Settings.Default.dbHost     = dbHost.Text;
            Settings.Default.dbBase     = dbBase.Text;
            Settings.Default.dbUser     = dbUser.Text;
            Settings.Default.dbPassword = dbPassword.Text;

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

            Settings.Default.name = name.Text;
            Settings.Default.font = font;

            Settings.Default.Check_update = updates.Checked;
            Settings.Default.WebServer    = web_enable.Checked;
            Settings.Default.WebRoot      = root_dir.Text;
            Settings.Default.WebUser      = web_user.Text;
            Settings.Default.WebPassword  = web_password.Text;

            try
            {
                Settings.Default.WebPort     = int.Parse(web_port.Text);
                Settings.Default.quickBan    = int.Parse(quickBan.Text);
                Settings.Default.interval    = UInt32.Parse(interval.Text);
                Settings.Default.playerTicks = UInt32.Parse(playerTicks.Text);
                Settings.Default.banTicks    = UInt32.Parse(banTicks.Text);
                Settings.Default.buffer      = UInt32.Parse(buffer.Text);
            }
            catch
            {
                gui.Log(Resources.Strings.Error_occ, LogType.Debug, false);
            }
            Settings.Default.Save();
            if (Settings.Default.WebServer && gui.webService == null)
            {
                gui.InitialazeWeb();
            }

            this.Close();
        }
Example #5
0
        public List <Player> getPlayers()
        {
            int id = this.Send(BattlEyeCommand.Players);

            string response;
            int    ticks = 0;

            while ((response = this.GetResponse(id)) == null && ticks < Settings.Default.playerTicks)
            {
                Thread.Sleep(10);
                ticks++;
            }

            if (response == null)
            {
                if (_players.Count > 0)
                {
                    return(_players);
                }
                if (!_reconnecting)
                {
                    _form.Log(Resources.Strings.Player_timeout, LogType.Console, false);
                }
                return(_players);
            }
            this.parsePlayers(response);

            return(_players);
        }