Network Client Connecting with different Maps

Hey guys,

Does anyone know whether there is a way to get the data like the comment from a registered host/server when connenting to its ip? I need that because the comment is the name of the map which is needed in the script which let the player connect to the server.

Btw. If someone knows an easier way to send the name of the map to the client so that i can load the right scene then answered that.

I hope someone can help me with my problem.

If you have any knowledge of PHP & SQL you can store your data in a Database and get it with the Unity’s WWW & WWWForm classes.
Just send a form to your PHP page that will search your database for the requested information and return as a string in www.text (www as an WWW object).

So I was making it like I said in my answer. After a little while I found out that this is not working. It works when the Server and the client is the same computer. That’s why I didn’t noticed it until I made a web Player Build. Now I found a way that works:

if(Network.isClient){
for (var myElement in multiplayerScript.sortedHostList)
    						{
    							var element=multiplayerScript.hostData[myElement];
  								if(element.ip[0]==PlayerPrefs.GetString("connectIP")){
    									if(element.comment=="FPSscenetest"){
           		 			     			Map1=true; Map2=false;
           			    		 			}
           			     				if(element.comment=="Level2test"){
           			     					Map1=false; Map2=true;
           			     			}
    								}
    						}
          		if(Map1)
          			Application.LoadLevel(1);
          		if(Map2)
          			Application.LoadLevel(2);
    			}
}

This is the interesting part. Important is also that the server sets the MapName as the comment when he registers himself at the masterserver.

Another thing is that sortedHostlist is just what you think. It’s a sorted List of the servers.

The usual way is to send an RPC call with the level to load. There are unlimited ways how you can implement networking, so it’s hard to give suggestions. If you use buffered RPCs and Network.Instantiate in your game (as shown by the documentation) you simply send a loadLevel RPC right at start of the server.

For more details see the Network LevelLoad tutorial