Added IP to TSPlayer

This commit is contained in:
ricky 2011-06-15 16:10:27 +10:00
parent 42905f2317
commit a8df558fe2
2 changed files with 9 additions and 6 deletions

View file

@ -48,6 +48,10 @@ namespace TShockAPI
{ {
get { return TPlayer.active; } get { return TPlayer.active; }
} }
public string IP
{
get { return Tools.GetRealIP(Netplay.serverSock[Index].tcpClient.Client.RemoteEndPoint.ToString()); }
}
public int Team public int Team
{ {
get { return TPlayer.team; } get { return TPlayer.team; }

View file

@ -238,14 +238,13 @@ namespace TShockAPI
} }
if (text.StartsWith("playing")) if (text.StartsWith("playing"))
{ {
int count = 0; int count = 0;
for (int i = 0; i < Main.maxPlayers; i++) foreach (TSPlayer player in Players)
{ {
if (Main.player[i].active) if (player != null && player.Active)
{ {
count++; count++;
Console.WriteLine(string.Format("{0} ({1}) [{2}]", Main.player[i].name, Console.WriteLine(string.Format("{0} ({1}) [{2}]", player.Name, player.IP, player.Group.Name));
Netplay.serverSock[i].tcpClient.Client.RemoteEndPoint, Players[i].Group.Name));
} }
} }
Console.WriteLine(string.Format("{0} players connected.", count)); Console.WriteLine(string.Format("{0} players connected.", count));