Code (CSharp): using UnityEngine; using System.Collections; public class BL2Room : Photon.MonoBehaviour { private string roomName = "Test"; private RoomInfo[] roomsList; void OnGUI() { if (!PhotonNetwork.connected) { GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ()); } else if (PhotonNetwork.room == null) { // Create Room if (GUI.Button (new Rect (100, 100, 250, 100), "Start Server")) PhotonNetwork.CreateRoom (roomName + Guid.NewGuid ().ToString ("N"), true, true, 5); }{ // Join Room if (roomsList != null) { for(int i = 0; i < roomList.Length; i++) { if (GUI.Button(new Rect(100, 250 + (110 * i), 250, 100), "Join " + roomsList[i].name)) PhotonNetwork.JoinRoom(roomsList[i].name); } } } } void OnReceivedRoomListUpdate() { roomsList = PhotonNetwork.GetRoomList(); } void OnJoinedRoom() { Debug.Log("Connected to Room"); } } Updated 4th July
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
you may need to use photon. MonoBehaviour. later man lol Code (CSharp): using UnityEngine using System.Collections; private string roomName = "Test"; private RoomInfo[] roomsList; public class Youaremissingthislol : MonoBehaviour { void OnGUI() { if (!PhotonNetwork.connected) { GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString()); } else if (PhotonNetwork.room == null) { // Create Room if (GUI.Button(new Rect(100, 100, 250, 100), "Start Server")) PhotonNetwork.CreateRoom(roomName + Guid.NewGuid().ToString("N"), true, true, 5); // Join Room if (roomsList != null) { for (int i = 0; i < roomsList.Length; i++) { if (GUI.Button(new Rect(100, 250 + (110 * i), 250, 100), "Join " + roomsList[i].name)) PhotonNetwork.JoinRoom(roomsList[i].name); } } } } void OnReceivedRoomListUpdate() { roomsList = PhotonNetwork.GetRoomList(); } void OnJoinedRoom() { Debug.Log("Connected to Room"); }
Updated the code above, now getting these 3 errors Code (CSharp): BL2Room.cs(25,72): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement Code (CSharp): BL2Room.cs(25,72): error CS1525: Unexpected symbol `;', expecting `)', or `,' Code (CSharp): BL2Room.cs(42,1): error CS8025: Parsing error
Yes I had one missing but I am getting errors with these 2 Code (CSharp): BL2Room.cs(22,72): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement Code (CSharp): BL2Room.cs(22,72): error CS1525: Unexpected symbol `;', expecting `)', or `,' Both referring to this line Code (CSharp): for (int i = 0; i < roomsList.Length; i++)
Thanks BFGames. New errors Code (CSharp): BL2Room.cs(17,102): error CS0103: The name `Guid' does not exist in the current context refers too: Code (CSharp): PhotonNetwork.CreateRoom (roomName + Guid.NewGuid ().ToString ("N"), true, true, 5); ---------- Code (CSharp): 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): BL2Room.cs(17,79): error CS1502: The best overloaded method match for `PhotonNetwork.CreateRoom(string, bool, bool, int)' has some invalid arguments ---------- Code (CSharp): BL2Room.cs(17,79): error CS1503: Argument `#1' cannot convert `object' expression to type `string' refers too: Code (CSharp): BL2Room.cs(17,79): error CS1502: The best overloaded method match for `PhotonNetwork.CreateRoom(string, bool, bool, int)' has some invalid arguments ------------ Code (CSharp): BL2Room.cs(22,52): error CS0103: The name `roomList' does not exist in the current context refers too: Code (CSharp): for(int i = 0; i < roomList.Length; i++) Thank you to all that have helped me so far.
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...
Gee Cjreek thanks for your harsh comments. But I dont need to listen to what you need to say. Code has been completed.
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.
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.