- Home /
C# Newline in constant.
hello guys i am a little bit new to c# and i have make a script but i dont khow what that error mean "Newline in constant" can anyone help? ... here is my code: using UnityEngine; using System.Collections; using System.Collections.Generic;
public class MultiplayerManager : MonoBehaviour
{
public static MultiplayerManager instance;
public string PlayerName;
private string MatchName = "";
private string MatchPassword = "";
private int MatchMaxUsers = 24;
public List PlayerList = new List();
void Start()
{
instance = this;
	 PlayerName = PlayerPrefs.GetString("PlayerName");
}
public void StartServer(string serveraname, string serverpassword, int maxusers)
{
MatchName = servername;
	 MatchPassword = serverpassword;
	 MatchMaxUsers = maxusers;
	 Network.InitializeServer(MatchMaxUsers, 2550, false);
	 MasterServer.RegisterHost("DeathMatch", MatchName, "");
	 //Network.InitializeSecurity();
}
void OnServerInitialized()
{
Server_PlayerJoinRequest(PlayerName, Network.player);
}
void OnConnectedToServer()
{
network.RPC("Server_PlayerJoinRequest",RPCMode.Server, PlayerName, Network.player);
}
}
void OnPlayerDisconnected()
{
networkView.RPC("Client_RemovePlayer,RPCMode.All, id);
}
[RPC]
void Server_PlayerJoinRequest(string playername, NetworkPlayer view);
{
networkView.RPC("Client_AddPlayerToList", RPCMode.All, playername, view)
}
[RPC]
void Client_AddPlayerToList(string playername, NetworkPlayer view)
{
MPPlayer tempplayer = new MPPlayer();
	tempplayer.PlayerName = playername;
	tempplayer.PlayerNetwork = view;
	PlayerList.Add(tempplayer);
}
[RPC]
void Client_RemovePlayer(NetworkPlayer view)
{
MPPlayer temppl = null;
foreach(MPPlayer pl in PlayerList)
{
if(pl.PlayerNetwork == view)
{
temppl = pl;
}
}
if(temppl != null)
{
PlayerList.Remove(temppl);
}
}
public class MPPlayer
{
public string PlayerName = "";
public NetworkPlayer PlayerNetwork;
}
}
When posting code please format it correctly.
Edit your post, select all the code and hit the 'code snippet' button
I can't format it for you since UA finally totally f**** up every post. The generic parameters are missing totally now... It's getting worse with each update.
Please edit your post, remove your old code and insert your original code, but this time don't forget to press the "101/010" button after you selected all your code.
Is this thing still Qato or is it something else? Horrible system.
It is still qato, but i don't think it's a general problem with the system. They have implemented a lot new stuff. Right after the switch we had much less problems...
Well they implemented some auto-conversion to html which were done at certain time intervals in the past (at least that was my experience). In it's current form it's near to be unusable. $$anonymous$$ost work on this site in the past was fixing wrongly formatted code. Now it's a real pain in the a**. All text get it's special characters html-escaped and generic parameters, which of course would be interpreted as html tags, are just stripped away.
When i post something and i click "edit", i expect to be able to edit what i've just posted or at least something that's "almost" the same, but at the moment the text is totally screwed up. I don't want to spend 10 $$anonymous$$ to fix what the webserver has f* up in less then 2ms.
I've run into that too. Unless it's small, I just avoid it now.
Answer by DaveA · Aug 22, 2012 at 09:19 PM
Yes you should format your code, but that error is usually because you didn't have matching double-quotes on a string.
In Chrome, you can search, search for " and it hightlights all the " on the page.
Easy to see:
networkView.RPC("Client_RemovePlayer,RPCMode.All, id);
Did you see the error in the line I put in my answer, did you fix that?
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
how do i fix (error CS1010 Newline in constant) 1 Answer
Multiple Cars not working 1 Answer
Help I am getting an error CS0079 in my code and I don't know why. 1 Answer
Particle circle HELP 1 Answer