question

Simon Atkey avatar image
Simon Atkey asked

Reading other players' title entity files

Hi, my players have an entity file in their title player account. I'm able to get them to read their own file ok, but I need players to be able to read the file of others.

I'm having two issues in relation to this

1) I'm unable to get the local player to find someone else's title ID. I'm loading a leaderboard, which a player can use to access other players' master IDs, but not sure how I can get the title IDs from that. Is there any way to achieve this?

2) When I try to access someone else's master player data I get an error saying the player doesn't have access to these files. I imagine if I can solve 1), I'll have a similar access issue. How can I get it so that any player can read any other player's title entity data?

Perhaps I'm trying to go about this the wrong way? For context, I'm making a racing game where the leaderboard has the best times of all the players, and the title entity data is 4kb worth of data which is essentially a run-through of the player's best race. I want any other player to be able to download this data, so that they can essentially race against someone else's best run.

Thanks

Leaderboards and StatisticsTitle Dataentities
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

·
Simon Atkey avatar image
Simon Atkey answered

Ok, I've managed to get somewhere with this, but still not quite there.

For anyone else interested, the answer to 1) was to make a GetTitlePlayersFromMasterPlayerAccountIds call (I only need this for one player in the leaderboard, so I don't mind making an extra call).

I thought I had also solved question 2). I added the below code to the entity global files policy. This appeared to work - I no longer got a 'not authorized' message when trying to make calls from other players, however the calls always return 0 files, even though I can see the file for the player in the browser game manager. I think the code below is probably missing something Any ideas?

{
    "Action": "Read",
    "Effect": "Allow",
    "Resource": "pfrn:data--*!*/Profile/FILES/*",
    "Principal": "*",
    "Comment": null,
    "Condition": null
}

3 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.

Simon Atkey avatar image Simon Atkey commented ·

Update number 2 for anyone interested. Looks like the player also has to have a title player account policy allowing read access to the specific file. I've set this through the browser and have managed to get it working. Hopefully shouldn't be too hard to work out how to do this via script when the player first creates the file.

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Simon Atkey commented ·

I believe you are on the right track. Feel free to let me know if you need any other help.

0 Likes 0 ·
nguyenhoainam avatar image nguyenhoainam Simon Atkey commented ·

you can update policy in C#:

var request = new SetEntityProfilePolicyRequest()
            {
                Entity = new PlayFab.ProfilesModels.EntityKey()
                {
                    Id = myEntityId,
                    Type = myEntityType,
                },
                Statements = new List<EntityPermissionStatement>(new EntityPermissionStatement[] {
                    new EntityPermissionStatement()
                    {
                        Action = "Read",
                        Effect = PlayFab.ProfilesModels.EffectType.Allow,
                        Principal = "*",
                        Resource = string.Format("pfrn:data--title_player_account!{0}/Profile/Files/{1}",
                            myEntityId, "*")
                    }
                }),
            };
            PlayFabProfilesAPI.SetProfilePolicy(request,
                result =>
                {
                    Debug.Log("success");
                }, error =>
                {
                    Debug.LogFormat("error msg={0}",
                error.GenerateErrorReport());
                });
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.