Hi
I have an script with following error :
RPC call failed because the function ‘removeUsernameFromAll’ does not exist in the any script attached to’Main Camera’
UnityEngine.NetworkView:RPC(String, RPCMode, Object[ ])
Multi:OnApplicationQuit() (at Assets/Skripts/Multi.js:39)
This is the script:
var username : String;
var imTheOwner : boolean;
var serverConnections : int;
var playersConnected : String;
function Start(){
if(username == "admin01") {
imTheOwner = true;
}else{
imTheOwner = false;
}
}
function Update() {
serverConnections = Network.connections.Length;
}
@RPC
function sendUsernameToAll(usrName : String){
playersConnected += "\n" + usrName;
}
@RPC
function sendUsernameFromAll(usrName : String){
playersConnected = playersConnected.Replace("\n" + usrName, "");
}
function OnApplicationQuit(){
networkView.RPC("removeUsernameFromAll", RPCMode.AllBuffered, username);
}
function OnGUI () {
GUILayout.BeginVertical(GUI.skin.box);
GUILayout.Label("du trits bei als " + username);
if(imTheOwner)
GUILayout.Label("Server Inhaber");
if(GUILayout.Button("Logout")){
username = "";
GetComponent(Hauptmenue).enabled = true;
GetComponent(Hauptmenue).username = "";
GetComponent(Hauptmenue).enableUsrNameSelector = false;
enabled = false;
}
if(imTheOwner){
if(!Network.isServer){
if(GUILayout.Button("Server starten")){
startMainServer();
}
}
if(Network.isServer){
if(GUILayout.Button("Stop Server")){
Network.Disconnect();}
GUILayout.Label("verbundene Spieler: " + serverConnections);
}
}
if(!imTheOwner){
if(!Network.isClient){
if(GUILayout.Button("Server beitreten")){
Network.Connect("localhost", 25001);
}
}
if(Network.isClient){
GUILayout.Label("mit server verbunden");
if(GUILayout.Button("verbindung trennen")){
networkView.RPC("removeUsernameToAll", RPCMode.AllBuffered, username);
Network.Disconnect();}
}
}
if(Network.isServer || Network.isClient){
if(!imTheOwner || imTheOwner){
GUILayout.BeginVertical(GUI.skin.box);
GUILayout.Label("Players connected");
GUILayout.Label(playersConnected);
GUILayout.EndVertical();
}
}
GUILayout.EndVertical();
}
function OnConnectedToServer(){
networkView.RPC("sendUsernameToAll", RPCMode.AllBuffered, username);
}
function OnServerInitialized(){
networkView.RPC("sendUsernameToAll", RPCMode.AllBuffered, username);
}
function startMainServer(){
Network.InitializeServer(32, 25001, !Network.HavePublicAddress());
Debug.Log("Server startet");
}
Do you can see the error?