- Home /
Networkmanager errors and gui to small
Hello, I have followed Cg_cookie's tutorial on networking, But first i noticed that my GUI did not show up and I was never able to try if it worked because i always got errors. If someone here got time it would be nice if you could help me. Here's the errors [Note: I'm not hundered if I wrote it right because I never tried it because of errors]
//errors
Assets/Networking/NetworkManagerScript.js(49,10): BCE0044: expecting (, found 'OnServerInitialized'.
Assets/Networking/NetworkManagerScript.js(49,31): UCE0001: ';' expected. Insert a semicolon at the end.
Assets/Networking/NetworkManagerScript.js(51,15): BCE0043: Unexpected token: :.
Assets/Networking/NetworkManagerScript.js(51,16): UCE0001: ';' expected. Insert a semicolon at the end.
Assets/Networking/NetworkManagerScript.js(56,12): BCE0044: expecting (, found 'OnMasterServerEvent'.
Assets/Networking/NetworkManagerScript.js(56,32): BCE0043: Unexpected token: mse.
Assets/Networking/NetworkManagerScript.js(56,54): UCE0001: ';' expected. Insert a semicolon at the end.
Assets/Networking/NetworkManagerScript.js(62,12): BCE0044: expecting (, found 'OnGUI'.
Assets/Networking/NetworkManagerScript.js(62,19): UCE0001: ';' expected. Insert a semicolon at the end.
Assets/Networking/NetworkManagerScript.js(81,1): BCE0044: expecting }, found ''.
And here's the tutorial http://vimeo.com/33996023
And here's the Code I tried to copy
var playerPrefab:GameObject;
var SpawnObject: Transform;
var gameName:String = "Trackants";
private var refreshing:boolean;
private var hostData : HostData[];
private var btnX : float;
private var btnY : float;
private var btnW : float;
private var btnH : float;
function Start(){
bntX = Screen.width * 0.05;
bntY = Screen.height * 0.05;
bntW = Screen.width * 0.1;
bntH = Screen.width * 0.1;
}
function startServer(){
Network.InitializeServer(32,25000, !Network.HavePublicAddress);
MasterServer.RegisterHost(gameName, "Trackant game", "This is a co-op game!");
}
function refreshHostList(){
MasterServer.RequireHostList(gameName);
refreshing = true;
Debug.Log(MasterServer.PollHostList().Length);
}
function Update(){
if(refreshing){
if (MasterServer.PollHostList().Length <0){
refreshing = false;
Debug.Log(MasterServer.PollHostList().Length);
hostData=MasterServer.PollHostList();
}
}
}
function SpawnPlayer(){
Network.Instantiate(playerPrefab, spawnObject.position, Quaternion.identity,0);
}
function OnConnectedToServer(){
spawnPlayer();
//Messages
function OnServerInitialized(){
Debug.Log("Server initialized!");
spawnPlayer():
}
function OnMasterServerEvent(mse:MasterServerEvent){
if(mse == MasterServerEvent.RegistrationSucceeded){
Debug.Log("Redistered Server!");
}
}
function OnGUI(){
if(Network.isClient && !Network.isServer ){
if(GUI.Button(Rect(btnX, btnY, btnW, btnH), "Start server")){
Debug.log("starting server");
startServer();
}
if(GUI.Button(Rect(btnX, btnY * 1.2 + btnH, btnW, btnH), "Refresh hosts")){
Debug.log ("refreshing");
refreshHostList();
}
if(hostData){
for(var i:int = 0; i<hostData.lenght; int++){
if (GUI.Button(Rect(btnX *1.5 + btnW, btnY*1.2 + (btnH * i), btnW*3, btnH*.5), hostData[i].gameName));
Network.Connect(hostData[i]);
}
}
}
}
There are just simple errors like bracket missing or typos and nothing much.
$$anonymous$$g.
There is no closing bracket to function OnConnectedToSer ver() function which should be placed after spawnPlayer(); line in that function.
Under this function
function OnServerInitialized(){ Debug.Log("Server initialized!"); spawnPlayer(): }
there should be semicolon ';' after spawnPlayer() and not ':'
Find remaining error that are just like the ones specified above.
Best luck!
Your answer
Follow this Question
Related Questions
Why is networkbehaviour underlined in green? 1 Answer
Error when I try to run the build in tutorial (roll a ball, tanks, and etc.) 0 Answers
Error in my script i don't understand. 0 Answers
How do I change the text of a gui image text 1 Answer
Unity Gui lable problem with showing js var using C# 2 Answers