- Home /
The question is answered, right answer was accepted
error javasript
i get this error: Assets/scripts/Network.js(71,22): BCE0044: expecting ;, found 'i'. Assets/scripts/Network.js(71,53): BCE0043: Unexpected token: ). Assets/scripts/Network.js(73,17): BCE0043: Unexpected token: if. Assets/scripts/Network.js(73,96): UCE0001: ';' expected. Insert a semicolon at the end.
i will show the code where the error is if you need the full code then please ask in a comment.
var typeName : String = "UniqueGameName";
var gameName : String = "RoomName";
var hostlist : HostData[];
var _NetworkView : NetworkView;
var madeaserver : boolean = false;
var msEvent : MasterServerEvent;
var hostdata : HostData;
var newPlayer : NetworkPlayer;
function Start () {
}
function Update () {
}
private function RefreshHostList()
{
MasterServer.RequestHostList(typeName);
}
function OnMasterServerEvent()
{
if (msEvent == MasterServerEvent.HostListReceived)
hostlist = MasterServer.PollHostList();
}
private function JoinServer()
{
Network.Connect(hostData);
}
function OnPlayerConnected ()
{
_NetworkView.RPC("GetNetworkPlayer", RPCMode.AllBuffered, newPlayer);
}
function OnConnectedToServer()
{
Debug.Log("Joined Server");
}
private function StartServer()
{
Network.InitializeServer(4, 25000, !Network.HavePublicAddress());
MasterServer.RegisterHost(typeName, gameName);
}
function OnServerInitialized()
{
Debug.Log("Server Initiliazed");
madeaserver = true;
}
function OnGUI()
{
if (!Network.isClient && !Network.isServer)
{
if (GUI.Button(new Rect(100, 100, 250, 100), "Start Server"))
{
StartServer();
}
}
if (GUI.Button(new Rect(100, 250, 250, 100), "Refresh Hosts"))
RefreshHostList();
if (hostList != null)
{
for (int i = 0; i < hostList.Length; i++)
{
if (GUI.Button(new Rect(400, 100 + (110 * i), 300, 100), hostList[i].gameName))
JoinServer(hostList[i]);
}
}
}
which line pointing this error? Is this script is Network.js ??
Not that it's related, but the name hostList
is kinda mis-leading - Since you're accessing the Length
property, this tells it's an array, not a list (where you have the Count
property) - Better name it hosts
ins$$anonymous$$d.
The snippet you showed seems error-clean to me, could you show the rest?
yes i will edit my post to show the whole list and thak you for pointing out on hoslist.
its updated
in the error log, the first lines you get should be the exact location of the error, while the rest show the methods that the error happened to be inside. Are you sure the error isn't inside one of your functions JoinServer
, RefreshHostList
or StartServer
? or maybe even something within those?
Answer by vexe · Sep 14, 2013 at 07:36 AM
This is definitely weird. However here's what you can do about it: first comment out everything inside of OnGUI
See if the error is gone, if so then your guy isn't in OnGUI, if not, move on - Uncomment the first outer if, see if there's any errors, then the inner one, then move on to the 2nd outer if, etc. Till you find what's the error.
Will try this if i can go on the pc
Thanks for taking the time to help me Already a thumb up for the afford :)
I Did this and i got the errors away by simply making an i var thank you for your help i will close this topic. I now have a couple new errors i will make a new post for that
ohh yes, I should have seen that. The syntax you wrote it was C#, for JS it's var i not int i. Glad you sort it out :)
I translated a c# script to javascript and forgot to change that :)
Follow this Question
Related Questions
How do I change the text of a gui image text 1 Answer
What's wrong with eval()? 1 Answer
Health not counting down? 1 Answer
Issue with OnTriggerEnter. 1 Answer
expecting (, found 'Update' and unexpected char: 0x200B. 2 Answers