- Home /
Question by
adriel0000 · Jun 29, 2014 at 05:44 PM ·
multiplayernetwork
Problem with RPC attribute.
Hi! I have a problem, and i cant solve this :( I tried about 1 month to fix it, but i cant solve this problem :(
Problem:
RPC call failed because the function 'SendFullPlayers' in 'LobbyUI' does not have the RPC attribute. You need to add the RPC attribute in front of the function declaration
UnityEngine.NetworkView:RPC(String, RPCMode, Object[])
LobbyUI:Update() (at Assets/Escenas/Nivel1/Lobby/LobbyUI.js:33)
Code:
private var Menu = 1;
var ButtonSolo : GUIStyle;
var ButtonCoop : GUIStyle;
var ButtonCrearPartida : GUIStyle;
var ButtonUnirseAPartida : GUIStyle;
var ButtonUnirse : GUIStyle;
var ButtonComenzar : GUIStyle;
var remoteIP:String = "127.0.0.1";
var IP:String = "IP DEL SERVIDOR";
var remotePort = 25002;
var useNAT = false;
static var Jugadores = 1;
static var Spawn:int;
static var Servidor:int;
static var Jugando;
static var ClienteFijo;
var ClienteFijoTiempo = 0;
function Start(){
networkView.group = 1;
}
function Update(){
if(Servidor==1){
if(Jugadores==2){
networkView.RPC("SendPlayers",RPCMode.All);
//SendPlayers2();
}
if(Jugadores==3){
//SendPlayers3();
networkView.RPC("SendFullPlayers",RPCMode.All);
}
}
if(Servidor==0 && ClienteFijoTiempo>=10 && ClienteFijoTiempo <= 6020){
ClienteFijoTiempo -= Time.deltaTime;
}
if(Servidor==0 && ClienteFijo==0 && Jugadores <=2 && ClienteFijoTiempo>=6000)
ClienteFijo = 1;
ClienteFijoTiempo = 0;
}
if(Servidor== 0 && ClienteFijo==0 && Jugadores >=3){
Network.Disconnect();
MasterServer.UnregisterHost();
Menu = 1;
}
function OnGUI () {
if(Screen.width<=1366 && Screen.height<=768){
if(Menu==1){ //Menu Principal 720p
if(GUI.Button (Rect(Screen.width/2.4,Screen.height/3.8,225,50),"",ButtonSolo)){
Network.InitializeServer(32, 25002, useNAT);
StartGame();
networkView.RPC("StartGame",RPCMode.All);
Destroy(gameObject);
}
if(GUI.Button (Rect(Screen.width/2.4,Screen.height/2.9,225,50),"",ButtonCoop)){
Menu = 2;
}
}
}
if(Menu==2){ //MenuCoop
if(GUI.Button (Rect(Screen.width/2.4,Screen.height/3.8,225,50),"",ButtonCrearPartida)){
Network.InitializeServer(32, 25002, useNAT);
Menu = 3;
}
if(GUI.Button (Rect(Screen.width/2.4,Screen.height/2.9,225,50),"",ButtonUnirseAPartida)){
Menu = 4;
}
}
if(Menu==3){ //MenuCrearPartida---------------------------
if(Jugadores==1){
GUI.Box(Rect(Screen.width/2.4,Screen.height/3.8,225,50),"Jugadores 1/2");
}
if(Jugadores==2) {
GUI.Box(Rect(Screen.width/2.4,Screen.height/3.8,225,50),"Jugadores 2/2");
}
if(GUI.Button (Rect(Screen.width/2.45,Screen.height/3,225,50),"",ButtonComenzar)){
StartGame();
networkView.RPC("StartGame",RPCMode.AllBuffered);
}
}
if(Menu==4){ //MenuUnirseAPartida--------------------
if(GUI.Button (Rect(Screen.width/2.45,Screen.height/3,225,50),"",ButtonUnirse)){
Network.Connect(IP, remotePort);
Servidor = 0;
}
IP = GUI.TextField (Rect(Screen.width/2.4,Screen.height/3.8,200,20), IP, 25);
}
if(Menu==5){ //MenuPartidaUnida
if(Servidor==0){
if(Jugadores==1) {
GUI.Box(Rect(Screen.width/2.4,Screen.height/3.8,220,20),"Jugadores 1/2");
}
if(Jugadores==2) {
GUI.Box(Rect(Screen.width/2.4,Screen.height/3.8,220,20),"Jugadores 2/2");
}
if(Jugadores==3) {
GUI.Box(Rect(Screen.width/2.4,Screen.height/3.8,220,20),"Jugadores 3/3");
}
if(GUI.Button (Rect(Screen.width/2.45,Screen.height/3,225,50),"",ButtonComenzar)){
StartGame();
networkView.RPC("StartGame",RPCMode.AllBuffered);
}
}
}
}
function OnConnectedToServer() {
Menu = 5;
if(ClienteFijo==0){
ClienteFijoTiempo = 10;
}
}
function OnServerInitialized() {
Servidor = 1;
}
function OnPlayerConnected(player: NetworkPlayer) {
if(Servidor== 1){
Jugadores += 1;
}
}
function OnPlayerDisconnected(player: NetworkPlayer) {
if(Servidor==1){
Network.RemoveRPCs(player);
Jugadores -= 1;
}
}
@RPC
function SendPlayers(){
Jugadores = 2;
}
function SendFullPlayers(){
Jugadores = 3;
/*Network.Disconnect();
MasterServer.UnregisterHost();
Menu = 1;*/
}
function StartGame(){
Destroy(gameObject);
Spawn = 1;
Jugando = 1;
}
Thank you for your time :)
Comment
Answer by KiraSensei · Jun 29, 2014 at 05:45 PM
@RPC
function SendFullPlayers(){
Jugadores = 3;
/*Network.Disconnect();
MasterServer.UnregisterHost();
Menu = 1;*/
}
the "@RPC" you have is applied only to the next function only (SendPlayers), not the ones after.
Your answer
![](https://koobas.hobune.stream/wayback/20220613152813im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Doubt about Network level loading 0 Answers
Can you create a Stand alone server for your game? 0 Answers
Online Multiplayer 1 Answer
Multiplayer. Destroying player object on Host/Server 2 Answers
Networking, players can't see each others movements 1 Answer