question

Benjamin Bennett avatar image
Benjamin Bennett asked

SubtractUserVirtualCurrency only subtracting 1

Hello, I'm running into a very strange bug?

I'm running a SubtractUserVirtualCurrency request in an azure function. The balance being returned from the function is correct, but on the playfab dashboard the value is only reduced by 1.

For example if I have 100 "GO" and I run this script with a cost of 5.
95 is returned from the spendResult.Resutl.Balance.
However the balance on the PlayFab dashboard for that player shows 99

I can't think of anything on my end that would cause an issue like this.

var spendResult = await server.SubtractUserVirtualCurrencyAsync(new SubtractUserVirtualCurrencyRequest()
{
    PlayFabId = context.CallerEntityProfile.Lineage.MasterPlayerAccountId,
    Amount = cost, // 5
    VirtualCurrency = "GO",

});

if (spendResult.Error?.ErrorMessage != null)
{
    return new {success = false};
}

return new {success = true, amount = spendResult.Result.Balance};
2 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.

Benjamin Bennett avatar image Benjamin Bennett commented ·

I also tried enabling "Allow Client to Subtract Virtual Currency" and the same behavior exists when running the code in the client

0 Likes 0 ·
Benjamin Bennett avatar image Benjamin Bennett commented ·

Okay so upon further investigation it looks like the value on the dashboard is actually just offset... so if you put in 20 on the amount the amount is offset by 2 (only subtracts 18).

I'm a little nervous to put cost + 2 here because if you guys fix it on the back end it will cause issues down the road

0 Likes 0 ·

1 Answer

·
Gosen Gao avatar image
Gosen Gao answered

May I know how you configure the Virtual Currency “GO“? If you have set the Recharge rate, then it will automatically increase the Virtual Currency balance, which may make you think the SubtractUserVirtualCurrency API doesn’t work well.

3 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.

Benjamin Bennett avatar image Benjamin Bennett commented ·

There is no recharge rate on it. Just a default virtual currency

0 Likes 0 ·
Benjamin Bennett avatar image Benjamin Bennett Benjamin Bennett commented ·

Here is what it looks like

0 Likes 0 ·
gold.png (29.1 KiB)
Gosen Gao avatar image Gosen Gao Benjamin Bennett commented ·

When the virtual currency changes, events "player_virtual_currency_balance_changed" will be generated. You can navigate to the Data Explorer - PlayFab | Microsoft Docs to check this event to see if there any other actions change the virtual currency when you try to subtract it.

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.