Keep a room Open 1 minute after player quit

Options
Hi everybody ! first sorry about my bad english, i'm french :)


I'm doing a 2d game like a little MMO, and i want to kniw if it's possible to keep a room open just 1 minute after the last player quit

I have some monster on the map, and if nobody is in the map and a player come back, monster are going to respawn, so , the player can use this trick to farm monster and experience.

So if i can simulate a player and destroy him after 1mn( time to monster to respawn), he can't use this trick to level up faster :) !

so if someone have some idea i'll really appreciate !

Have a good day !

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @redskry,

    Thank you for choosing Photon and don't worry about the language, your English is OK!

    When creating rooms, you may set roomOptions.EmptyRoomTTL to 60000 milliseconds to keep the empty room alive for 1 minute.

  • redskry
    Options
    Oh Great !! That it's perfect!

    So just do that ? :

    PhotonNetwork.CreateRoom(roomName);
    roomOptions.EmptyRoomTTL(60000);

    Thx for you're replay !
  • Hi @redskry,

    you have to create the RoomOptions before creating the room in order to use it for room creation, basically like this:
    RoomOptions options = new RoomOptions();
    options.EmptyRoomTtl = 60000;
    PhotonNetwork.JoinOrCreateRoom("RoomName", options, null);
  • redskry
    redskry
    edited June 2017
    Options
    Oh thx Great ! I really apreciate you're help !

    And i have a last question, is it possible to set up max player ?
    What is happening if the room if full? i have to use callback like : Onmaxplayer ect...?

    There is a way to "group" room of the same scene? i have multiple scene and i don't want that player of scene 1 join room with player on scene 2 :/

    Thx for y'oure help agin!
    Have a good day!
  • And i have a last question, is it possible to set up max player ?


    Yes, when creating the room you can use the Room Options parameter to set this value for the room.
    RoomOptions options = new RoomOptions();
    options.MaxPlayers = 4;
    PhotonNetwork.JoinOrCreateRoom("Room", new RoomOptions(), null);
    What is happening if the room if full? i have to use callback like : Onmaxplayer ect...?


    In case of joining a room fails this callback is invoked: OnPhotonJoinRoomFailed. You can use this, too, in order to inform the client about the failed joining attempt.

    There is a way to "group" room of the same scene? i have multiple scene and i don't want that player of scene 1 join room with player on scene 2


    There is PhotonNetwork.automaticallySyncScene which does what its name says: it automatically synchronizes the active scene on all clients so that each of the clients loads the same scene. If I'm getting you right you should use multiple rooms whereby each rooms represents a certain scene. For example you have one room with 'Level 1' as active scene and another room with 'Level 2' as active scene. Therefore you can use Custom Room Properties which are available for filtering in the lobby as well. There is an example about how to use this in the Matchmaking Guide.
  • redskry
    Options
    Thx for you're anwser !

    In case of joining a room fails this callback is invoked: OnPhotonJoinRoomFailed. You can use this, too, in order to inform the client about the failed joining attempt.


    So if i have 50 room full, it's will make a long time to have a connection with the good room no?
    ( that join the second part of my question)


    For the second part, i don't understant really if it's about that ,
    my game it's a "little" Mmorpg"

    I have the room "City" with :
    server 1 -10 player: roomcity1
    server 2 : -10 player: roomcity 2
    server 3 :-8 player : Rommcity3

    and multiple other level, wich contain multiple "server"

    You're explain about "PhotonNetwork.automaticallySyncScene" is about that? (Sorry for my bad english :/ )

    i
  • When using the cloud I think having multiple different loaded scenes in just one room is a bad decision. If you want to have multiple different regions you should have one region per room so that each room represents a unique region. The other approach might also work but will result in increased message count which can be avoided.

    However if you want to use Photon Server, you can still follow this approach (multiple regions per room) when using server-side Interest Management in order to keep message count down.
  • redskry
    Options
    I think that my explain was bad , i don't have multiple scene in the same room

    i will take a fps like a exemple,

    i set up the max player/room to 5

    I have scene 1 with 5 player maximim
    and scene 2 with 4 player

    if a player want to join the scene 1, he can't because room is full, so he have to create a second room with the scene 1

    So i want to know how to do for the sixth player to create a new room in the secene 1, and not join the room for the scene 2 ^^

    Sorry again for my english and thx for you're help!
  • Now I got it. Therefore I would recommend you reading the section 'Not so random Matchmaking' from the Matchmaking guide. I think this will help you achieving the result you want to have.

    Short addition: when PhotonNetwork.JoinRandomRoom(...) fails, the client needs to create a new room.
  • redskry
    redskry
    edited June 2017
    Options
    Thanks for you're anwser! I read about this, and i want to be sur with somethings

    i have to create CustomProprieties for the room:
    
     void OnJoinedLobby()
        {
    
            Hashtable expectedCustomRoomProperties = new Hashtable() { { "RoomForScene1"} };
            PhotonNetwork.JoinRandomRoom(expectedCustomRoomProperties);
            // Join random room with cutsom proprieties expected 
        }
    
        void OnPhotonJoinRoomFailed()
        {
            RoomOptions roomOptions = new RoomOptions();
            roomOptions.CustomRoomProperties = new Hashtable() { { "RoomForScene1" } };
            roomOptions.MaxPlayers = 10;
            PhotonNetwork.CreateRoom(null, roomOptions); // create room with random name and Custom Proprieties
    }

    Can you tell me if my code is good? In this way, i want to filter the room join, to be able to player to join specific room, for specific Scene :)

    Thx again!
  • Kurtav
    Kurtav ✭✭
    edited June 2017
    Options
        void OnJoinedLobby()
        {
            Hashtable expectedCustomRoomProperties = new Hashtable() { { "room", "RoomForScene1" } };
            PhotonNetwork.JoinRandomRoom(expectedCustomRoomProperties, 0);
        }
        void OnPhotonRandomJoinFailed()
        {
            RoomOptions roomOptions = new RoomOptions();
            roomOptions.CustomRoomProperties = new Hashtable() { { "room", "RoomForScene1" } };
            roomOptions.CustomRoomPropertiesForLobby = new string[] { "room" };
            roomOptions.MaxPlayers = 10;
            PhotonNetwork.CreateRoom(null, roomOptions,null);
        }
  • redskry
    Options
    Thank you for you're awnser! :)

    Can i know what is the "0" ?
    (expectedCustomRoomProperties, 0);


    And i have to use a lobby ? it can be the same for all ?

    If i have , i have to set up before "onJoinedLobby?" Or it's good just like you wrote ?

    Thx again for you're help ! :)
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    without lobby (AutoJoinLobby disabled, PhotonNetwork.AutoJoinLobby set to false) use OnConnectedToMaster.


    Here is full code, I updated @Kurtav's snippet:
    void OnConnectedToMaster()
        {
            byte maxPlayers = 10;
            Hashtable expectedCustomRoomProperties = new Hashtable() { { "room", "RoomForScene1" } };
            PhotonNetwork.JoinRandomRoom(expectedCustomRoomProperties, maxPlayers );
        }
     void OnJoinedLobby()
        {
            byte maxPlayers = 10;
            Hashtable expectedCustomRoomProperties = new Hashtable() { { "room", "RoomForScene1" } };
            PhotonNetwork.JoinRandomRoom(expectedCustomRoomProperties, maxPlayers );
        }
        void OnPhotonRandomJoinFailed()
        {
            byte maxPlayers = 10;
            RoomOptions roomOptions = new RoomOptions();
            roomOptions.CustomRoomProperties = new Hashtable() { { "room", "RoomForScene1" } };
            roomOptions.CustomRoomPropertiesForLobby = new string[] { "room" };
            roomOptions.MaxPlayers = maxPlayers ;
            PhotonNetwork.CreateRoom(null, roomOptions,null);
        }