2 Errors Occur please help newb :)

i know these are simply errors but i cant find a way to fix this

Errors:

Assets/Scripts/MultiplayerManager.cs(13,42): error CS0029: Cannot implicitly convert type char' to string’

Assets/Scripts/MultiplayerManager.cs(11,38): error CS0029: Cannot implicitly convert type char' to string’

Code its on about

public class MultiplayerManager : MonoBehaviour
{
	public static MultiplayerManager instance;
	
	public string PlayerName;
	
	private string MatchName = '*';
	
	private string MatchPassword = '*';
	
	private int MatchMaxUsers = 32;

Full 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 = 32;
	
	
	public List<MPPlayer> PlayerList = new List<MPPlayer>();
	
	void Start ()
	{
		instance = this;
	}
	
	
	
	public void StartServer(string servername, string serverpassword, int maxuser)
	{
	MatchName = servername;
		
	MatchPassword = serverpassword;
		
	MatchMaxUsers = maxusers;
		
	Network.InitializeServer(MatchMaxUsers,2550, false);
		
	Network.InitializeSecurity();
	}
	
	void OnServerInitialized()
	{
		Server_PlayerJoinRequest("", Network.player);
	}
	
	void OnConnectedToServer()
	{
		networkView.RPC("Server_PlayerJoinRequest", RPCMode.Server,"" , Network.player);
	}
	
	void OnPlayerDisconnected(NetworkPlayer id)
	{
		networkView.RPC("Client_RemovePlayer", RPCMode.All, id);
		
	}
	
	[RPC]
	void Server_PlayerJoinRequest(string playername, NetworkPlayer view)
	{
		networkView.RPC("Server_PlayerJoinRequest", RPCMode.All, 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 temp1 = null;
		
		foreach(MPPlayer p1 in PlayerList)	
		{
			
			if (p1.PlayerNetwork = view)	
			{
				
			}
			
		}
		if (temp1 != null)
		{
			PlayerList.Remove(tempp1);
		}
		
	}
}

public class MPPlayer
{
	public string PlayerName = "";
	
	public NetworkPlayer PlayerNetwork;
}

Hi,

It’s explicit ! “Cannot implicitly convert type char' to string’” => The compiler says he can’t convert char to string directly. You need to tell him.

Replace

private string MatchName = '*';

by

private string MatchName = "*";

or

private string MatchName = new string('*');

when using

private string MatchName = "*";

These errors come up:

Assets/Scripts/MultiplayerManager.cs(33,25): error CS0103: The name `maxusers’ does not exist in the current context

Assets/Scripts/MultiplayerManager.cs(80,25): error CS0029: Cannot implicitly convert type UnityEngine.NetworkPlayer' to bool’

Assets/Scripts/MultiplayerManager.cs(88,43): error CS0103: The name `tempp1’ does not exist in the current context

Assets/Scripts/MultiplayerManager.cs(88,36): error CS1502: The best overloaded method match for `System.Collections.Generic.List.Remove(MPPlayer)’ has some invalid arguments

Assets/Scripts/MultiplayerManager.cs(88,36): error CS1503: Argument #1' cannot convert object’ expression to type `MPPlayer’

and when i use

private string MatchName = new string('*');

these errors come up

Assets/Scripts/MultiplayerManager.cs(11,51): error CS1502: The best overloaded method match for `string.String(char*)’ has some invalid arguments

Assets/Scripts/MultiplayerManager.cs(11,51): error CS1503: Argument #1' cannot convert char’ expression to type `char*’

Assets/Scripts/MultiplayerManager.cs(13,55): error CS1502: The best overloaded method match for `string.String(char*)’ has some invalid arguments

Assets/Scripts/MultiplayerManager.cs(13,55): error CS1503: Argument #1' cannot convert char’ expression to type `char*’

This is the exact same thread that you posted here). Even down to the same title. Why are you posting it again?

because i wasnt helped in the other one ? and i cant find it sorry if its irratating you

I just give you the solution on second post…

i just edited my miss sent message

I dont think you need a help on this forum but you need help in programming in general :confused:

Look at your “maxusers” with an “S” at the end, but your variable in “StartServer” function dont have an s in “maxuser”. That’s why it gives you an error, this is not the fault of the string.

Idem for “tempp1” instead of “temp1”…

The second method was obviously wrong, so forget it, just use the first method.

ok thank you sorry for the spam and all im a practical learner so this is why im doing this way, im also for any stress ive coursed theres one more thing i need you guys to help me with

Assets/Scripts/MultiplayerManager.cs(80,25): error CS0029: Cannot implicitly convert type UnityEngine.NetworkPlayer' to bool’

void Client_RemovePlayer(NetworkPlayer view)
	{
		
		MPPlayer temp1 = null;
		
		foreach(MPPlayer p1 in PlayerList)	
		{
			
			if (p1.PlayerNetwork = view)	
			{
				
			}
			
		}
		if (temp1 != null)
		{
			PlayerList.Remove(temp1);
		}
		
	}

Replace :

if (p1.PlayerNetwork = view)

by

if (p1.PlayerNetwork == view)

But sorry if i repeat : This kind of problem is the base of basic of basic of programming. Advice : Try to learn a bit more before start a Unity project :slight_smile:

yeah im starting a course soon and when i get back to school i will be too