hI
Im getting an error in my network script.
Would really appreciate if someone could help me finding out what i have done wrong.
I have looked over it for days now.
This is the error
Assets/Scripts/MultiplayerManager.cs(127,10): error CS0116: A namespace can only contain types and namespace declarations
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>();
public List<MapSetting> MapList = new List<MapSetting>();
public MapSetting CurrentMap = null;
public int oldprefix;
public bool IsMatchStarted = false;
void start()
{
instance = this;
PlayerName = PlayerPrefs.GetString("PlayerName");
CurrentMap = MapList[0];
}
void FixedUpdate()
{
instance = this;
}
public void StartServer(string servername, 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()
{
networkView.RPC("Server_PlayerJoinRequest", RPCMode.Server, PlayerName, Network.player);
}
void OnPlayerDisconnected(NetworkPlayer id)
{
networkView.RPC("Client_RemovePlayer", RPCMode.All, id);
}
void OnPlayerConnected(NetworkPlayer player)
{
foreach(MPPlayer p1 in PlayerList)
{
networkView.RPC("Client_AddPlayerToList", player, p1.PlayerName, p1.PlayerNetwork);
}
networkView.RPC("Client_GetMultiplayerMatchSettings", player, CurrentMap.MapName, "", "");
}
[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 p1 in PlayerList)
{
if (p1.PlayerNetwork == view)
{
temppl = p1;
}
}
if (temppl != null) {
PlayerList.Remove(temppl);
}
}
[RPC]
void Client_GetMultiplayerMatchSettings(string map, string mode, string others)
{
CurrentMap = GetMap(map);
}
public MapSetting GetMap(string name)
{
MapSetting get = null;
foreach(MapSetting st in MapList)
{
if (st.MapName == name)
{
get = st;
break;
}
}
return get;
}
}
[RPC]
void Client_LoadMultiplayerMap(string Map, int prefix)
{
Network.SetLevelPrefix(prefix);
Application.LoadLevel(map);
}
[System.Serializable]
public class MPPlayer
{
public string PlayerName = "";
public NetworkPlayer PlayerNetwork;
}
[System.Serializable]
public class MapSetting
{
public string MapName;
public string MapLoadName;
public Texture MapLoadTexture;
}
[CODE/]