question

malsowayegh avatar image
malsowayegh asked

Cloud Script to take player of the week and write it in title data

I have in title data "game_config" as a key that have "player_of_the_week".

I want with each reset of my weekly leaderboard to set the playerID or username in that using cloudscript. which I will use with the reset of leaderboard as an action to execute the cloudscript.

Question One: how can I use player Id of rank 1 in leaderboard as an argument for the action?

Question Two: how can I implement a script that will set the title data for the "game_config"?

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

·
brendan avatar image
brendan answered

Sure:

1. As long as it's only going to be the one update to Title Data, and only on reset of the leaderboard, you could have a Prize Table with only one entry: For players in rank 1 to 1 (so, only the #1 player), you could run a Cloud Script to update that data, using the profile PlayerId from the context (https://api.playfab.com/docs/tutorials/landing-automation/using-cloud-script-actions-with-playstream).

However, question on that one - what specifically will players be doing as a result of that? If there's any chance you'll have players querying data from that player, you'll need to cache that data in the Title Data as part of that script, as well. Otherwise, you could have a case where tons of players are all trying to query that player's data all at once - which would cause severe delays in responses, as player data is not a sharded and cached resource (like Title Data).

2. Use the Server API call UpdateTitleData. There's an example showing how to make Server API calls from Cloud Script in the revision 1 that is automatically part of all titles.

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.