I was coding on one computer then i switched to laptop and suddenly i have an error which i can’t for the life of me figure out what is going wrong.
The error is the title,
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 maxusers)
{
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 ("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;
}