Need BOO help

Posts 1–6 of 6 · Page 1 of 1
Need BOO help
Can anyone take a gander at this and tell me why it cant create its own server and join it??


Code:
/*
import UnityEngine

class NetworkManager (MonoBehaviour): 
	
	typeName = "UniqueGameName"
	gameName = "RoomName"
	hostlist as (HostData)
	
	def StartServer() as void:
		useNat as bool = (not Network.HavePublicAddress())
		Network.InitializeServer(4, 5000, useNat)	
		MasterServer.RegisterHost(typeName, gameName)

	def OnServerInitialized() as void:
		print("Server on.")
		print(hostlist)
	
	def RefreshHostList() as void:
		MasterServer.ClearHostList()
		MasterServer.RequestHostList("Hostlist")
		
	def OnMasterServerEvent(msEvent as MasterServerEvent ) as void:
		if (msEvent == MasterServerEvent.HostListReceived):
        	hostList = MasterServer.PollHostList()
        	print(hostList)
	
	def JoinServer(hostData as HostData) as void:
		Network.Connect(hostData)
	
	def OnConnectedToServer() as void:
		print("Server Joined")
	
		
	def Awake() as void:
		RefreshHostList()
		print("Host list refreshed")
		print(MasterServer.PollHostList().Length)
	
		
	def OnGUI() as void :
		if (not Network.isClient and not Network.isServer):
			GUI.Label(Rect(300,10,400,40),"Server List: ")
			if (GUI.Button(Rect(0, 0, 250, 100),"Start Server")):
				StartServer()
				print(hostlist)
			if (GUI.Button(Rect(0, 150, 250, 100), "Refresh Hosts")):
            	RefreshHostList()
            	print("Server list refreshed")
           	if (hostlist is not null):
           		for i in range(0, hostlist.Length): 
           			if (GUI.Button(Rect(200, 100 + (110 * i), 300, 100), hostlist[i].gameName)):
           				JoinServer(hostlist[i])
           				print("Server found and link created")
			else:
				GUI.Label(Rect(300,60,400,100),"No servers started")
better?
Not taking any ganders.

I do not trust.
Quote Originally Posted by Anti View Post
Not taking any ganders.

I do not trust.
ok.... is this better?
Quote Originally Posted by utherson601 View Post
ok.... is this better?
Yeah. It looks good. I do not understand the issue.
Expected scenario:
1. Find all available servers and store their data into hostList
2. Enable the player to choose from those servers (GUI buttons) or create their own server.
3. If no server is available, no button is shown, and a label saying "No server started" is shown.

Output scenario:
During startup:
1. Buttons (Start server) and (Join Server) is shown.
2. No servers are found.
Upon pressing (Start server):
1. Server is initiated on port 25000.
2. End script, jump to next script (log in)

Problems:
1. Masterserver cannot register the game/ no game is registered on masterserver. I changed the ipaddress and port from the default to 127.0.0.1:25000 and "hamachi ip":25000 after starting them but to no avail.
2. No server is shown on another instance of Unity Player after I press (Start server).
Can you even connect to 25000 if 25000 is bound locally?
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us