Refresh ID owners??

I’m using neworkView.owner to identify player’s objects to then retrieve info form an array.

The owner ID maches the array index. But if a player who was owner ID say 1 leaves and another player enter it is asigned as ID 2

so i end having the host ID 0 and player 1 as ID 2 wich doesn’t match anymore.

So i was wondering is there a way to unregister a neworkPlayer and refresh the IDs?

there is no need to do that, it will do it internally

Just never use the int handle and never cache it, instead use directly the exposed handle from the Network class

could you point me where to look up for that?

Make an Arraylist and a class ?

class PlayerData
{
var object : GameObject;
var player : NetworkPlayer;
}

var example : PlayerData = new PlayerData ();

example.object = GameObject.Find ("game Object");
example.player = info.sender;

Network.player

thats yours and

Network.connections

holds the other sides (server on client, and all clients on the server)

if you want / need to store something in relation to a playern then please use the approach AkilaeTribe has shown, use the NetworkPlayer reference instead, it will always be correct

I have an array and a calss set up. When on the lobby the host recive and gather the session info and brodcast it to the rest. for example the Name of the player.

On of the things i was trying to solve is to asign the Tag to the players.
So my problem was on how to idetify wich objects belongs to who.
I did it like this:

on the level start up name = "Player "+networkView.owner

so i get in both server and clients the Player 0 Player 1 etc…

then i do a little for loop like this:

for i = 0 … bla bla…

if (GameObject.Find ("Player "+ i).name == "Player "+i)
Tag = sessionInfo*.TagName;*
this works all cool. but i have that problem when a player leaves the owner don’t change.
You would ask why they woun’t mach anymore? well because the session info is displayed on a list and if i don’t re arenge the array i’ll have an empty space were the player who left the game used to be.
is hard to explain why i had to do it like this complicated. But i did try hundred of different ways.
This one works fine except for that problem.

Don’t include the NetworkPlayer information to the name. Make a variable called player or owner, of type NetworkPlayer, and define the NetworkPlayer there.