- Home /
AllocatedID error
I have a server and a client running the same code. I want X clients to be able to join a server. They all control a character (including the server) on a map. Pretty standard. I can allow players to connect and disconnect, but if they try to reconnect, they get two errors and weird stuff start happening. 1) View ID AllocatedID: 150 not found during lookup. Strange behaviour may occur 2) Could't invoke RPC function 'FocusCameraOnObject' because the networkView 'AllocatedID: 150' doesn't exist
I'm also going to dump the javascript file in question in here, but it may not really be nesessary.
 var playerModel : Transform;
 var mapModel : Transform;
 
 
 //add players and map
 function OnPlayerConnected(player: NetworkPlayer)
 {
     networkView.RPC("startLoadingSelf",  RPCMode.AllBuffered, player.ToString());
 }
 @RPC
 function startLoadingSelf(player:String)
 {
     if(Network.player.ToString() == player)
     {
         addNewPlayer("player " + player);
     }
 }
 
 function OnServerInitialized()
 {
     var newMapModel = Network.Instantiate(mapModel, transform.position, transform.rotation, 0);
     newMapModel.networkView.RPC("renameObject", RPCMode.AllBuffered, "Map");
     
     addNewPlayer("player " + Network.player.ToString());
 }
 
 function addNewPlayer(playerName:String)
 {
     
     var spawnPoint = GameObject.Find("Map/Spawn");
     var newPlayerModel = Network.Instantiate(playerModel, spawnPoint.transform.position, spawnPoint.transform.rotation, 0);
     newPlayerModel.networkView.RPC("renameObject", RPCMode.AllBuffered, playerName);
     newPlayerModel.networkView.RPC("FocusCameraOnObject", RPCMode.AllBuffered, playerName, playerName + "/PlayerModel");
 }
 
 
 
 //remove players and map
 function OnPlayerDisconnected (player : NetworkPlayer)
 {
     Network.RemoveRPCs(player);
     removePlayer("player " + player.ToString(), "network");
 }
 
 function OnDisconnectedFromServer(mode : NetworkDisconnection)
 {
     Destroy(GameObject.Find("Map"));
     var players = GameObject.FindGameObjectsWithTag("Player");
     var i = 0;
     for(var player in players)
     {
         removePlayer("player " + i, "local");
         i++;
     }
 }
 
 function removePlayer(playerName:String, netOrLoc:String)
 {
     if(netOrLoc == "network")
     {
         GameObject.Find(playerName).networkView.RPC("FocusCameraOnObject", RPCMode.AllBuffered, playerName, "World");
         Network.Destroy(GameObject.Find(playerName));
     }
     else if(netOrLoc == "local")
     {
         GameObject.Find(playerName).GetComponent(GenericRPC).FocusCameraOnObject(playerName, "World");
         Destroy(GameObject.Find(playerName));
     }
     var currentPlayer = GameObject.Find("World");
 }
 
Answer by tavoevoe · Oct 13, 2012 at 04:46 PM
I solved this on my own. Sorry if I wasted anyone's time. The trick here is that I'm calling removeRPCs, then adding one more RPC. That means, when a player connects after this player has left, they get one command that's applicable to a non-existent player. The two lines in the "OnPlayerDisconnected" function should be swapped.
Your answer
 
 
             Follow this Question
Related Questions
Persisting NetworkView across Scene change does not work 1 Answer
Is server the sender of RPC? 0 Answers
A question regarding networking... 2 Answers
How to solve RPC error 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                