I have an error can somone plz tell me how to fix it here is the error Sending RPC ‘Client_RemovePlayer’ failed because the number of supplied parameters doesn’t match the rpc declaration. Expected 1 but got 2 parameters.
here is the 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 string MatchPassword = "";
private int MatchMaxUsers = 32;
public List<MPPlayer> PlayerList = new List<MPPlayer>();
void Start()
{
instance = this;
PlayerName = PlayerPrefs.GetString ("Player Name");
}
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()
{
GetComponent<NetworkView>().RPC("Server_PlayerJoinRequest", RPCMode.Server,PlayerName, Network.player);
}
void OnPlayerDisconnected(NetworkPlayer id)
{
GetComponent<NetworkView>().RPC("Client_RemovePlayer", RPCMode.All, id);
}
[RPC]
void Server_PlayerJoinRequest(string playername, NetworkPlayer view)
{
GetComponent<NetworkView>().RPC("Client_RemovePlayer", 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;
}