Search Unity

Error Parsing OMG why

Discussion in 'Multiplayer' started by jf3000, Jun 29, 2014.

  1. jf3000

    jf3000

    Joined:
    Dec 31, 2013
    Posts:
    166
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class BL2Room : Photon.MonoBehaviour {
    5.  
    6. private  string roomName = "Test";
    7. private RoomInfo[] roomsList;
    8.  
    9.  
    10. void OnGUI()
    11. {
    12.     if (!PhotonNetwork.connected) {
    13.                         GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
    14.                 } else if (PhotonNetwork.room == null) {
    15.                         // Create Room
    16.                         if (GUI.Button (new Rect (100, 100, 250, 100), "Start Server"))
    17.                                 PhotonNetwork.CreateRoom (roomName + Guid.NewGuid ().ToString ("N"), true, true, 5);
    18.                 }{
    19.         // Join Room
    20.             if (roomsList != null)
    21.         {
    22.                 for(int i = 0; i < roomList.Length; i++)
    23.             {
    24.                 if (GUI.Button(new Rect(100, 250 + (110 * i), 250, 100), "Join " + roomsList[i].name))
    25.                     PhotonNetwork.JoinRoom(roomsList[i].name);
    26.             }
    27.         }
    28.     }
    29. }
    30.  
    31. void OnReceivedRoomListUpdate()
    32. {
    33.     roomsList = PhotonNetwork.GetRoomList();
    34. }
    35. void OnJoinedRoom()
    36. {
    37.     Debug.Log("Connected to Room");
    38. }
    39. }
    40.    
    Updated 4th July
     
    Last edited: Jul 3, 2014
  2. Turbo420

    Turbo420

    Joined:
    Jun 24, 2014
    Posts:
    61
    Come on man lol. Put a } on line 38 it will fix it lol :D
     
  3. jf3000

    jf3000

    Joined:
    Dec 31, 2013
    Posts:
    166
    OMG..... Someone slap me. Thanks Turbo. But alas I am still getting a parser error this time related to BL2Room.cs(1,13): error CS8025: Parsing error
     
  4. Turbo420

    Turbo420

    Joined:
    Jun 24, 2014
    Posts:
    61
    you may need to use photon. MonoBehaviour. later man lol
    Code (CSharp):
    1. using UnityEngine
    2. using System.Collections;
    3.  
    4. private  string roomName = "Test";
    5. private RoomInfo[] roomsList;
    6. public class Youaremissingthislol : MonoBehaviour {
    7.     void OnGUI()
    8.     {
    9.         if (!PhotonNetwork.connected)
    10.         {
    11.             GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
    12.         }
    13.         else if (PhotonNetwork.room == null)
    14.         {
    15.             // Create Room
    16.             if (GUI.Button(new Rect(100, 100, 250, 100), "Start Server"))
    17.                 PhotonNetwork.CreateRoom(roomName + Guid.NewGuid().ToString("N"), true, true, 5);
    18.          
    19.             // Join Room
    20.             if (roomsList != null)
    21.             {
    22.                 for (int i = 0; i &lt; roomsList.Length; i++)
    23.                 {
    24.                     if (GUI.Button(new Rect(100, 250 + (110 * i), 250, 100), "Join " + roomsList[i].name))
    25.                         PhotonNetwork.JoinRoom(roomsList[i].name);
    26.                 }
    27.             }
    28.         }
    29.     }
    30.  
    31.     void OnReceivedRoomListUpdate()
    32.     {
    33.         roomsList = PhotonNetwork.GetRoomList();
    34.     }
    35.     void OnJoinedRoom()
    36.     {
    37.         Debug.Log("Connected to Room");
    38.     }
     
  5. jf3000

    jf3000

    Joined:
    Dec 31, 2013
    Posts:
    166
    Updated the code above, now getting these 3 errors

    Code (CSharp):
    1. BL2Room.cs(25,72): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
    Code (CSharp):
    1. BL2Room.cs(25,72): error CS1525: Unexpected symbol `;', expecting `)', or `,'
    Code (CSharp):
    1. BL2Room.cs(42,1): error CS8025: Parsing error
     
  6. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    You dont close your class with } ?
     
  7. jf3000

    jf3000

    Joined:
    Dec 31, 2013
    Posts:
    166
    Yes I had one missing but I am getting errors with these 2

    Code (CSharp):
    1. BL2Room.cs(22,72): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
    Code (CSharp):
    1. BL2Room.cs(22,72): error CS1525: Unexpected symbol `;', expecting `)', or `,'
    Both referring to this line


    Code (CSharp):
    1. for (int i = 0; i &lt; roomsList.Length; i++)
     
  8. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    You got a ; too much.

    Code (csharp):
    1.  
    2. for(int i = 0; i < roomList.Length; i++)
    3.  
    Its 101 programming :D
     
  9. jf3000

    jf3000

    Joined:
    Dec 31, 2013
    Posts:
    166
    Thanks BFGames.

    New errors

    Code (CSharp):
    1. BL2Room.cs(17,102): error CS0103: The name `Guid' does not exist in the current context


    refers too:

    Code (CSharp):
    1. PhotonNetwork.CreateRoom (roomName + Guid.NewGuid ().ToString ("N"), true, true, 5);


    ----------

    Code (CSharp):
    1. BL2Room.cs(17,79): error CS1502: The best overloaded method match for `PhotonNetwork.CreateRoom(string, bool, bool, int)' has some invalid arguments


    refers too:

    Code (CSharp):
    1. BL2Room.cs(17,79): error CS1502: The best overloaded method match for `PhotonNetwork.CreateRoom(string, bool, bool, int)' has some invalid arguments


    ----------

    Code (CSharp):
    1. BL2Room.cs(17,79): error CS1503: Argument `#1' cannot convert `object' expression to type `string'


    refers too:

    Code (CSharp):
    1. BL2Room.cs(17,79): error CS1502: The best overloaded method match for `PhotonNetwork.CreateRoom(string, bool, bool, int)' has some invalid arguments


    ------------

    Code (CSharp):
    1. BL2Room.cs(22,52): error CS0103: The name `roomList' does not exist in the current context


    refers too:

    Code (CSharp):
    1. for(int i = 0; i < roomList.Length; i++)


    Thank you to all that have helped me so far.
     
  10. Cjreek

    Cjreek

    Joined:
    Apr 23, 2013
    Posts:
    33
    Please learn the basics/syntax of C# and don't copy just random code. We can't/won't correct every little syntax error you make...
     
  11. jf3000

    jf3000

    Joined:
    Dec 31, 2013
    Posts:
    166
    Gee Cjreek thanks for your harsh comments. But I dont need to listen to what you need to say.

    Code has been completed.
     
  12. Cjreek

    Cjreek

    Joined:
    Apr 23, 2013
    Posts:
    33
    My post wasn't covered in flowers, that's right, but if you are such a beginner at programming (which is okay - everybody once was a beginner) that you can't handle those compiler messages yourself then you won't get very far with your game/coding. That's just a fact.

    So I advise you to learn some programming basics. And also I'm not sure if you even tried to understand those messages yourself. You should try to understand them and even if you don't quite understand a message you can try a little bit and/or google how the syntax for for-loops (for example) in C# is.

    If you tried to understand them and tried to solve the problem on your own (internet research included) and you are still failing than you should ask the forum.

    But as long as you don't understand most of those compiler messages you probably need to improve you programming skills.
     
    landon912 likes this.
  13. Yukichu

    Yukichu

    Joined:
    Apr 2, 2013
    Posts:
    420
    I actually think you should listen to what CJreek has to say. You basically made a bunch of posts about helping you find syntax errors. The next time you forget a brace, are you going to come to forums again to ask for help? I think you need to determine the issue yourself because it will help build skills so the next time you forget a brace, you won't spend hours wondering why everything is breaking... you'll just notice a missing brace and add it.
     
    landon912 likes this.