question

frozenvortexgames avatar image
frozenvortexgames asked

Setting the currency of a player to an existing statistic?

Hi,

I am working on adding inventory items to my game via PlayFab.

I have ran into a problem as my game has already been out for some time.

Is there a way for me to set the currency of a player to one of their statistic values?

I have thought about doing maths once they log in to the newer version for the first time to figure it out, would that be the best way to do it? or is there some code that I could run, like a cloudscript on all players at once or only as they log in for example?

Thanks and if you need any more information, feel free to ask!

Regards,

Brandon

Player DataCloudScriptLeaderboards and StatisticsPlayer Inventory
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

For a game that has been client-only up to now, or where the data is in another service, I would recommend setting the player's VC balance in Cloud Script using the Server/AddUserVirtualCurrency API call (don't turn on the client version). You could either do this via a PlayStream Rule on the player_added_title event, or via an OnFirstPlay handler that you call from the client, setting a value in the User Internal Data when you're done, to make sure they can't use it later to get more currency.

If you mean that you've been tracking VC in a statistic in PlayFab up to now, you could still do exactly that, using the statistic value. But you could also use a Task that calls a Cloud Script handler that performs this task, and then run it against the Segment "All Players" in your title.

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.