question

brendan avatar image
brendan asked

How to trigger an event on a VC change

Question from a developer:

I'm trying to set up a Rule in PlayStream that triggers when the virtual currency balance for a player hits a specific value via the "player_virtual_currency_balance_changed" event. What do I need to set as the Condition for this?

PlayStream
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

You can specify any parameter name from the event as the Field Name for the Condition. If you have a look at the parameters of the "player_virtual_currency_balance_changed" even, you'll see that there's a "VirtualCurrencyBalance" which is where the new balance is returned. If you use that, set it to "numeric value", "is", and the value you want, that should get you the results you're looking for.

7 comments
10 |1200

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

developerjazzhaq avatar image developerjazzhaq commented ·

Hi Brendedn,

But i have two separate virtual currency. I want to check value of the specific one only. How to fo that?

0 Likes 0 ·
brendan avatar image brendan developerjazzhaq commented ·

In that case you would also add a check that the parameter "VirtualCurrencyName" in the event is set to your virtual currency's two-letter name.

0 Likes 0 ·
developerjazzhaq avatar image developerjazzhaq brendan commented ·

Ok got it.. but where can i find these variables like VirtualCurrencyBalance and VirtualCurrencyName ?

0 Likes 0 ·
Show more comments
yabatatagames avatar image yabatatagames commented ·

I'm trying to send push notification when a currency is recharged.
So I added a rule just like this and I was surprised to reveal that player_virtual_currency_balance_changed is triggered just when the user logs in. is this the expect behavior of this events?

0 Likes 0 ·
brendan avatar image brendan yabatatagames commented ·

Events are triggered by active calls to PlayFab. Regenerating VC balances are not computed every second - doing that across millions of players, whether or not they've signed in for the last N days/weeks/etc., would require massive computing resources. Instead, they are recomputed when needed (getting the current balance, adding/subtracting, making purchases).

To notify a player that a regenerating virtual currency is full, what you should do is compute when that will occur based upon the current balance, regeneration rate, and next regeneration "tick", and schedule a local notification to occur at that time (for example, here's Apple's version: https://developer.apple.com/documentation/uikit/uiapplication).

0 Likes 0 ·
yabatatagames avatar image yabatatagames brendan commented ·

Got it, thanks.

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.