JoinRoom - Create if doesn't exist. How to set properties?

Options
carmine
carmine ✭✭
You can call JoinRoom with "true" to create the room if it doesn't exist. However... I don't see how to set any of the properties. For instance, CreateRoom looks like this:

public static void CreateRoom(string roomName, bool isVisible, bool isOpen, int maxPlayers, Hashtable customRoomProperties, string[] propsToListInLobby)

However, I only have the option to do:
public static void JoinRoom(string roomName, bool createIfNotExists)

Is there a way to specify all of that in the Join? Is the "createIfNoExists" a "Serverside" check or is it a client side check that simply calls create?

Thanks!
-Carmine

Comments

  • Call in your code to join an existing server but do not create if not exists. You can do that manually.

    PhotonNetwork.JoinRoom(roonName, false);

    And then have the callback functions ready to call your custom setup stuff instead of a default create room:

    public void OnPhotonJoinRoomFailed(){
    Debug.Log("OnPhotonRandomJoinFailed");
    PhotonNetwork.CreateRoom(RoomName, isVisible, isOpen, maxNumberOfPlayers);
    }
    public void OnCreatedRoom(){
    Debug.Log("OnCreatedRoom");

    //set room properties
    //load level if needed, dont forget to disable messaging
    }
  • Tobias
    Options
    When joining a room, you can't set room properties, because you better first check which props the room actually has (and maybe the players in it already set some values they want to stick with, like map). In create, you know you're the owner of a room and the first person to enter it and you can safely set props.
    In the hybrid "create if not exists", you have to set the props when you entered the room. Maybe you created it, maybe not. But it's safe to set them when you arrived.
  • carmine
    Options
    Tobias wrote:
    When joining a room, you can't set room properties, because you better first check which props the room actually has (and maybe the players in it already set some values they want to stick with, like map). In create, you know you're the owner of a room and the first person to enter it and you can safely set props.
    In the hybrid "create if not exists", you have to set the props when you entered the room. Maybe you created it, maybe not. But it's safe to set them when you arrived.

    Tobias... I can set all of these when I arrive in a room?

    bool isVisible,
    bool isOpen,
    int maxPlayers,
    Hashtable customRoomProperties,
    string[] propsToListInLobby
  • Tobias
    Options
    Truth to be told: You should be but can't. I worked on this but it's just not released yet.
    The Room.cs must be updated a bit to be able to set propsToListInLobby. The other values are already settable after joining, yes.
    I think I could send you the updated Room.cs.

    Maybe there's another, hidden problem: If you don't set maxPlayers in create a busy game lobby might add too many players to your game before you can even limit the player count. That's something we might have to change.