- Home /
Networking Question
Hello, I'm still new to the Networking field but was hoping someone can clarify with me of how to stop others from joining after the game has started, shouldn't need it password protected for this to work or need to have max players shorter. So my question is there anyway to have the players that aren't connected not be able to connect to a game that has already started. Thank you.
Please specify what networking you are using (Unity Networking, Photon, etc).
I had this problem, but am self-taught so this probably isn't the best solution, so I shall post as comment. Hopefully someone with more knowledge and experience will give us both a better answer!
I couldn't work out how to get information from a room while in the lobby. (using Photon Networking)
So first the player entered the room, then checked my Game$$anonymous$$anager script to see if the boolean inGame was set to true (by the host when game has started), if so then the player was returned to the lobby.
Here are some code snippets from my version :
 private var inGame : boolean = false;
 
 // called when a room is joined by the player
 function OnJoinedRoom()
 {
     DebugLog( "OnJoinedRoom() : You Have Joined a Room : " + PhotonNetwork.room.name );
     
     // - start listing the players -
     
     if ( PhotonNetwork.is$$anonymous$$asterClient ) 
     {
         // Player is Host
         // do stuff
     }
     // player is not host, proceed to select character
     else
     {
         /*
         // check if there is currently a game running
         if ( inGame )
         {
             DebugLog( "Game is already in progress !!!!" ); // ****
             // this is not printing
             // boolean is not immediatly synchronized
             // need to add a delay to let SerializeView update this
         }
         
         // go to Character Selection
         SetToSelectCharacter();
         */
         
         Invoke( "CheckAndJoinGame", 1.0 ); // one second delay seems to work
     }
 }
 
 
 function CheckAndJoinGame() 
 {
         // check if there is currently a game running
         if ( inGame )
         {
             DebugLog( "Game is already in progress !!!!" );
             
             // return to the lobby
             DisconnectFromRoom();
             
             return;
         }
         
         // go to Character Selection
         SetToSelectCharacter();
 }
 
 
 function DisconnectFromRoom() 
 {
     DebugLog( "DisconnectFromRoom()" );
     
     // do stuff
     
     //
     PhotonNetwork.LeaveRoom();
     PhotonNetwork.Disconnect();
     PhotonNetwork.offline$$anonymous$$ode = false;
 }
 
 
 // Synchronization
 function OnPhotonSerializeView( stream : PhotonStream, info : Photon$$anonymous$$essageInfo )
 {
     if ( stream.isWriting )
     {
         // We own this player: send the others our data
         stream.SendNext( inGame );
     }
     else
     {
         // Network player, receive data
         inGame = stream.ReceiveNext();
     }
 }
Answer by Guardian2300 · Mar 04, 2014 at 05:33 PM
I've kind of figured it out. You have to declare max connections to -1 or 0 for others not to join.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                