Koen avatar image
Koen asked

Multiple friend / user group leaderboards

We want to make a game in which the user is able to create user (friend) groups. When a user creates a group, all those users should know they're a part of the group and that they can see all the other users of the group.

We want it to be possible to show leaderboards per group (sort of like a Friend Leaderboard).

How can we accomplish this using just PlayFab (there's no budget for an external server)?

1. How can we create these user/friend groups?

Do we create a new SharedGroupData that contains all the users PlayFab IDs and add the SharedGroupData ID to the ReadOnly data part of all the users (a JSON array for example)?

2. How can we show leaderboards per group?

Do we call GetLeaderboard multiple times until we have the ranking of every user in the group or do we have to make all users each others friend (multiple AddFriend calls) and just call GetFriendLeaderboard and filter that list with the selected group (by checking the SharedGroupData or perhaps add FriendTags to everyone to check in which groups they belong)?

Leaderboards and StatisticsShared Group DataFriends
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

brendan avatar image
brendan answered

What you're describing aligns well to a guild/team type of system. We do plan to provide a guild system in a future update, but we do not have that available right now. So you would need to implement this using external data tables, though you could use Photon Realtime for connecting players in online "rooms" for realtime connectivity (and/or Photon Chat, if you want to give them chat rooms).

Shared Group Data is basically player data, but without an associated player. It was added specifically to provide a non-player data system that could be used as a shared space between a small number of players (async game save state was the original request). It cannot be used for cases where you need to have a large number of players reading from or writing to it, as it is not sharded or cached in any way.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Koen avatar image Koen commented ·

Sadly we can't wait for the guild system to be released. Our groups won't be that large, think 12 people at maximum. The groups will only be used as a 'extra filter' for the leaderboards. We won't have chat for example or other data that will be written to the SharedGroupData. It's an asynchronous multiplayer game (of some sorts), no realtime multiplayer so Photon is not an option.

So is it possible to have an 'extra filter' for leaderboards that will be shown to the user as friend groups?

For example: User A creates a friend group and adds 4 other players (8 max). A 'friend group request' is added to the other users' UserData. When a user accepts the request, a cloud script is run to add all users of the group to the friend list.

Then, when a user requests a leaderboard of a certain friend group the GetFriendLeaderboard is called and filtered locally with the users of the selected group.

0 Likes 0 ·
brendan avatar image brendan Koen commented ·

There isn't a guild/team system built into PlayFab right now. If you are 100% confident that the number of players in the group will always be very small, you could use Shared Group Data to share data between players. There is, however, no built-in system for an "extra filter" on leaderboards. That's not to say you couldn't apply one directly, but it is not directly supported by the platform (nor is updating a single statistic by multiple players).

For real support of guild/team systems, I would recommend either waiting on our built-in guild support, or else using an external data table that provides consistency across all player writes.

0 Likes 0 ·
Koen avatar image Koen brendan commented ·

Thanks for the reply, just in case of miscommunication: the 'extra filter' just means a subset of users, so I want to be able to see a leaderboard of only the users in my group/clan/guild. The group doesn't have a cummulative score that should have their own leaderboard. And yes we can enforce the groups to be very small (max x users).

Do you think my example/use case is viable?:

  • Use the SharedGroupData to know which users are in a group
  • Add the group SharedGroupData ID to the UserData of all users of the group (to know in which groups you are added)
  • Add all users of a group to the friend lists of the other users, in order to use the GetFriendLeaderboard call
  • Filter the GetFriendLeaderboard call result locally with the users of the group

Or do you think it's best to use multiple API calls to retrieve the statistics of the users of a group and order them locally and show that as our leaderboard? This way we won't have to make all users friends of each other.

Edit: so we don't really need a 'real' guild/team system, just use a 'team' as a way to filter leaderboards.

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.