Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Sep 14, 2013 at 09:16 AM by mirkobon for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by mirkobon · Sep 14, 2013 at 07:16 AM · javascripterror

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]);
             }
         }
  }
Comment
Add comment · Show 7
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DeveshPandey · Sep 14, 2013 at 07:20 AM 0
Share

which line pointing this error? Is this script is Network.js ??

avatar image mirkobon · Sep 14, 2013 at 07:22 AM 0
Share

yes it is Network.js Lines: 71,73

avatar image vexe · Sep 14, 2013 at 07:24 AM 0
Share

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?

avatar image mirkobon · Sep 14, 2013 at 07:27 AM 0
Share

yes i will edit my post to show the whole list and thak you for pointing out on hoslist.

its updated

avatar image vexe · Sep 14, 2013 at 07:28 AM 0
Share

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?

Show more comments

1 Reply

  • Sort: 
avatar image
1
Best Answer

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.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mirkobon · Sep 14, 2013 at 07:39 AM 0
Share

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 :)

avatar image mirkobon · Sep 14, 2013 at 09:14 AM 0
Share

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

avatar image vexe · Sep 14, 2013 at 09:19 AM 0
Share

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 :)

avatar image mirkobon · Sep 14, 2013 at 09:23 AM 0
Share

I translated a c# script to javascript and forgot to change that :)

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges