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 /
avatar image
0
Question by jlittlewood · Feb 26, 2011 at 07:20 PM · errorparsingcs8025cs1519

unity 3d - c# scripting problems

ok so im not realy a c# scripter and im also new to unity and i downloaded server fox to try and start a multiplayer game and i was following a tutorial so i got a script and i have 2 errors and i dont have a clue what they meen or how to fix the

here is the script :-

using UnityEngine;

using System; using System.Collections; // for using hash tables using System.Security.Permissions; // for getting the socket policy using SmartFoxClientAPI; // to setup SmartFox connection using SmartFoxClientAPI.Data; // necessary to access the room resource

public class gui_Login : MonoBehaviour {

// smartFox variables private SmartFoxClient smartFox; private string serverIP = "127.0.0.1"; private int serverPort = 9339; // default = 9339 public string zone = "city"; public bool debug = true;

// variables used in script private string statusMessage = ""; private string username = "";

void Awake() { Application.runInBackground = true; // Let the application be running while the window is not active.

 // Create SmartFox connection if not already available
 if ( SmartFox.IsInitialized() ) {
     Debug.Log("SmartFox is already initialized, reusing connection");
     smartFox = SmartFox.Connection;
 } else {
     if( Application.platform == RuntimePlatform.WindowsWebPlayer ) {
       // Only set this for the webplayer, it breaks pc standalone
         // See http://answers.unity3d.com/questions/25122/ for details
         Security.PrefetchSocketPolicy(serverIP, serverPort);
     }
     try {
         Debug.Log("Starting new SmartFoxClient");
         smartFox = new SmartFoxClient(debug);
         smartFox.runInQueueMode = true;
     } catch ( Exception e ) {
         Debug.Log(e.ToString());
     }
 }

 // Register callback delegates, before callling Connect()
 SFSEvent.onConnection += OnConnection;
 SFSEvent.onConnectionLost += OnConnectionLost;
 SFSEvent.onLogin += OnLogin;
 SFSEvent.onRoomListUpdate += OnRoomList;
 SFSEvent.onDebugMessage += OnDebugMessage;
 //SFSEvent.onJoinRoom += OnJoinRoom;        // We will not join a room in this level

 Debug.Log("Attempting to connect to SmartFoxServer");
 smartFox.Connect(serverIP, serverPort);  

}

void FixedUpdate() { smartFox.ProcessEventQueue(); }

void OnGUI() {

 // server IP in bottom left corner
 GUI.Label(new Rect(10, Screen.height-25, 200, 24), "Server: " + serverIP);

 // quit button in bottom right corner
 if ( Application.platform != RuntimePlatform.WindowsWebPlayer ) {         
     if ( GUI.Button(new Rect(Screen.width-150, Screen.height - 50, 100, 24), "Quit") ) {
         smartFox.Disconnect();
         UnregisterSFSSceneCallbacks();
         Application.Quit();
     }
 }

 // Show login fields if connected and reconnect button if disconnect
 if (smartFox.IsConnected()) {
     GUI.Label(new Rect(10, 116, 100, 100), "Username: ");
     username = GUI.TextField(new Rect(100, 116, 200, 20), username, 25);
     if ( GUI.Button(new Rect(100, 166, 100, 24), "Login")  || (Event.current.type == EventType.keyDown && Event.current.character == '\n')) {
         smartFox.Login(zone, username, "");
     }
 } else {
     if ( GUI.Button(new Rect(100, 166, 100, 24), "Reconnect")  || (Event.current.type == EventType.keyDown && Event.current.character == '\n')) {
     Application.LoadLevel("sc_City");
     }
 }

 // Draw box for status messages, if one is given
 // Contains some logic to parse message of multiple lines if necessary
 if (statusMessage.Length > 0)
 {
     int boxLength = 61;       // define length of status box
     int messageLength = statusMessage.Length;   // get length of status message
     string originalMessage = statusMessage;  // copy message in to work string
     string formattedMessage = "";            // define output message string
     int i = 0;
     while (i + boxLength < messageLength)      // iterate and add newline until over length
     {
         formattedMessage = formattedMessage + originalMessage.Substring(i,boxLength) + "\n";
         i = i + boxLength;
     }
     // add last piece of original message
     formattedMessage = formattedMessage + originalMessage.Substring(i,  boxLength - (i + boxLength - messageLength));
     // draw status box with message
     GUI.Box (new Rect (Screen.width - 420,10,400,48), formattedMessage);
 }

}

private void UnregisterSFSSceneCallbacks() { // This should be called when switching scenes, so callbacks from the backend do not trigger code in this scene SFSEvent.onConnection -= OnConnection; SFSEvent.onConnectionLost -= OnConnectionLost; SFSEvent.onLogin -= OnLogin; SFSEvent.onRoomListUpdate -= OnRoomList; SFSEvent.onDebugMessage -= OnDebugMessage; //SFSEvent.onJoinRoom -= OnJoinRoom; }

void OnConnection(bool success, string error) { if ( success ) { SmartFox.Connection = smartFox; statusMessage = "Connected to SmartFox Server"; Debug.Log(statusMessage); } else { statusMessage = "Can't connect! " + error; Debug.Log(statusMessage); } }

void OnConnectionLost() { statusMessage = "Connection lost / no connection to server"; }

public void OnDebugMessage(string message) { Debug.Log("[SFS DEBUG] " + message); }

public void OnLogin(bool success, string name, string error) { if ( success ) { statusMessage = "Login for user \"" + name + "\" successful."; // Lets wait for the room list } else { // Login failed - lets display the error message sent to us statusMessage = "Login error: " + error; } }

/*
// We will not join a room in this level, the NetworkController in the next scene will take care of that void OnJoinRoom(Room room) { Debug.Log("Room " + room.GetName() + " joined successfully"); smartFox.SendPublicMessage(smartFox.myUserName + " has joined"); // We can now move on to the next level UnregisterSFSSceneCallbacks(); Application.LoadLevel("sc_City"); }

/

void OnRoomList(Hashtable roomList) { try { foreach (int roomId in roomList.Keys) { Room room = (Room)roomList[roomId]; if (room.IsPrivate()) { Debug.Log("Room id: " + roomId + " has name: " + room.GetName() + "(private)"); } Debug.Log("Room id: " + roomId + " has name: " + room.GetName()); } // Users always have to be in a room, but we'll do that in the next level /* if (smartFox.GetActiveRoom() == null) { smartFox.JoinRoom("Central Square"); }*/ UnregisterSFSSceneCallbacks Application.LoadLevel("sc login");

 }

{ catch (Exception e) Debug.Log("Room list error: "+e.Message+" "+e.StackTrace); }

here are the errors :-

  1. Assets/scripts/GUI_login.cs(178,44): error CS1519: Unexpected symbol `sc login' in class, struct, or interface member declaration

  2. Assets/scripts/GUI_login.cs(181,9): error CS8025: Parsing error

as i said i am a complete novice and i dont have a clue how to fix these errors or what they meen so any help that anyone counld give would be welcome :) Thankyou (in advance).

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Jesse Anders · Feb 27, 2011 at 02:30 AM

Here's a couple of things you can do that will make it easier to help:

  1. Edit your post and fix the formatting. (I think the code formatting doesn't always work correctly, but if you post and see that it's wrong, you should at least try to fix it.)

  2. In addition to posting the script in its entirety, also post the exact lines that are generating the errors, and/or add easy-to-find comments to the script showing where these lines are.

Comment
Add comment · Show 2 · 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 jlittlewood · Feb 27, 2011 at 03:44 PM 0
Share

Ok and by the way thanks for that these are the lines that are causeing the trouble:

Application.LoadLevel("sc login");

and

catch (Exception e) Debug.Log("Room list error: "+e.$$anonymous$$essage+" "+e.StackTrace);

avatar image Jesse Anders · Feb 27, 2011 at 11:06 PM 0
Share

I don't know what UnregisterSFSSceneCallbacks is, but it doesn't look like a complete statement. Also, it looks like you have an extra bracket before your 'catch' statement.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Script Errors with C# 1 Answer

Jukebox parsing error 2 Answers

CS8025 parsing error, can't find, halp ! 0 Answers

Errors CS1525 and CS8025.... 1 Answer

CS8025 Error (Parsing Error) 1 Answer


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