Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 BrennanVargas1 · Jul 18, 2011 at 03:21 AM · networkingcs1525cs1519

Multiplayer Networking Problems

Alright so im basically working on a script and temporarily i want to use GetString and SetString and so forth to do this and i am but ive ran into a couple of problems and these problem didnt exists until i tried doing so.

Im getting this errors...

 Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(45,144): error CS1525: Unexpected symbol `{'
 
 Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(51,40): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
 
 Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(53,38): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
 
 Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(55,46): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration
 
 Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(55,73): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration
 
 Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(57,48): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
 
 Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(57,60): error CS1519: Unexpected symbol `,' in class, struct, or interface member declaration
 
 Assets/My Assets/Scripts/Network/MultiPlayer/Connect.cs(57,73): error CS1519: Unexpected symbol `)' in class, struct, or interface member declaration


this is my script

125

125

using UnityEngine; using System.Collections; using System;

public class Connect : MonoBehaviour {

 public int connectToIP = "127.0.0.1";
     public int connectPort = 25000;
     
     public string UserName;
     public string passwordToEdit = "My Password";
     public bool isUserNameCorrect;
     public bool isPasswordCorrect;
 
 
 void  OnGUI (){
     
 
     if (Network.peerType == NetworkPeerType.Disconnected){
     
         GUILayout.Label("Connection status: Disconnected");
         
         //connectToIP = GUILayout.TextField(connectToIP, GUILayout.MinWidth(100));
         //connectPort = int.Parse(GUILayout.TextField(connectPort.ToString()));
         
         if(GUILayout.TextField("UserName")){
             if(UserName = PlayerPrefs.GetString(UserName)){
                 isUserNameCorrect = true;
             }
         }
         
         if(passwordToEdit = GUI.PasswordField(new Rect(Screen.width / 2, (Screen.height / 2) - 50, 200, 20), passwordToEdit,"*"[0], 25){
             if(passwordToEdit = PlayerPrefs.GetString(passwordToEdit)){
                 isPasswordCorrect = true;
             }
         }
         
         GUILayout.BeginVertical();
         
         if (GUILayout.Button ("Login"))
         {
             if(isUserNameCorrect == true | isPasswordCorrect == true)
             {
                 Network.Connect(connectToIP, connectPort);
             }
         }
     
         
         if (GUILayout.Button ("Start Server"))
         {
                 
             
             Network.InitializeServer(32, connectPort);
         }
         GUILayout.EndVertical();
         
         }
         else
         {
         
 
         if (Network.peerType == NetworkPeerType.Connecting){
         
             GUILayout.Label("Connection status: Connecting");
             
         } else if (Network.peerType == NetworkPeerType.Client){
             
             GUILayout.Label("Connection status: Client!");
             GUILayout.Label("Ping to server: "+Network.GetAveragePing(  Network.connections[0] ) );        
             
         } else if (Network.peerType == NetworkPeerType.Server){
             
             GUILayout.Label("Connection status: Server!");
             GUILayout.Label("Connections: " + Network.connections.length.ToString());
             if(Network.connections.length>=1){
                 GUILayout.Label("Ping to first player: "+Network.GetAveragePing(  Network.connections[0] ) );
             }            
         }
 
         if (GUILayout.Button ("Disconnect"))
         {
             Network.Disconnect(200);
         }
     }
     
 
 }
 
 
 void  OnConnectedToServer (){
     Debug.Log("This CLIENT has connected to a server");    
 }
 
 void  OnDisconnectedFromServer ( NetworkDisconnection info  ){
     Debug.Log("This SERVER OR CLIENT has disconnected from a server");
 }
 
 void  OnFailedToConnect ( NetworkConnectionError error  ){
     Debug.Log("Could not connect to server: "+ error);
 }
 
 
 void  OnPlayerConnected ( NetworkPlayer player  ){
     Debug.Log("Player connected from: " + player.ipAddress +":" + player.port);
 }
 
 void  OnServerInitialized (){
     Debug.Log("Server initialized and ready");
 }
 
 void  OnPlayerDisconnected ( NetworkPlayer player  ){
     Debug.Log("Player disconnected from: " + player.ipAddress+":" + player.port);
 }
 
 
   
 void  OnFailedToConnectToMasterServer ( NetworkConnectionError info  ){
     Debug.Log("Could not connect to master server: "+ info);
 }
 
 void  OnNetworkInstantiate ( NetworkMessageInfo info  ){
     Debug.Log("New object instantiated by " + info.sender);
 }
 
 void  OnSerializeNetworkView ( BitStream stream ,   NetworkMessageInfo info  ){
     
 }

  }

125

and im still currently working on a login system, like a said atm it is temporarily based on a players prefs way to load but i plan on changing that soon.

125

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
Best Answer

Answer by BrennanVargas1 · Jul 18, 2011 at 05:39 AM

I solved it myself, someone can close this if they want.

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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

5 Errors, Need help, Unexpected symbol private etc 0 Answers

Really Simple C# Errors I Can't Figure Out 1 Answer

Unexpected symbols 0 Answers

PLEASE HELP!!!! using BergZurgArcades guide having error! 5 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