question

martinliu1993 avatar image
martinliu1993 asked

Best way to allow players to level up and award skill points

What is the best and most recommended way to level up users using xp, and award new levels based on xp, and have skillpoints awarded for each level advancement?

From what i saw, it seems the best way is to create 3 stats (level, xp, skillpoints), setup segments to trigger level up when xp hits a certain point, carry out 3 actions (advance level, award skills points, reset xp).

This seems good, but suppose each player can advance from level 1 all the way to level 200, each with increasing non-linear xp requirements. Does that mean I literally need 200 different segments? Is there a better way to do this?

2nd question: the players have many skills in which they can spend their skill points into. Do all those skills need to be a player statistic, so that when a skill point is spent in that skill, I just call UpdatePlayerStatistic?

Player Data
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

Well, it's certainly possible to do this via PlayStream actions in the professional tier, but it would take a lot of actions (and segments, in your description). A better solution might be to just call a Cloud Script handler for the statistic increase event. Then, in the handler, use the specifics of the event data (passed in as the context: https://blog.playfab.com/docs/tutorials/landing-automation/using-cloud-script-actions-with-playstream) to determine the specifics of the reward.

As to what you choose to make statistics, it really depends upon your usage requirements. Statistics all result in leaderboards, which can be used for comparison between players. They can also be used to trigger actions in PlayStream, as stated. So if either of those are requirements, statistics would likely be the way to go. Otherwise, you may want to consider some form of player data (though to be clear, you shouldn't store a single statistic in a key/value pair of UserReadOnlyData, for example - tiny values are fairly inefficient in the current data model).

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

martinliu1993 avatar image martinliu1993 commented ·

Thanks for your advice. I would probably make levels and xp as statistics, but skill points as consumables. I don't have professional tier yet so I don't have access to PlayStreams, so what would be the best way to detect a player registered an account and logged in for the first time with detecting the player_add_game event?

0 Likes 0 ·
brendan avatar image brendan martinliu1993 commented ·

All titles have access to PlayStream, bar none. It's just that in the free tier, you have only a small amount of actions/segments/etc. So you can set up an action for that event, no problem.

0 Likes 0 ·
galichakristoffer avatar image galichakristoffer commented ·

hi i created 3 keys on Playerdata(title) exp, level, max level. how can i add the values?

0 Likes 0 ·
brendan avatar image brendan galichakristoffer commented ·

Player Data isn't a numeric value - it's a string. You can update Player Data via calls like UpdateUserData. If you want these to be numeric values and have leaderboards, you'll need to make them statistics. https://api.playfab.com/docs/tutorials/landing-players/player-statistics

0 Likes 0 ·
Janderson avatar image Janderson commented ·

Have any tutorial to do this on unity 3d?

0 Likes 0 ·
Janderson avatar image Janderson brendan commented ·

any video tutorial?

0 Likes 0 ·
Show more comments
Jorge Gonzalez avatar image Jorge Gonzalez commented ·

I am not sure if it is ok to ask about things on other questions, but I have a follow up question to this one. Something I haven't seen addressed in the documentation or tutorials.

I know the limit on calls is in the documentations, but is hard for me to do the math. Lets say I have a game with exp and levels. I place them in the player stats, I set up the cloud scripts to update exp and levels to make sure is safe. Let's say we have 100 people play the game on launch. Wouldn't all the calls to playfab be a problem in the first hour when player's exp and levels update faster? Even if you take exp into account. Players gain exp all the time.

So what is the best way to handle safety in cloud script and not overloading playfab with cloudscript calls? Am I being over dramatic?

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.