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 ErikJG · Aug 08, 2013 at 07:32 PM · error-handling

How to solve a Parsing Error

After writing my script I find when I play it I'm unable to as of an error-Parsing Eroor: What is this? Heres the problem:Assets/Scripts/MultiplayerManager.cs(2,1): error CS8025: Parsing error

Heres the script: Please reply very Urgent

edit(copied from Answer)

SORRY DIDNT REALISE I POSTED THE WRONG SCRIPT. HERE IS THE NEW SCRIPT.

1. using UnityEngine;

2. using System.Collections;

3. using System.Collections.Generic;

5. public class MultiplayerManager : MonoBehaviour

6. {

  1. public static MultiplayerManager instance;

  2. public GUIManager guiManager;

  3. public GameObject PlayerManagerPrefab;

  4. public string PlayerName;

  5. private string MatchName = "";

  6. private string MatchPassword = "";

  7. private int MatchMaxUsers = 32;

  8. public List PlayerList = new List();

  9. public List MapList = new List();

  10. public MapSetting CurrentMap = null;

  11. public int oldprefix;

  12. public bool IsMatchStarted = false;

  13. //General Multiplayer Modes

  14. public bool MatchLoaded;

  15. public MPPlayer MyPlayer;

  16. public GameObject[] Spawnpoints;

  17. void Start()

  18. {

  19.  instance = this;
    
    
  20.  PlayerName = PlayerPrefs.GetString("PlayerName");
    
    
  21.  CurrentMap = MapList[0];
    
    
  22.  DontDestroyOnLoad(gameObject);
    
    
  23. }

  24. void FixedUpdate()

  25. {

  26.  instance = this;
    
    
  27. }

  28. public void StartServer(string servername, string serverpassword, int maxusers)

  29. {

  30.  MatchName = servername;
    
    
  31.  MatchPassword = serverpassword;
    
    
  32.  MatchMaxUsers = maxusers;
    
    
  33.  Network.InitializeServer(MatchMaxUsers, 2550, false);
    
    
  34.  MasterServer.RegisterHost("DeathMatch", MatchName, "");
    
    
  35.  //Network.InitializeSecurity();
    
    
  36. }

  37. void OnServerInitialized()

  38. {

  39.  Server_PlayerJoinRequest(PlayerName, Network.player);
    
    
  40. }

  41. void OnConnectedToServer()

  42. {

  43.  networkView.RPC("Server_PlayerJoinRequest", RPCMode.Server, PlayerName, Network.player);
    
    
  44. }

  45. void OnPlayerDisconnected(NetworkPlayer id)

  46. {

  47.  networkView.RPC("Client_RemovePlayer", RPCMode.All, id);
    
    
  48. }

  49. void OnPlayerConnected(NetworkPlayer player)

  50. {

  51.  foreach(MPPlayer pl in PlayerList)
    
    
  52.  {
    
    
  53.      networkView.RPC("Client_AddPlayerToList", player, pl.PlayerName, pl.PlayerNetwork);
    
    
  54.  }
    
    
  55.  networkView.RPC("Client_GetMultiplayerMatchSettings", player, CurrentMap.MapName, "", "");
    
    
  56. }

  57. void OnDisconnectedFromServer()

  58. {

  59.  PlayerList.Clear();
    
    
  60. }

  61. [RPC]

  62. void Server_PlayerJoinRequest(string playername, NetworkPlayer view)

  63. {

  64.  networkView.RPC("Client_AddPlayerToList", RPCMode.All, playername, view);
    
    
  65. }

  66. [RPC]

  67. void Client_AddPlayerToList(string playername, NetworkPlayer view)

  68. {

  69.  MPPlayer tempplayer = new MPPlayer();
    
    
  70.  tempplayer.PlayerName = playername;
    
    
  71.  tempplayer.PlayerNetwork = view;
    
    
  72.  PlayerList.Add(tempplayer);
    
    
  73.  if (Network.player == view)
    
    
  74.  {
    
    
  75.      MyPlayer = tempplayer;
    
    
  76.      GameObject play = Network.Instantiate(PlayerManagerPrefab, Vector3.zero, Quaternion.identity, 5) as GameObject;
    
    
  77.      //play.GetComponent<PlayerManager>().thisplayer = MyPlayer; //Remove This Part
    
    
  78. }

 }

 [RPC]

 void Client_RemovePlayer(NetworkPlayer view)

 {

  1. MPPlayer temppl = null;

  2. foreach(MPPlayer pl in PlayerList)

  3. {

  4.     if (pl.PlayerNetwork == view)
    
    
  5.     {
    
    
  6.         temppl = pl;
    
    
  7.     }
    
    
  8. }

  9. if (temppl != null)

  10. {

  11.     PlayerList.Remove(temppl);
    
    
  12. }

 }

 [RPC]

 void Client_GetMultiplayerMatchSettings(string map, string mode, string others)

 {

  1. CurrentMap = GetMap(map);

 }

 public MapSetting GetMap(string name)

 {

  1. MapSetting get = null;

  2. foreach (MapSetting st in MapList)

  3. {

  4.     if (st.MapName == name)
    
    
  5.     {
    
    
  6.         get = st;
    
    
  7.         break;
    
    
  8.     }
    
    
  9. }

  10. return get;

 }

 [RPC]

 void Client_LoadMultiplayerMap(string map, int prefix)

 {

  1. //Network.SetLevelPrefix(prefix);

  2. Application.LoadLevel(map);

 }

 void OnGUI()

 {

  1. if (!MyPlayer.PlayerIsAlive && IsMatchStarted)

  2.     SpawnMenu();
    
    
  3. if (IsMatchStarted && Input.GetKey(KeyCode.Tab))

  4. {

  5.     guiManager.ScoreBoard();
    
    
  6. }

 }

 [RPC]

 void Server_SpawnPlayer(NetworkPlayer player)

 {

  1. int numberspawn = Random.Range(0, Spawnpoints.Length - 1);

  2. networkView.RPC("Client_SpawnPlayer", RPCMode.All, player, Spawnpoints[numberspawn].transform.position + new Vector3(0, 2, 0), Spawnpoints[numberspawn].transform.rotation);

 }

 [RPC]

 void Client_SpawnPlayer(NetworkPlayer player, Vector3 position, Quaternion rotation)

 {

  1. MultiplayerManager.GetMPPlayer(player).PlayerIsAlive = true;

  2. MultiplayerManager.GetMPPlayer(player).PlayerHealth = 100;

  3. if (player == MyPlayer.PlayerNetwork)

  4. {

  5.     MyPlayer.PlayerManager.ControllerTransform.position = position;
    
    
  6.     MyPlayer.PlayerManager.ControllerTransform.rotation = rotation;
    
    
  7.     MyPlayer.PlayerManager.networkView.RPC("Client_PlayerAlive", RPCMode.All);
    
    
  8. }

  9. else

  10. {

  11. }

 }

 void OnLevelWasLoaded()

 {

  1. if (Application.loadedLevelName == CurrentMap.MapLoadName && Network.isServer)

  2. {

  3.     MatchLoaded = true;
    
    
  4.     Spawnpoints = GameObject.FindGameObjectsWithTag("spawnpoint");
    
    
  5.     networkView.RPC("Client_ServerLoaded", RPCMode.AllBuffered, IsMatchStarted);//Add parameter for boolean IsMatchStarted
    
    
  6. }

 }

 [RPC]

 void Client_ServerLoaded(bool started)//Add parameter for boolean IsMatchStarted

 {

  1. MatchLoaded = true;

  2. IsMatchStarted = started;

 }

 public static MPPlayer GetMPPlayer(NetworkPlayer player)

 {

  1. foreach (MPPlayer play in MultiplayerManager.instance.PlayerList)

  2. {

  3.     if (play.PlayerNetwork == player)
    
    
  4.     {
    
    
  5.         return play;
    
    
  6.     }
    
    
  7. }

  8. return null;

 }

 //Deathmatch

 void SpawnMenu()

 {

  1. if (GUI.Button(new Rect(5, Screen.height - 40, 250, 35), "Spawn"))

  2. {

  3.     if (Network.isServer)
    
    
  4.         Server_SpawnPlayer(Network.player);
    
    
  5.     else
    
    
  6.         networkView.RPC("Server_SpawnPlayer", RPCMode.Server, Network.player);
    
    
  7. }

 }

 [RPC]

 public void Client_UpdatePlayerHealthAndAlive(NetworkPlayer targetplayer, bool IsAlive, int CurrentHealth)

 {

  1. MPPlayer player = MultiplayerManager.GetMPPlayer(targetplayer);

  2. player.PlayerIsAlive = IsAlive;

  3. player.PlayerHealth = CurrentHealth;

 }

231. }

233. [System.Serializable]

234. public class MPPlayer

235. {

 public string PlayerName = "";

 public NetworkPlayer PlayerNetwork;

 public PlayerManager PlayerManager;

 public int PlayerHealth = 100;

 public bool PlayerIsAlive;

 public int PlayerScore;

 public int PlayerKills;

 public int PlayerDeahts;

244. }

246. [System.Serializable]

247. public class MapSetting

248. {

 public string MapName;

 public string MapLoadName;

 public Texture MapLoadTexture;

252. }

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 clunk47 · Aug 08, 2013 at 07:41 PM 0
Share

Your parsing error is in the $$anonymous$$ultiplayer$$anonymous$$anager script, but you posted your $$anonymous$$enu$$anonymous$$anager script. Please post the correct script and we'll be happy to resolve your concern.

avatar image perchik · Aug 08, 2013 at 07:49 PM 2
Share

Alternatively, if this script is saved as $$anonymous$$ultiplayer$$anonymous$$anager.cs, the class should also be called $$anonymous$$ultiplayer$$anonymous$$anager

avatar image clunk47 · Aug 08, 2013 at 08:04 PM 1
Share

@perchik is correct. If the class name and script name don't match in C#, a warning will be thrown.

avatar image zombience · Aug 08, 2013 at 08:46 PM 0
Share

as a side note: so, i only glanced over your code, but unless i'm missing something, there's no reason to continuously assign:

instance = this

as you have done here in the fixedupdate() loop. assign it once at start and you're set.

avatar image clunk47 · Aug 08, 2013 at 08:54 PM 0
Share

He needs to post the correct script lol

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Aug 09, 2013 at 06:36 AM

Well, is it possible that you have that 1. 2. 3. .... actually in your script file? Remove them, all!

Comment
Add comment · Show 6 · 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 Bunny83 · Aug 09, 2013 at 06:43 AM 0
Share

Btw, that looks like a compy and paste error from aoms website. This script actually exists in more or less this form several times on the net:

http://mysticpaste.com/view/5oD1v6UOOk;jsessionid=1yia78vgd5zp2a4pmnpprwu?0

http://pastebin.com/L3p$$anonymous$$cPBA

avatar image ErikJG · Aug 09, 2013 at 09:27 AM 0
Share

tried your edited script still says parsing error

avatar image Bunny83 · Aug 09, 2013 at 11:03 AM 1
Share

$$anonymous$$y edited script? I did not edit any script, I just copied your script from the answer you've posted to your question since answers should answer the question. As I said it seems you copied line numbers into the script itself. Those numbers are not code. They must be removed.

avatar image clunk47 · Aug 09, 2013 at 02:11 PM 0
Share

Do a little homework on parsing man. Google it. "Parsing Error C#". It's probably either an unnecessary or missing bracket. Opening { Bracket or Closing } Bracket.

avatar image clunk47 · Aug 09, 2013 at 02:37 PM 1
Share

In addition to @Bunny83's answer, don't number each line!

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 public class $$anonymous$$ultiplayer$$anonymous$$anager : $$anonymous$$onoBehaviour
 {
     public static $$anonymous$$ultiplayer$$anonymous$$anager instance;
     public GUI$$anonymous$$anager gui$$anonymous$$anager;
     public GameObject Player$$anonymous$$anagerPrefab;
     public string PlayerName;
     private string $$anonymous$$atchName = "";
     private string $$anonymous$$atchPassword = "";
     private int $$anonymous$$atch$$anonymous$$axUsers = 32;
     public List PlayerList = new List();
     public List $$anonymous$$apList = new List();
     public $$anonymous$$apSetting Current$$anonymous$$ap = null;
     public int oldprefix;
     public bool Is$$anonymous$$atchStarted = false;
     
     //General $$anonymous$$ultiplayer $$anonymous$$odes
     public bool $$anonymous$$atchLoaded;
     public $$anonymous$$PPlayer $$anonymous$$yPlayer;
     public GameObject[] Spawnpoints;
     
     void Start()
     {
         instance = this;
         PlayerName = PlayerPrefs.GetString("PlayerName");
         Current$$anonymous$$ap = $$anonymous$$apList[0];
         DontDestroyOnLoad(gameObject);
     }
     
     void FixedUpdate()
     //.........................And so on..........
Show more comments

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

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

IndexOutOfRangeException: How to FIX it? 1 Answer

'Cannot Submit Change to Server' and Failing to Revert Project in Unity Collab 1 Answer

Debug.LogError vs throw new exception 4 Answers

Unity wont enter play mode - compiler errors? 0 Answers

using smtp to send email from webgl build get error message - message string not found in the message table 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