question

MoonHeonYoung avatar image
MoonHeonYoung asked

currentPlayerID and Context parameters

When I call executeCloudScript on the client, I understand that I can use the currentPlayerId property in cloud code.

However, can I use the currentPlayerID property when calling a cloud script from'Game Manager'?

For example, can I use the currentPlayerID property instead of the context parameter

when calling a cloud function from a rule, task, or individual player tab?

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

·
Sarah Zhang avatar image
Sarah Zhang answered

>> However, can I use the currentPlayerID property when calling a cloud script from'Game Manager'?

Yes, when you call the CloudScript function in the Player Tab, the currentPlayerId would be the id of the player you select.

>> For example, can I use the currentPlayerID property instead of the context parameter.

You can’t use the currentPlayerId instead of the context, they are different concepts. As this section said, currentPlayerId is a global variable, which is set to the PlayFabId of the player requesting this call. The context would contain the caller’s Profiles. When the Cloud Script function is called from a PlayStream action, context would also contain the information of the event.

>> when calling a cloud function from a rule, task, or individual player tab?

Yes, CurrentPlayerId can be used when the CloudScript is called from the Scheduled Tasks, Player Tabs or Rules that triggered by player events.

1 comment
10 |1200

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

Ben avatar image Ben commented ·

The last part isnt working for me, I cant save the rule with "CurrentPlayerId" Argument:

I google for 2 days now but cant find an answer.

I get this error if I use CurrentPlayerID:

  • An error occurred while loading data from the server. PlayFab engineers have been notified of the issue and will investigate.
[FunctionName("UpdateStatisticPoint")]
        public static async Task<dynamic> UpdateStatisticPoint([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log)
        {
            var context = JsonConvert.DeserializeObject<FunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync());
            var args = context.FunctionArgument;

            var argsPlayerID = (string)args["profileID"] ?? string.Empty;
            var profileID = string.IsNullOrEmpty(argsPlayerID) ? context.CallerEntityProfile.Lineage.MasterPlayerAccountId : argsPlayerID;
            var statisticName = (string)args["statisticName"] ?? string.Empty;
            var value = (int)args["value"];

            var serverApi = new PlayFabServerInstanceAPI(FabSettingAPI);

.....
0 Likes 0 ·
screenshot-67.png (11.9 KiB)

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.