Limiting number of async matches
Here's how I have it working at the moment:
- If player has less than 3 matches, allow creation of a new game.
- Player looks for an opponent that has matchmaking enabled.
- If an opponent is found, make a match. Matches can be made whether the opponent is offline or online, doesn't matter.
- If NO opponent is found, set player's matchmaking to true. Waits for an opponent to make a new game.
- Find matches you belong to that are not EXPIRED or COMPLETE.
- Select a match from these matches and load the game for the client.
I would like to limit the number of matches any user can have at a given time to 3. The problem is that when you match with an opponent, their matchmaking will still be enabled if they are offline. Other users can match with them, potentially putting the offline opponent over the match limit of 3. I could not find a way in the API to disable matchmaking for another user that is offline with these conditions.
Is there any way to do this, or some trick I am missing?
You may write a pre-hook cloud code script with your validating logic and integrate it with
Thank you! I will try that out.
Just for anyone else's future reference, I realized you can "log in" as another user using GetSessionForProfile(). So if the other user is offline, you will be able to modify their data (for example, to increment an attribute for number of matches they have).
I believe this way, you can also do what JasonL said and TurnShieldOn() for the other user, stopping them from being able to match anymore.
Correct me if I'm wrong.