public void ListPlayers() { string currentLine = string.Empty; var activePlayers = false; var disconnectedPlayers = false; var isPlayer = false; try { string playerList = rconServerProxy.GetPlayerList(); // Remove all rows from the grid ClearGridRows(grdPlayers); // Take the response and break it into a string array breaking each line off string[] playerArray = playerList.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None); for (var i = 0; i < playerArray.Length; i++) { // Get the current line currentLine = playerArray[i].Trim(); // No blank lines if (currentLine.Length > 0) { switch (currentLine.Trim()) { case "----- Active Players -----": activePlayers = true; disconnectedPlayers = false; isPlayer = false; break; case "----- Recently Disconnected Players [Max of 15] -----": activePlayers = false; disconnectedPlayers = true; isPlayer = false; break; default: isPlayer = true; break; } // Process connected player list if (activePlayers) { if (isPlayer) { string[] playerInfo = currentLine.Split(':'); string[] slot = playerInfo[1].Split('|'); string[] steamId = playerInfo[2].Split('|'); string playerName = playerInfo[3]; AddPlayerToGrid(slot[0], playerName, steamId[0], "Connected", ""); } } // Process disconnected player list if (disconnectedPlayers) { if (isPlayer) { string[] playerInfo = currentLine.Split(':'); string[] slot = playerInfo[1].Split('|'); string[] steamId = playerInfo[2].Split('|'); string[] time = playerInfo[3].Split('|'); string playerName = playerInfo[4]; AddPlayerToGrid(slot[0], playerName, steamId[0], "Disconnected", time[0]); } } } } } catch (Exception ex) { } }