So how do I retrieve a list of “clients” that have connected to a server?
Ok, so I have worked it out… by using the OnConnectedToServer() function I can send RPCs with my player name and stuff… cool. But…
I am sending the networkplayer in the RPC call but how do I accedd the unique playerid of that player? I need to be able to use the playerid in my array incase the player disconnects… so I can remove them from my array of connected players.
I should add here that this list is just so a server can watch who is connecting before the game starts.
Maybe you’re looking for this function?
function OnPlayerDisconnected(player: NetworkPlayer) {
Debug.Log("Clean up after player " + player);
Network.RemoveRPCs(player);
Network.DestroyPlayerObjects(player);
}
When this happens, you just remove your player item from the array - probably easier if it’s an ArrayList.
You can also use Network.Connections to enumerate who is connected - it returns type NetworkPlayer.
Ahh, it was Network.Connections that I was looking for. Thanks Shaun. Again.