private void PlayerList(CommandArgs args) { bool verbose = false; bool playersFound = false; bool help = false; PlayerOnlineListArguments arguments = new PlayerOnlineListArguments(args.Parameters.ToArray()); if (arguments.Contains("-help")) { help = true; } if (help) { args.Player.SendMessage("Syntax: /playersonline [-help] ", Color.Red); args.Player.SendMessage("Flags: ", Color.LightSalmon); args.Player.SendMessage(" -help this information", Color.LightSalmon); return; } List <object> playerList = new List <object>(); foreach (TSPlayer tsPlayer in TShock.Players.Where(p => null != p)) { Player player = new Player(tsPlayer.Name, tsPlayer.IP, tsPlayer.Group.Name, tsPlayer.UserAccountName); playerList.Add(player); } if (playerList.Count == 0) { args.Player.SendSuccessMessage("No players online at this time."); } else { string plural = ""; if (playerList.Count > 1) { plural = "s"; } args.Player.SendSuccessMessage(playerList.Count + "/" + TShock.Config.MaxSlots + " player" + plural + " online at this time."); // Query for ascending sort. IEnumerable <Player> playerSort = from Player p in playerList orderby p.Name //"ascending" is default select p; foreach (Player p in playerSort) { args.Player.SendInfoMessage(String.Format(" {0} {1} Group:{2} UserAccount:{3}", p.Name, p.IP, p.Group, p.UserAccountName ?? "<none>")); playersFound = true; } if (!playersFound) { args.Player.SendSuccessMessage("No players online at this time."); } } }
private void PlayerList(CommandArgs args) { bool verbose = false; bool playersFound = false; bool help = false; PlayerOnlineListArguments arguments = new PlayerOnlineListArguments(args.Parameters.ToArray()); if (arguments.Contains("-help")) help = true; if (help) { args.Player.SendMessage("Syntax: /playersonline [-help] ", Color.Red); args.Player.SendMessage("Flags: ", Color.LightSalmon); args.Player.SendMessage(" -help this information", Color.LightSalmon); return; } List<object> playerList = new List<object>(); foreach (TSPlayer tsPlayer in TShock.Players.Where(p => null != p)) { Player player = new Player(tsPlayer.Name, tsPlayer.IP, tsPlayer.Group.Name, tsPlayer.UserAccountName); playerList.Add(player); } if (playerList.Count == 0) args.Player.SendSuccessMessage("No players online at this time."); else { string plural = ""; if (playerList.Count > 1) plural = "s"; args.Player.SendSuccessMessage(playerList.Count + "/" + TShock.Config.MaxSlots + " player" + plural + " online at this time."); // Query for ascending sort. IEnumerable<Player> playerSort = from Player p in playerList orderby p.Name //"ascending" is default select p; foreach (Player p in playerSort) { args.Player.SendInfoMessage(String.Format(" {0} {1} Group:{2} UserAccount:{3}", p.Name, p.IP, p.Group, p.UserAccountName ?? "<none>")); playersFound = true; } if (!playersFound) { args.Player.SendSuccessMessage("No players online at this time."); } } }