question

kennyroy avatar image
kennyroy asked

Possible to query all users for the same characterID?,Can I query all character IDs on a server?

Is it possible to get a list of all users that have the same characerID? Like say if playfabID 98333765432 and 98333765433 both have characterID 9874325, could I find that out?

,

I know that to access the unique character, I need playfabID.characterID, but is it possible to return a list of all characterIDs that are shared? Like if playfabID 98333765432 and 98333765433 both have a character ID of 3345677, could I find that out?

Character DataCharacters
10 |1200

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

pfnathan avatar image
pfnathan answered

No, it is impossible to associate one character to multiple PlayFab players. It is not possible to define the ID of any Entity when you create it, as all PlayFab Entities of all types are given random IDs. It is also generally not possible to look up a single Entity by just its id alone, at this time.
For your question specifically, characters should not be used as a global index. We discuss some workarounds in the comments below, but those should also be considered WORKAROUNDS, and not a real solution that will work at scale.
The "official" answers for this would be "don't, because it probably won't scale well." If you know how to solve your scaling issues, this can be solved with a custom database (like mongodb or others), accessed through cloud script, or a custom game server.

8 comments
10 |1200

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

kennyroy avatar image kennyroy commented ·

Damn, I've been constantly hovering around Playfab for 3 years now; all I need to use it for my game is just one way to access a single class across multiple users. I need to be able to check just a few values from the server, and I thought that the new characters might be the way to do it. So there's still no persistent, unique data accessible cross-users on Playfab? I don't want to have to code, setup, and support my own server JUST for the few fields I need stored.

0 Likes 0 ·
pfnathan avatar image pfnathan ♦ kennyroy commented ·

Can you let us know what is your use case is? If you need to check multiple character value, you can accomplish with statistics and we can find a solution for you without having to code, setup, and support your own server for simple data, just need some clarification on use.

0 Likes 0 ·
kennyroy avatar image kennyroy pfnathan ♦ commented ·

I have multiplayer 'realms' that are actually just randomly generated integer-named photon rooms. The room numbers seed the realms' procedural generation. When a player wins in the realm, they claim the realm by putting a flag. This grants them more idle-resource collection. I just need to store that realm's integer as being owned by a player so when another player joins a random room and it happens to be already claimed, the owner of the realm is notified so they can return and defend it.

I thought characters would be perfect for this when I heard about it. player A clicks "play" and is sent to Photon room 292312939, which also seeds the generation of the procedural world using the integers (so everyone sees the same). He plants his flag, which creates playfab "CharacterID 292312939". He leaves, and when another player comes along, I check on playfab if any other player has characterID 292312939. Seed the realm, notify the owner his realm is under attack, etc. As you can imagine, I'd prefer not to code, setup, maintain servers just to store a few ints when I'm doing EVERYTHING else on playfab

0 Likes 0 ·
Show more comments
kennyroy avatar image kennyroy commented ·

Paul's guide below for using "Players" and not characters seems like it will work. But just so that I'm sure I got it right, is this my step by step?

  • Human Player A plays the game, and is sent to random Photon rooms with integer names.
  • API checks if there's a PlayFab player with that room's ID. If no player exists with that room's ID, create an Automated Player using the int as that "player's" CustomID. These "players" are referred to as "realms" hereafter.
  • The realms' playerData includes a field of "owner" that is same data type as the identifier of my human players.
  • Player A "claims" the realm in game by performing in-game tasks.
  • Cloudscript sets the realm's "owner" data to Player A's playerID.
  • In game, Player B gets sent to the same photon room using photon's matchmaking.
  • Only upon being granted access by passing Photon's checks, they make an API call to see if the room's ID exists as a playerID on PF.
  • Since it was already created above, check the owner's ID, load their flag and other playerData used to customize the in-game models.
  • If Player B wins and claims the realm, the realm's "owner" ID is changed to Player B's playerID, and we go around like this ad infinitum.
0 Likes 0 ·
1807605288 avatar image 1807605288 ♦ kennyroy commented ·

Just a clarification: A realm should only use internal-data. It should never use playerData, as that would be hackable with this implementation.

"they make an API call to see if..." This should be run off the Photon "join" webhook if possible, and not directly from a player (because that's hackable).

"Since it was already created above, ... " not really sure what you mean by this point?

NOTE: you can only make 3 playfab API calls per Cloud Script, so you're going to have to be very careful how you implement this.

Conclusion: Overall, I fear that this workaround isn't going to be secure. A hacked client could call any Cloud Script callable by the client, and take over rooms that they shouldn't have access to. If there are any Cloud Script calls which result in realm ownership changing hands, then it's not safe from hackers. You should only do this logic from a game-server, if possible.

The only "safe" action for a client-called Cloud Script is to read the state of a realm (and only if it's not being read from lots of players at once). Anything that results in writes has to be called from secure machines.

0 Likes 0 ·
kennyroy avatar image kennyroy 1807605288 ♦ commented ·

Ok thanks again for the detailed help. Back to the drawing board on this.

0 Likes 0 ·
Show more comments
1807605288 avatar image
1807605288 answered

I want to clarify some terminology, just in case there's some confusion.

A Player is an account for a person playing a Title(your game) on a device. A Player can have data, vc, stats, etc. A Player can also have multiple Characters. Characters are sub-entities for a Player, and can also have data, and such.

A Player (also called User, same thing) is identified by PlayFabId, and is globally unique. If you have 3 Titles within a single Studio, the PlayFabId will be the same for all 3 Titles. You can access PublisherData to share info between those Titles.

A Character is identified by CharacterId, and is globally unique. Two Players should never have a character with the same CharacterId.

You can put some data on a character to identify it somehow as a specific "type" of character.

I can't tell if you're looking to identify a single Player across multiple Titles (which we support), or identify a single Character across multiple Players (which we do not, and doesn't make sense to me).

9 comments
10 |1200

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

kennyroy avatar image kennyroy commented ·

"A Character is identified by CharacterId, and is globally unique. Two Players should never have a character with the same CharacterId."

The docs say "CharacterIds are not globally unique; characterId must be evaluated with the parent PlayFabId to guarantee uniqueness."

Now I'm confused. See below for my use case.

0 Likes 0 ·
1807605288 avatar image 1807605288 ♦ kennyroy commented ·

That was an old possibility, which was extremely unlikely, but possible. New code we're releasing for GDC this year relies on characters being globally unique.

You could never specify the characterid of a character when you create it.

0 Likes 0 ·
kennyroy avatar image kennyroy 1807605288 ♦ commented ·

Ok I read your response below and I'll try to consider a way to do this. Thanks for the help

0 Likes 0 ·
1807605288 avatar image 1807605288 ♦ kennyroy commented ·

What you're really looking for is a global index. We don't support these out-of-the-box, because they don't perform well at scale. If 1000, or a million players are all trying to access the same room, your whole game breaks. It doesn't matter HOW you implement it, it will break.

We don't prevent you from accessing your own mongodb or other global lookup mechanism from cloudscript (which is a potential way), but I'll reiterate, once you scale above a certain number of players, it won't work anymore.

0 Likes 0 ·
kennyroy avatar image kennyroy 1807605288 ♦ commented ·

The game only allows 8 players into a realm, using a check on Photon. Once granted access to the room, I'm assuming that it would be an easy call to playfab to check the "player" (realm) ID for who owns it, if anybody. So there would only be a maximum of 8 people calling a playfab playerID, and only upon being granted access to a photon room.

0 Likes 0 ·
Show more comments
1807605288 avatar image 1807605288 ♦ commented ·

Sorry for swapping around the accepted answer on you. I wasn't sure what answer you were looking for right away, and the question/answer combos should ideally be readable to future readers.

0 Likes 0 ·
kennyroy avatar image kennyroy 1807605288 ♦ commented ·

No problem, the accepted answer is fine, but I'm going to write my step by step up there so I can be sure.

0 Likes 0 ·

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.