• Sign Up Login
  • Features
    • Game Services
    • Real-time Analytics
    • LiveOps
    • Add-ons
  • Game Services
  • Real-time Analytics
  • LiveOps
  • Add-ons
  • Games
  • Pricing
  • Blog
  • Support
    • Docs
    • Forums
    • Contact
  • Docs
  • Forums
  • Contact
  • Sign Up Login
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Ideas
    • Articles
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by lukewaffel · Sep 01, 2017 at 07:01 AM · apisCloudScriptPlayer Inventory

CloudScript check user VC before subtracting?

Hi there!

First of all, I've used PlayFab a few years back and I totally loved it. But seeing how far you guys have come, wow! It's truly amazing to see the amazing changes this service has gone through. Congratz guys!

So, for my question. (Hopefully) soon I'll start the design and development of a new multiplayer game. And because I have had so many good times with PlayFab, I'll obviously choose PlayFab as the player management backend. Ofcourse my game will incorporate purchasable items and stuff like that, so I'd like to handle these using the CloudScript feature. Since CloudScript has full access of the server API it's able to remove VC, grant items, and other stuff. There was one thing I couldn't find however. That's the possibility to check the user's (or character's) current VC. I thought maybe the subtract currency will give an error if there isn't enough VC left, but I could only see errors for InvalidVirtualCurrency and InvalidParams.

Is there any way to check if there is enough VC left before subtracting it? Also, what will the SubtractVC function return if there isn't enough? Just 0?

Thanks for creating this awesome platforms guys!

Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Brendan · Sep 01, 2017 at 07:05 AM

Thanks! My first question would be, why not just define the VC prices in the catalog directly, and use PurchaseItem? That way, you wouldn't have to worry about that at all.

The virtual currency system is specifically designed to be flexible, and to allow currency to go negative, if you're using the Subtract... API call. It's only if you're using PurchaseItem that we ensure the transaction only takes place if the player has the VC. If you want to check the player's VC balance, you can get it from a call to get the player's inventory, or you could just use the GetUserVirtualCurrency option in the InfoRequestParameters of the GetPlayerCombinedInfo API call.

Comment

People who like this

0 Show 2 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lukewaffel · Sep 01, 2017 at 03:50 PM 0
Share

My fault, I didn't even think of that. I was thinking about using cloud script to make everything more secure, but sending a purchase item request from the client would be just as secure right? Since you wouldn't have to manually supply the currency in the request since it's retrieved from the stored player data on the playfab servers.

avatar image Brendan ♦♦ lukewaffel · Sep 01, 2017 at 03:51 PM 0
Share

Correct - we take care of making sure the player has enough VC, grant the item, and remove the VC from their balance.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    2 People are following this question.

    avatar image avatar image

    Related Questions

    Getting item,How to get ItemInstanceId in GrantItemsToUse 1 Answer

    UnlockContainer and CloudScriptAPIRequestError 1 Answer

    script exrcution problem 5 Answers

    CloudScript Errors on server api calls 1 Answer

    client API security feature requests 1 Answer

    • PlayFab

      • Features
      • Games
      • Pricing
      • Blog
    • Engineers

      • Documentation
      • Quickstarts
      • API Reference
      • SDKs
      • Usage Limits
    • Support

      • Forums
      • Videos
      • Contact
      • Service Health
      • Terms of Service
    • Social

      • Facebook
      • Twitter
      • LinkedIn
      • YouTube
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • About Microsoft
    • Jobs
    • Accessibility
    • Diversity & inclusion
    • Security
    • Company news
    • © Microsoft 2019
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Post an idea
    • Create an article
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Ideas
    • Articles
    • Users
    • Badges