question

Ben avatar image
Ben asked

Rules - JSON Arguments not working

Hello!

I want to call a azure function when a player is logged in.

The function expects the playerID, but when I use "CurrentPlayerId", I just get this error:

  • An error occurred while loading data from the server. PlayFab engineers have been notified of the issue and will investigate.

The function is working if I pass a unique ID as string, but I need to use "CurrentPlayerId". Is there something wrong with my arguments?

This isnt working:

screenshot-67.png (11.9 KiB)
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 ·

I tried a little more and "CurrentPlayerId" cant be saved only when I choose "com.playfab.play_logged_in" as Event type, BUT if I choose a different event, I can save my JSON Arguments, but nothing happens...

Lets say I use the focus changed one (just for testing), nothing happens after focus changed.

Im pretty lost with those rules, nothing seems to work for me, I try to get something running for 2 days now. My azure functions are working perfectly fine through client calls, but I cant get those rules to work.

0 Likes 0 ·

1 Answer

·
Made Wang avatar image
Made Wang answered

To clarify, CurrentPlayerId is used in Cloud Script (legacy) as a global variable, but it does not work in Azure Function Cloud Script.

Referring to PlayFab CloudScript using Azure Functions Context Models - PlayFab | Microsoft Docs, in Azure Function Cloud Script you can get the PlayFabId from the context. It should be noted that different calling methods correspond to different contexts. Since you are calling the Azure Function Cloud Script through the rule, you can refer to the following code to get it.

PlayerPlayStreamFunctionExecutionContext<dynamic> context = JsonConvert.DeserializeObject<PlayerPlayStreamFunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync());
var playfabId = context.PlayerProfile.PlayerId;
10 |1200

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

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.