Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by bhester · Jul 30, 2021 at 04:13 PM · In-Game Economy

Complex Inventory System

Hi,

We are currently looking at moving our game over from Gamesparks to PlayFab and wanted to check on best practices for our players inventory.

In our game, a player unlocks chests which earn players cards. Once a player has enough cards they can Unlock an item by using thier cards and spending coins or gems.

We store the 'meta' data of items in the Title Data. An example of an item:

"Item_3": {
    "DisplayName": "NAME",
    "UnlockLevel": 0,
    "CardsCost": 10,
    "CoinsCost": 500,
    "Rarity": 0,
    "SkillsData": {	
"SomeSkillData":123 }, "Stats": { "SomeStats":123 }, "Levels": [ { "CardsToUnlock": 4, "CoinsToUnlock": 600 }, { "CardsToUnlock": 4, "CoinsToUnlock": 700 }, { "CardsToUnlock": 4, "CoinsToUnlock": 800 } ] }

We can use the above to show our inventory screen, and how many coins/cards players need to unlock items for example.

We are also currently storing the Player inventory in each players Player Data like so:
key = itemInventory

"Item_3": {
    "Level": 0,
    "NumberOfCards": 40,
    "SkillCharge": 3,
    "bUnlocked": false
  },

We can then grab both of those when users attempt to unlock/upgrade in the cloudscript to check they have enough currency and cards for example.

We also update the Player Data if the user unlocks chests and earns cards for specific items in the Cloud scripts.

However, we also want to do a similar process for when a user makes an IAP. Our IAPs could contain some cards for an item, the whole item itself, currency, chests amoung other things. But I can't find the best way to have the IAP award things like cards to the Item_3 in Player Data for example. When the purchase is validated, is there any kind of response that is hit in the API for a player that we can then award them our specific goods for. Or will we need to somehow use the Catalog system in PlayFab?

If we have to use the catalog system, would our use case be viable or will it require a lot of reworking?

Thanks,
Brad

Comment
bhester

People who like this

1 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 Rick Chen · Aug 02, 2021 at 08:36 AM

In PlayFab, the IAP needs to be implemented with the Catalog items. When the validation API is called and if the purchase is successfully validated, the PlayFab items in that order will be granted to the player, along with relevant events, purchase history and Value-to-Date being recorded for that player. That is by design. So yes, you need to use the Catalog system to implement IAP in PlayFab. Please refer to this document for more detail: Getting started with PlayFab, Unity IAP, and Android. If you don’t want to change your current configuration that stores player inventory in Player Data, you could write a CloudScript function that consumes the item purchased via IAP and update the corresponding Player Data.

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 bhester · Aug 02, 2021 at 03:05 PM 0
Share

Thanks for the reply.

So if a player buys my 'AugustPromotionPack_1' for example, I can setup a catalog item for that. Then when the IAP is processed it awards my player that item.
On a successful purchase, we then execute another cloudscript function that checks for any catalog goods that have been awarded and consumes them - awarding the correct content based on the pack type?

Does PlayFab have any 'callback' or 'response' events by default that we can add CloudScript code to? For example, when a player registers for the first time, or makes an IAP, is there something we can add to the CloudScript which is automatically called so we can do specific cloud script actions?
Or will we have to check for the response on the client and call our own cloudscript functions from there instead?

avatar image Rick Chen ♦ bhester · Aug 04, 2021 at 07:32 AM 0
Share

The IAP purchase could generate some events, for example, player_realmoney_purchase. You can setup a rule on this event such that when this event is fired, the actions you configured in the rule will be executed. Please refer to this document for more detail: Actions and rules quickstart.

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

    5 People are following this question.

    avatar image avatar image avatar image avatar image avatar image

    Related Questions

    How to add PayPal to a game 1 Answer

    Does PlayFab support Facebook Instant Games payments? 2 Answers

    About Coupon uses 1 Answer

    IAP Guide Parity 1 Answer

    Is it necessary that the price in RM matches the price in USD in the app store? 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

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

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges