Added permission for seeing ids when using /who

Also added in the ability to see ids when using /who.  Good for quickly adding ids to a region.
This commit is contained in:
Zack Piispanen 2012-01-26 19:41:12 -05:00
parent 174acade76
commit 1306043c00
3 changed files with 31 additions and 2 deletions

View file

@ -2636,7 +2636,10 @@ namespace TShockAPI
private static void Playing(CommandArgs args)
{
args.Player.SendMessage(string.Format("Current players: {0}.", TShock.Utils.GetPlayers()), 255, 240, 20);
string response = args.Player.Group.HasPermission(Permissions.seeids)
? TShock.Utils.GetPlayersWithIds()
: TShock.Utils.GetPlayers();
args.Player.SendMessage(string.Format("Current players: {0}.", response), 255, 240, 20);
args.Player.SendMessage(string.Format("TShock: {0} ({1}): ({2}/{3})", TShock.VersionNum, TShock.VersionCodename,
TShock.Utils.ActivePlayers(), TShock.Config.MaxSlots));
}

View file

@ -158,7 +158,10 @@ namespace TShockAPI
[Description("User can start invasions (Goblin/Snow Legion) using items")]
public static readonly string startinvasion;
static Permissions()
[Description("User can see the id of players with /who")]
public static readonly string seeids;
static Permissions()
{
foreach (var field in typeof (Permissions).GetFields())
{

View file

@ -69,6 +69,29 @@ namespace TShockAPI
return sb.ToString();
}
/// <summary>
/// Used for some places where a list of players might be used.
/// </summary>
/// <returns>String of players and their id seperated by commas.</returns>
public string GetPlayersWithIds()
{
var sb = new StringBuilder();
foreach (TSPlayer player in TShock.Players)
{
if (player != null && player.Active)
{
if (sb.Length != 0)
{
sb.Append(", ");
}
sb.Append(player.Name);
string id = "( " + Convert.ToString(TShock.Users.GetUserID(player.UserAccountName)) + " )";
sb.Append(id);
}
}
return sb.ToString();
}
/// <summary>
/// Finds a player and gets IP as string
/// </summary>