please help with this script

the error is (Assets/scripts/MenuManager.cs(48,37): error CS1501: No overload for method StartServer' takes 3’ arguments)
this is my script MenuManager :

using UnityEngine;
using System.Collections;

public class MenuManager : MonoBehaviour
{
public string CurrentMenu;
public string MatchName=“”;
public string MatchPassword=“”;
public int MatchMaxPlayers=20;
void Start()
{
CurrentMenu = “Main”;

}

void OnGUI()
{
if(CurrentMenu == “Main”)
Menu_Main();
if(CurrentMenu == “Lobby”)
Menu_Lobby();
if(CurrentMenu == “Host”)
Menu_HostGame();
}
public void NavigateTo(string nextmenu)
{
CurrentMenu=nextmenu;
}
private void Menu_Main()
{
if(GUI.Button(new Rect(10,10,200,50),“Host Game”))
{
NavigateTo(“Host”);
}
GUI.Label(new Rect(220,10,130,30), “Player Name”);
MultiPlayerManager.instance.PlayerName=GUI.TextField(new Rect(400,10,200,30),MultiPlayerManager.instance.PlayerName);

}
private void Menu_HostGame()
{
// Buttons Host Game
if(GUI.Button(new Rect(10,10,200,50),“Back”))
{
NavigateTo(“Main”);
}
if(GUI.Button(new Rect(10,60,200,50),“Start Server”))
{
MultiPlayerManager.instance.StartServer(MatchName,MatchPassword,MatchMaxPlayers);
}
GUI.Label(new Rect(220,10,130,30),“Match Name”);
MatchName=GUI.TextField(new Rect(400,10,200,30),MatchName);

GUI.Label(new Rect(220,50,200,30),“Match Password”);
MatchPassword=GUI.PasswordField(new Rect(400,50,200,30),MatchPassword,“*”[0]);

GUI.Label(new Rect(220,90,130,30),“Match Max Players”);
GUI.Label(new Rect(400,90,200,30),MatchMaxPlayers.ToString ());
MatchMaxPlayers=Mathf.Clamp(MatchMaxPlayers,2,20);
if(GUI.Button(new Rect(425,90,25,30),“+”))
MatchMaxPlayers += 1;
if(GUI.Button(new Rect(450,90,25,30),“-”))
MatchMaxPlayers -= 1 ;
}
private void Menu_Lobby()
{
}
}

and MultiPlayerManager script

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class MultiPlayerManager : MonoBehaviour
{
public static MultiPlayerManager instance;
public string PlayerName;

private string MatchName = “”;
private int MatchMaxusers = 20;
public List PlayerList = new List();
void start()
{
instance = this;
}
public void StartServer(string servername,int maxuser)
{
MatchName = servername;
MatchMaxUsers = maxusers;
Network.InitializeServer(MatchMaxusers, 2550, false);
Network.InitializeSecurity();

}
void OnServerInitialized()
{
Server_PlayerJoinRequest(“”,Network.player);

}
void OnConnectedToServer()
{
NetworkView.RPC(“Player_JoinRequest”, 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(“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(templayer);
}

[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;
}
}

StartServer() funtion you create only takes two parameters ,how can you pass three to it , you might need to change the funciton

Please use [code ] tags this makes looking at the code so much easier.

OK, so

public void StartServer(string servername,int maxuser)

StartServer is expecting 2 arguments, you are sending three:

MultiPlayerManager.instance.StartServer(MatchName, MatchPassword, MatchMaxPlayers);

Looking at this, you don’t send the password in, so you would need to do:

MultiPlayerManager.instance.StartServer(MatchName, MatchMaxPlayers);

Good luck :slight_smile: