RPC Parameters Help

Hi again. What im trying to do is create a clientList variable that will hold all the usernames of any current player inside my lobby. The problem i am having is that it seems RPC can take a string parameter, but not a List. parameter. Im not sure of any good way i can collect and pass around a complete list of user names, in one string , that i can easily remove a username from or add to when players join and leave the lobby.

With List it was simple , but it throws an error of course (strange thing is it still seemed to work - along side the error and all). Now i know how to use the RPC’s and get everything rolling , but again , im just not sure how i can go about tackling this with a single string? Is it pssible to send an Array of strings through , or just only one?

Why does the entire list of players need to get passed with the RPC? Why not have each client maintain their own list and just have each connecting/disconnecting client add/remove their name from everyone’s list’s via an RPC with a string parameter?

OK , well i cant seem to get it , three hours later , i know what your saying is correct and makes seense , but i can not seem to write it in script logicly :frowning: I thought that if i passed the network viewID along with the RPC’s , when the data made it back to the original connecting client , i could seperate and assign information to them only via the viewID.isMine or owner properties , but no such luck, for some reason , it doesnt seem to be their id anymore by the time it makes it back to them. Cry / sob / argh! lol

@RPC function CLIENTSendUserName(username : String, id : NetworkViewID){

	clientList.Add(username);



	var go : GameObject[] = GameObject.FindObjectsOfType(GameObject);

	for(var g : GameObject in go){

		g.SendMessage("UpdateClientList", clientList, SendMessageOptions.DontRequireReceiver);

	}

	

	networkView.RPC("CLIENTReturnUserName", RPCMode.Others, userName, id);

}





@RPC function CLIENTReturnUserName(username : String, id : NetworkViewID){

	//Debug.Log(id.ToString());

	//ids = id.owner;

	if(id.owner == true){

		clientList.Add(username);

	}

	var go : GameObject[] = GameObject.FindObjectsOfType(GameObject);

	for(var g : GameObject in go){

		g.SendMessage("UpdateClientList", clientList, SendMessageOptions.DontRequireReceiver);

	}

}

I’m not sure why you’re looping through every object to update the client list, that seems terribly inefficient.

Another thing, every RPC can have a NetworkMessageInfo struct that you can utilize, instead of passing around NetworkView ID’s. Might help.

@RPC
function MyRPC(info : NetworkMessageInfo){
	var sender : NetworkPlayer = info.sender;
}