HELP: Is there a way to avoid players to rejoin a room?

Vazkuz
Vazkuz
Hi all!

So, I have a code when whenever the Master Client starts the game, the room becomes closed. The thing is that (even though new players can't join the room) players that were in the room and then left it can rejoin it (and I want just the exact oposite).

Is there a way to do that?

I leave my code below if you have any questions of that.
public void StartGame()
    {
        //Only the master client can start the game
        if(PhotonNetwork.IsMasterClient)
        {
            Debug.Log("Starting game");
            SceneManager.LoadScene(MultiplayerSettings.multiplayerSettings.gameScene);
            PhotonNetwork.CurrentRoom.IsOpen = false;
            PhotonNetwork.CurrentRoom. = false;
        }
    }

Comments

  • Hi
    have you tried to make the room invisible?
    >>> PhotonNetwork.room.IsVisible = false; <<<

    because that way players will not be able to find it through PhotonNetwork.JoinRandomRoom (), nor be able to see it on the list.
  • Alberto wrote: »
    Hi
    have you tried to make the room invisible?
    >>> PhotonNetwork.room.IsVisible = false; <<<

    because that way players will not be able to find it through PhotonNetwork.JoinRandomRoom (), nor be able to see it on the list.

    Hi, Alberto.

    Yes, I've tried that, the thing is that I'm using the room's name as the way for players to connect to the room. So, when I make it invisible there's always the possibility that the player search the room by its name and still be able to join.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited February 2021
    Hi @Vazkuz,

    Thank you for choosing Photon!

    In order to be able to rejoin rooms, PlayerTTL needs to be different than 0 when the player leaves the room or disconnects.
    So you can set PlayerTTL to zero or a low value (in milliseconds).
    Players also have the option to decide to leave for good explicitly by calling PhotonNetwork.LeaveRoom(false).
    Master client can also kick active actors via PhotonNetwork.CloseConnection(targetPlayer).