- Home /
Question by
menep · May 27, 2012 at 02:19 PM ·
multiplayerplayernetworkchat
Network.player giving me 0
When Im not a server returns -1, if im a server it returns 0, if I connect as client it returns 1, but only locally. The server still has got 0 in this code:
void TellServerOurName(string name, NetworkMessageInfo info)
{
PlayerNode newEntry = new PlayerNode();
newEntry.PlayerName = playerName;
newEntry.player = Network.player;
playerList.Add(newEntry);
}
void OnPlayerDisconnected(NetworkPlayer netplayer) {
addGameChatMessage("A player has disconected");
playerList.Remove(GetPlayerNode(netplayer));
}
When I disconnect and try to delete the player it is looking in arrayList for one numbered 1. But they are all 0. The names are correct.
How can I get the real Network.player in the network and not one of the server?
Im thinking about using PlayerPrefs.GetString() because on the client side it gets the correct numbers 1,2,3.... And then send it to server. This is an option, not so stupid, but still I want to know why Network.player is not working properly.
Comment