How to set custom room properties that get listed in the lobby

Hi,

I’m trying to implement skill based match making using Photon. For this, when creating a room:

client:createRoom(nil, {maxPlayers = 2, lobbyType = loadBalancingConstants.LobbyType.SqlLobby, propsListedInLobby = {1}, customGameProperties = {["C0"] = 100}});

The lobby type is SqlLobby and I want to use one of the predefined SQL filter parameters (C0 in this case). This parameter holds the player skill level. The problem is that I can’t find a way to set the propsListedInLobby variable to a valid type. According to the docs, this is a int array. I’ve also tried to supply a string array, but the problem is always the same and I got the following error message in the logs:

ERROR LoadBalancingClient: 65534 Invalid type for property LobbyProperties. Expected type System.Object[] but is System.Collections.Hashtable

It seems the SDK always converts Lua tables into Java Hashtables (I’m on Android) and this is not the expected type.

Has anyone experienced this problem?

Br,

Cleverson

Hi,

The documentation is wrong.

propsListedInLobby is an array of strings in fact. It contains names of custom properties to be listed in a lobby. Since lua does not have Array type, you need to wrap it in custom type defined in Photon

local Array = require("photon.common.type.Array") -- ... room:setPropsListedInLobby(Array.new(elem1, elem2, ... ))

See demo-particle/ParticleClient.lua and demo-memory/MemoryClient.lua for details.

Sorry for inconvenience. We will fix the documentation.

Ok, thank you!

I’ve tried to supply an array of strings, but got the same error. Do you have a working sample?

Another question. If I’m only using the predefined variables (C0, C1…), do I need to expose them through propsListedInLobby or they are already exposed in the lobby?

Br,

Cleverson

After using the Array type explained above, the error message is gone. Thanks!

But matchmaking doesn’t work yet. I checked both samples you mentioned, but I couldn’t find what I need there.

This is the code I’m using to create a room now:

self:createRoom(nil, {maxPlayers = 2, lobbyType = loadBalancingConstants.LobbyType.SqlLobby, propsListedInLobby = Array.new("C0"), customGameProperties = {["C0"] = gameModel.trophies}});

When another player joins the room, this is the code I’m using:

local sqlFilterString = "C0 \> "..tostring(lowerLimitForTrophies).. " and C0 \< "..tostring(uperLimitForTrophies); self:joinRandomRoom({lobbyType = loadBalancingConstants.LobbyType.SqlLobby, sqlLobbyFilter = sqlFilterString});

The values for lowerLimit and upperLimit are currently 50 and 100 in my tests. But, no matter which level the players are, there is always a match. Can you tell what’s wrong here?

Br,

Cleverson

I’ve tried a lot of alternatives, but I couldn’t make matchmaking work.

Exit Games? Could you help out?

Please add lobbyName string item to options list in both calls. Lobby name is mandatory for sql lobbies. Or more precise, default nameless lobby is not an sql lobby.

Thanks for the answer.

I’m not sure if I’m understanding how to set up the matchmaking process. Should the lobby names be unique? I mean, if they need to be unique, I will create random names (something like “my_lobby_”…math.random(1000)). If I do that, how the player who will later join the room will know the lobby name?

All players should join the same single lobby if they want to see each other’s rooms.

Just hardcode any constant name you like.

Thanks again!

I would love to solve this by myself, but there is no way I manage to make it work. I will paste the code here and hope someone can spot what I’m doing wrong.

This is how I create the room:

local Array = require("photon.common.type.Array"); local exposedProps = Array.new("C0"); self:createRoom(nil, {maxPlayers = 2, lobbyName = "TOWERCRUSH\_LOBBY\_234k1", lobbyType = loadBalancingConstants.LobbyType.SqlLobby, propsListedInLobby = exposedProps, customRoomProperties = {["C0"] = 50}});

And later, how I try to join it:

local sqlFilterString = "C0 \> 25 AND C0 \< 75"; self:joinRandomRoom({lobbyType = loadBalancingConstants.LobbyType.SqlLobby, lobbyName = "TOWERCRUSH\_LOBBY\_234k1", sqlLobbyFilter = sqlFilterString});

It was not supposed to be that hard, but I’m doing something wrong and I can’t find the problem. I tried many variations from the code above, but it never worked.

Also, I’m hardcoding the region just to make sure both players can see each other.

Br,

Cleverson

So you expect that random join finds the match but it does not?

I updated demo-particle.with the code below and it works for me. But I do not see any difference with yours.

self:createRoom(nil, {maxPlayers = 2, lobbyName="TOWERCRUSH\_LOBBY\_234k1", lobbyType = LoadBalancingConstants.LobbyType.SqlLobby, propsListedInLobby = Array.new("C0"), customGameProperties = {["C0"] = 50}})

local sqlFilterString = "C0 \> 25 AND C0 \< 75" self:joinRandomRoom({lobbyName="TOWERCRUSH\_LOBBY\_234k1", lobbyType = LoadBalancingConstants.LobbyType.SqlLobby, sqlLobbyFilter = sqlFilterString})

Hi Photon team,

Thanks a lot for the help. I checked your code and saw the difference. In one of my attempts, I used the photon docs from other SDKs and changed the custom property variable name to:

customRoomProperties = {["C0"] = 50

instead of (like your code sample):

customGameProperties = {["C0"] = 50

In the first code sample I posted on September, the 4th, I used the correct name. But, then I changed it to customRoomProperties and that was the mistake.

Everything is working great now. Tower Crush will have PvP powered by Photon soon :slight_smile:

Thanks for the great support.

Br,

Cleverson

Hi,

The documentation is wrong.

propsListedInLobby is an array of strings in fact. It contains names of custom properties to be listed in a lobby. Since lua does not have Array type, you need to wrap it in custom type defined in Photon

local Array = require("photon.common.type.Array") -- ... room:setPropsListedInLobby(Array.new(elem1, elem2, ... ))

See demo-particle/ParticleClient.lua and demo-memory/MemoryClient.lua for details.

Sorry for inconvenience. We will fix the documentation.

Ok, thank you!

I’ve tried to supply an array of strings, but got the same error. Do you have a working sample?

Another question. If I’m only using the predefined variables (C0, C1…), do I need to expose them through propsListedInLobby or they are already exposed in the lobby?

Br,

Cleverson

After using the Array type explained above, the error message is gone. Thanks!

But matchmaking doesn’t work yet. I checked both samples you mentioned, but I couldn’t find what I need there.

This is the code I’m using to create a room now:

self:createRoom(nil, {maxPlayers = 2, lobbyType = loadBalancingConstants.LobbyType.SqlLobby, propsListedInLobby = Array.new("C0"), customGameProperties = {["C0"] = gameModel.trophies}});

When another player joins the room, this is the code I’m using:

local sqlFilterString = "C0 \> "..tostring(lowerLimitForTrophies).. " and C0 \< "..tostring(uperLimitForTrophies); self:joinRandomRoom({lobbyType = loadBalancingConstants.LobbyType.SqlLobby, sqlLobbyFilter = sqlFilterString});

The values for lowerLimit and upperLimit are currently 50 and 100 in my tests. But, no matter which level the players are, there is always a match. Can you tell what’s wrong here?

Br,

Cleverson

I’ve tried a lot of alternatives, but I couldn’t make matchmaking work.

Exit Games? Could you help out?

Please add lobbyName string item to options list in both calls. Lobby name is mandatory for sql lobbies. Or more precise, default nameless lobby is not an sql lobby.

Thanks for the answer.

I’m not sure if I’m understanding how to set up the matchmaking process. Should the lobby names be unique? I mean, if they need to be unique, I will create random names (something like “my_lobby_”…math.random(1000)). If I do that, how the player who will later join the room will know the lobby name?

All players should join the same single lobby if they want to see each other’s rooms.

Just hardcode any constant name you like.