question

Jan Vacek avatar image
Jan Vacek asked

Azure functions global access to CurrentPlayerId

Hello, in classic cloudscript, there was a full-global access to variable CurrentPlayerId, which contained the ID of player used for playfab calls such as getting user's inventory.

Now in typescript Azure Functions, it is passed by parameter in request. I want to make i globally accessible, something like set it to global variable and then be able to use it across whole lifecycle of the function.

But somehow I cant get it working, can you please help me how to properly set CurrentPlayerId to a global variable and access it anywhere?

Im using JS/TS

Thank you!

CloudScript
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

·
Gosen Gao avatar image
Gosen Gao answered

The CurrentPlayerId is in the request body of your Azure Function, you don’t have to define it or pass it as a parameter, you can obtain it directly with code below.

req.body.CallerEntityProfile.Lineage.MasterPlayerAccountId
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.

Matt avatar image Matt commented ·

req.body has no such CallerEntityProfile...is this method even correct or are we supposed to use the FunctionExecutionContext?

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.