Need BOO help
Can anyone take a gander at this and tell me why it cant create its own server and join it??
better?
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")
