- Home /
Error with multiplayer script (not done)
So i get this 3 errors : 1) Assets/Scripts/MenuManager.cs(54,91): error CS0103: The name `maxusers' does not exist in the current context
2) Assets/Scripts/MenuManager.cs(54,53): error CS1502: The best overloaded method match for `MultiplayerManager.StartServer(string, string, int)' has some invalid arguments
3) Assets/Scripts/MenuManager.cs(54,53): error CS1503: Argument `#3' cannot convert `object' expression to type `int'
This is the script : using UnityEngine; using System.Collections;
public class MenuManager : MonoBehaviour
{
public string CurrentMenu;
public string MatchName = "";
public string MatchPassword = "";
public int MatchMaxPlayers = 32;
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()
{
//Button 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, maxusers);
}
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,130,30), "Match Password");
MatchPassword = GUI.PasswordField(new Rect(400,50,200,30),MatchPassword, '*');
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, 8, 32);
if (GUI.Button(new Rect(425,90,25,30), "+"))
MatchMaxPlayers += 2;
if (GUI.Button(new Rect(450,90,25,30), "-"))
MatchMaxPlayers -= 2;
}
private void Menu_Lobby()
{
}
}
Answer by Seth-Bergman · Nov 01, 2012 at 04:36 PM
the problem is this line:
MultiplayerManager.instance.StartServer(MatchName, MatchPassword, maxusers);
the third argument "maxusers" does not seem to have been declared anywhere, did you perhaps mean MatchMaxPlayers?
MultiplayerManager.instance.StartServer(MatchName, MatchPassword, MatchMaxPlayers);
Thank you so much! Such a small thing makes a big difference!
Your answer

Follow this Question
Related Questions
Error CS1502 Help! 1 Answer
Unity networking tutorial? 6 Answers
Error CS1502 help! 1 Answer
Following Script Not Working Properly 0 Answers