diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 6c79564b..5dd09524 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -48,6 +48,10 @@ namespace TShockAPI { get { return TPlayer.active; } } + public string IP + { + get { return Tools.GetRealIP(Netplay.serverSock[Index].tcpClient.Client.RemoteEndPoint.ToString()); } + } public int Team { get { return TPlayer.team; } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index b57b9b54..f44beeb2 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -238,14 +238,13 @@ namespace TShockAPI } if (text.StartsWith("playing")) { - int count = 0; - for (int i = 0; i < Main.maxPlayers; i++) - { - if (Main.player[i].active) + int count = 0; + foreach (TSPlayer player in Players) + { + if (player != null && player.Active) { count++; - Console.WriteLine(string.Format("{0} ({1}) [{2}]", Main.player[i].name, - Netplay.serverSock[i].tcpClient.Client.RemoteEndPoint, Players[i].Group.Name)); + Console.WriteLine(string.Format("{0} ({1}) [{2}]", player.Name, player.IP, player.Group.Name)); } } Console.WriteLine(string.Format("{0} players connected.", count));