- Home /
Question by
PogyManTV · Jul 03, 2015 at 01:54 PM ·
networkingmanageroverlappingservers
Network servers are overlapping in the multiplayer menu
Hi i have a problem that makes my game look sily in multiplayer menu the probem is that if my game have multiple servers hosted the servers in the multiplayer menu are overlapping[GUI overlapping] i looked to the networkmanager script try to search something on the web with no result :/ so iam turning to the forum trying to get some answer (: here is the code:
var playerPrefab : GameObject;
var spawnObject : Transform;
var gameName : String = "level1";
private var refreshing : boolean = false;
private var hostData : HostData[];
function OnGUI () {
if(!Network.isClient && !Network.isServer) {
GUI.Box(Rect(Screen.width/3.5f,Screen.height/45 + 60,750,595),"ThugLifeMultiplayer V0.02");
GUI.Box(Rect(Screen.width/2.55f,Screen.height/3 + 60,450,195),"List of playable servers:");
if (GUI.Button(Rect(Screen.width/2,Screen.height/4.5f,150,45),"Create a Server")) {
startServer();
audio.Play();
}
if (GUI.Button(Rect(Screen.width/2,Screen.height/4 + 30,150,45),"Search for servers")) {
Debug.Log("Refreshed");
refreshHostList();
audio.Play();
}
if(hostData) {
for(var i:int = 0; i<hostData.length; i++) {
if(GUI.Button(Rect(Screen.width/2.12f,Screen.height/2.65 + 60,280,25),hostData[i].gameName)) {
Network.Connect(hostData[i]);
}
}
}
}
}
function OnFailedToConnect(error : NetworkConnectionError){
Application.LoadLevel(1);
}
function OnDisconnectedFromServer(info : NetworkDisconnection){
Application.LoadLevel(1);
}
function Update () {
if(refreshing) {
if(MasterServer.PollHostList().Length > 0) {
refreshing = false;
Debug.Log(MasterServer.PollHostList().Length);
hostData = MasterServer.PollHostList();
}
}
}
function startServer () {
Network.InitializeServer(32,25001, !Network.HavePublicAddress);
MasterServer.RegisterHost(gameName, "ThugLifeSERVER Map:JiliensValley", " click to connect");
}
function OnServerInitialized () {
Debug.Log("server initialized");
spawnPlayer();
}
function OnConnectedToServer () {
spawnPlayer();
}
function spawnPlayer () {
Network.Instantiate(playerPrefab, spawnObject.position, Quaternion.identity, 0);
}
function OnMasterServerEvent(mse:MasterServerEvent) {
if(mse == MasterServerEvent.RegistrationSucceeded) {
Debug.Log("Server Registered");
}
}
function refreshHostList () {
MasterServer.RequestHostList(gameName);
refreshing = true;
}
function OnPlayerDisconnected (player : NetworkPlayer)
{
Debug.Log("Server destroying player");
Network.RemoveRPCs(player, 0);
Network.DestroyPlayerObjects(player);
}
And it looks lie this:
And here is what iam want it to look like :
problem.jpg
(44.8 kB)
servers.jpg
(56.6 kB)
Comment