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 activedreaminc · Sep 02, 2019 at 02:30 PM · Player DataLeaderboards and StatisticsPlayer InventoryCharacter DataCharacters

How to give player EXP after battle? and How to reward player after level up?

Hi, I have created statistics called EXP and Level. I would like to reward player certain amount of EXP after battle. Which function should I use to implement that?

Also I would like to implement so that after player accumulated certain EXP then the player will Level up and get reward such as gold currency, playable character, gift box, etc. Which function should I use to implement this feature?

Thank you for your help and support,

Best Regards,

Dennis

Active Dream

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 Sarah Zhang · Sep 03, 2019 at 06:28 AM

Firstly, you can learn about PlayStream Event, Rules and Cloud Script, then combine these functions to implement your features. About the possible workarounds we can give the following simplified steps:

>> I would like to reward player certain amount of EXP after battle. Which function should I use to implement that?

  1. Write a Cloud Script function A that can update player statistics EXP based on the EXP calculation formulas.
  2. In the clients, when players finish a battle, you use the Client API WritePlayerEvent, write a custom Event B.
  3. Set a Rule, set the Event type as your custom event type B. Choose the Execute CloudScript function as the Actions Type, then choose the function A in the Cloud Script Function drop down menu.

>> I would like to implement so that after player accumulated certain EXP then the player will Level up and get reward such as gold currency, playable character, gift box, etc.

  1. Write the corresponding Cloud Script functions.
  2. Set a Rule, set the Event type as the event type com.playfab.player_statistic_changed. Add corresponding Conditions in your need. Choose the Execute CloudScript function as the Actions Type, then choose the corresponding CloudScript functions.
Comment
activedreaminc

People who like this

1 Show 3 · 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 activedreaminc · Sep 04, 2019 at 02:27 PM 0
Share

Hi @Sarah Zhang

Thank you for your reply, could give example code for these steps please?

  1. Write a Cloud Script function A that can update player statistics EXP based on the EXP calculation formulas.
  2. In the clients, when players finish a battle, you use the Client API WritePlayerEvent, write a custom Event B.

Thank you for your help and support

Best Regards,

Dennis

Active Dream

avatar image Sarah Zhang activedreaminc · Sep 20, 2019 at 07:38 AM 0
Share

1. You can find the sample CloudScript code in your CloudScript revision1. You can also refer to the following code.

handlers.UpdateCurrentPlayerStatistics = function (args, context) {

    var request = {
        PlayFabId: currentPlayerId, Statistics: [{
                StatisticName: "Exp",
                Value: 100
            }]
    };
    
    var playerStatResult = server.UpdatePlayerStatistics(request);
};



2. You can refer to this doc.

avatar image activedreaminc Sarah Zhang · Sep 27, 2019 at 05:52 AM 0
Share

Hi @Sarah Zhang,

Thank you for your help, I have implemented the cloud script successfully. By the way, how to promote and gain audience for the game that I developed?

Thank you for your help and support,

Best Regards,

Dennis

Active Dream

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

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    Revoke all items or delete character?,What is better way: delete character or revoke inventory items? 1 Answer

    GrantItemsToCharacter gives VC to Player not Character? 1 Answer

    Creating dummy player from cloud script 1 Answer

    How can I change a players statistics ? 1 Answer

    Avatars as inventory items 2 Answers

    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