Since players only have their own EntityToken at the title_player_account level on the client side, calling GetObjects API on the client side will only return the caller's own data object. But you can call GetObjects API in Clould Script for Cloud Script holds a title-level entity token, which has the permission to get any entity objects. And, since the GetObjects API is an Entity API , you can call the GetObjects API with “entity” global variable defined in the CloudScript , you can find the entity corresponding code snippet in the Cloud Script default version. When you want to call this cloudscript method on the client side, you need to call ExcuteCloudScript.
In addition to calling CloudScript methods you can also modify the global entity policy in title settings->API feature to allow the client to get other player’s object directly. The code is as follows:
{ "Action": "Read", "Effect": "Allow", "Resource": "pfrn:data--*!*/Profile/Objects/*", "Principal":"*", "Comment": "Allow objects profile access", "Condition":null }
The code in Cloud Script:
handlers.GetOtherDataObject=function(args,context) { var result=entity.GetObjects({ "Entity": { "Id": args.id, "Type": "title_player_account", "TypeString": "title_player_account",} }); return result.Objects; }
The C# code example to call this function:
public void Test(string ID) { PlayFabClientAPI.ExecuteCloudScript( new ExecuteCloudScriptRequest { FunctionName = "GetOtherDataObject", FunctionParameter = new Dictionary<string,string>{ { "id", ID } }, }, result => { Debug.Log(result.FunctionResult); }, error => { Debug.Log("failure!"); } ); }
13 People are following this question.