Checking if an interest group is empty

Options

Hi there!

My team and I are looking to integrate use of interest groups for a client project using PUN 2, and we're having an issue figuring out some of the syntax for using interest groups.

We'd like to allow players to group together by sharing a code. Everyone joins the same room, then one person 'creates a team' and the others 'join the team' by using the code generated by the first player creating a team. That player will be assigned a random 5 digit code, which will set in the Room properties a corresponding interest group number. So let's say player one is randomly assigned "56789" and interest group "2" the other players will type in "56789", it will check to see a Room property exists with that code, and return '2'. The other players will then be added into interest group 2.

However, we can't find a way to check if (for example) interest group 1 is already being used. The goal is to check if an interest group is being used, and if it already has a player in it, move onto the next interest group number.

Is there a way to check if an interest group already has players subscribed/exists?

Thank you!

Answers

  • Tobias
    Options

    There is no way to check if anyone subscribed to an Interest Group.

    If this is essential, you could allow players to ping others, which reply with some event in said interest group. Make sure clients can only "ping" and "reply" once per second or so or you built a mechanism to flood the Interest Groups.

    There is also no way to check which Interest Groups are taken. Use the properties to check which ones are taken. Let only the Master Client change these pairings.

    Side note: Everyone knows all Custom Room Properties and is able to change and remove them. This opens doors for attacks.

    You could possibly use each player's ActorNumber as ID for an Interest Group, then you don't need a random number and such. I didn't fully understand the idea of said number...

  • botjungle
    Options

    Hi Tobias! Thank you so much for the reply!

    Good point about the Custom Room Properties.

    Using the player's ActorNumber sounds like a great solution, my understanding is the Interest Groups will always need to be under 255, are the ActorNumbers always below 255? I'll dig more into those!

  • Tobias
    Options

    The ActorNumber always start at 1 and go up. If a room had over 200 players, it might be good to make it invisible and let other player use a new one instead of keeping one open for a very long time.