[SOLVED] Using CreateRoom new RoomOptions parameters

Options
Hi, after updating PUN, my old method for creating and joining a room is obsolete. However, I am having trouble implementing CreateRoom with the new parameters and having the room visible in the lobby.

Old Method : PhotonNetwork.CreateRoom ( string roomName, bool isVisible, bool isOpen, int maxPlayers )
New Method : PhotonNetwork.CreateRoom ( string roomName, RoomOptions roomOptions, TypedLobby typedLobby )

This is my old way of using the lobby to create or connect to a room. (sorry for the long script, I tried to only have the relevant code included) :

function JoinMultiPlayer() 
{
	PhotonNetwork.ConnectUsingSettings( gameVersion );
}

function CreateRoom() 
{
	PhotonNetwork.CreateRoom( roomName, true, true, maxNumPlayers ); // now obsolete
}

function JoinRoom( theRoom : String ) 
{
	PhotonNetwork.JoinRoom( theRoom );
}

function OnGUI() 
{
	// - Create a Room -
	// Name of Room
	GUI.Box( Rect( (Screen.width * 0.5) - 170, 20 + extraHeight, 140, 25 ), "Room Name :", blackBkgndStyle ); 
	roomName = GUI.TextField( Rect( (Screen.width * 0.5) - 20, 20 + extraHeight, 190, 25 ), roomName, 20, inputTextStyle );

	if ( roomName.Length > 2 )
	{
		if ( GUI.Button( Rect( (Screen.width * 0.5) - 100, 50 + extraHeight, 200, 30 ), "Create Room", blackBtnStyle ) )
		{
			CreateRoom();
		}
	}

	// - Join an Existing Room -
	if ( PhotonNetwork.GetRoomList().Length == 0 )
	{
		GUI.Box( Rect( (Screen.width * 0.5) - 170, 100 + extraHeight, 340, 25 ), "Currently no games are available.", blackBkgndStyle );
		GUI.Box( Rect( (Screen.width * 0.5) - 170, 130 + extraHeight, 340, 25 ), "Rooms will be listed here,", blackBkgndStyle );
		GUI.Box( Rect( (Screen.width * 0.5) - 170, 160 + extraHeight, 340, 25 ), "when they become available.", blackBkgndStyle );
	}
	else
	{
		var startY : int = 140;
		var index : int = 0;
		
		// Room listing: simply call GetRoomList: no need to fetch/poll whatever!
		for ( var roomInfo : RoomInfo in PhotonNetwork.GetRoomList() )
		{
			GUI.Label( Rect( (Screen.width * 0.5) - 170, startY + ( index * 30 ) + extraHeight, 240, 25 ), roomInfo.name + " (" + roomInfo.playerCount + "/" + roomInfo.maxPlayers + ")", blackBkgndStyle );
			
			if ( GUI.Button( Rect( (Screen.width * 0.5) + 80, startY + ( index * 30 ) - 3 + extraHeight, 90, 30 ), "Join", blackBtnStyle ) )
			{
				JoinRoom( roomInfo.name );
			}
			
			index ++;
		}
	}
}

That is all working fine.

However, if I change the function CreateRoom() to use the new parameters, I cannot see the room in the GUI ( PhotonNetwork.GetRoomList() )
function CreateRoom() 
{
		var newRoomOptions : RoomOptions = new RoomOptions();

		newRoomOptions.isOpen = true;
		newRoomOptions.isVisible = true;
		newRoomOptions.maxPlayers = maxNumPlayers;
		
		newRoomOptions.customRoomProperties = new ExitGames.Client.Photon.Hashtable();
		newRoomOptions.customRoomProperties[ "race" ] = 0; // I have no idea what the HashTable is for, nor what the key value I'm assigning signifies
		
		var lobbyProps : String[] = [ "race" ];
		newRoomOptions.customRoomPropertiesForLobby = lobbyProps; // again, totally clueless what this means or does
		
		var sqlLobby : TypedLobby = new TypedLobby( "race", LobbyType.SqlLobby );
		
		PhotonNetwork.CreateRoom( roomName, newRoomOptions, sqlLobby ); // created room is not showing up in lobby :(
}

How do I use CreateRoom with the new parameters so that the room is visible and joinable in the lobby. Sorry if this seems easy to others, I am self-taught.

Comments

  • Tobias
    Options
    The problem is most likely that your clients show the rooms from the default lobby while you now place your new rooms into another, named lobby.

    You didn't do that before and in best case, you simply continue to use the default lobby and no room properties.

    Try:
    PhotonNetwork.CreateRoom(this.roomName, new RoomOptions() { maxPlayers = numPlayers }, null);
    

    This places the room into the default lobby (as before) and rooms should show up again, as before.

    I hope this page helps you get the idea of properties and the lobbies:
    http://doc.exitgames.com/en/realtime/current/reference/matchmaking-and-lobby
  • AlucardJay
    Options
    Thank you so much for the help. That suggestion fixed my problem.

    I did look at that link (that's how I derived the code in my question) and the pdf but still couldn't work out how to set a specific lobby then create or view/join rooms in that lobby. As I keep learning I'm sure it will dawn on me :)

    Thank you again, sorry for such a 'noob' question. I really enjoy playing around with this online stuff, and Photon does make it easy. All the Best.
  • Tobias
    Options
    I'm glad we could help.
    If you couldn't find the solution before, we did something wrong. The RoomOptions are really new and will need to get explained better.
    Thanks for the kind words. It's cool to read you actually enjoy Photon :)
  • Berial
    Options
    Ehm... Sorry to bump up but when i try to change numPlayers it says

    `int' to `byte`

    I use numPlayers as a int for changing it with the UI but since i can't assign it... i can't change it, any suggestions?

    Thank you.
  • vadim
    Options
    Do you mean that compiler complains about assigning int to byte? If yes, just cast int to byte.
  • Kera
    Options
    EASY:
    ExitGames.Client.Photon.Hashtable ht = new ExitGames.Client.Photon.Hashtable();
    RoomOptions ro = new RoomOptions();
    ht.Add("Mode","DM");
    ro.CustomRoomProperties = ht;

    and create a room : PhotonNetwork.CreateRoom("room",ro,null,null);