Hello ,
I am working on leaderboards.
I am doing queries to Playlyfe API from my backend server.
What i try to achieve is when i play an action, increment the mapped leaderboard corresponding to this action.
So i tried to pass scopes when i play an action, with id="leaderboard id" and entity_id="playerId". But it does nothing.
So my questions are :
- How does work scope?
- How do i pass scope while play an action?
- Does passing scope on an action will create a new leaderboard automatically? Referring the doc ; > This scope can be the course ID for instance which would automatically create a leaderboard that will track score changes only when actions are performed or rules executed with that scope. But when i pass the scope id, nothing is created.
- Do i have my users on a leaderboard everytime to see them on it?
Thanks for your help and congratulation for you work, your platform is awsome !
Thanks for contacting us and even more for your compliments
Well let me start with a scenario,
lets say you have a point metric "experience" and an action "download" which awards a player 10 "experience" points on playing it.
Now you have 2 leaderboards a game scoped leaderboard with id ("game_leaderboard") on the metric "experience" and a custom scoped leaderboard with id ("custom_leaderboard") on the metric "experience" also.
So now say your player finishes course 1.
POST http://api.playlyfe.com/v2/actions/download/play
I assume when you do a player action play with your custom scopes you do it with this data,
{
"scopes": [
{
"id": "course1",
"entity_id": "player1"
}
]
}
So when you do this,
1.Your game scoped leaderboard will be like this,
https://api.playlyfe.com/v2/runtime/leaderboards/game_leaderboard?sort=ascending&cycle=alltime
{
"data" : [
{
"player": {
"id": "player1",
},
"score": 10,
"rank": 1,
}
]
}
2.Your custom scoped leaderboard for course1
will be like this,
https://api.playlyfe.com/v2/runtime/leaderboards/custom_leaderboard?sort=ascending&cycle=alltime&scope_id=course1
{
"data" : [
{
"player": {
"id": "player1",
},
"score": 10,
"rank": 1,
}
]
}
So now lets do the action again with a different scope,
POST http://api.playlyfe.com/v2/actions/download/play
I assume when you do a player action play with your custom scopes you do it with this data,
{
"scopes": [
{
"id": "course2",
"entity_id": "player1"
}
]
}
So when you do this,
1.Your game scoped leaderboard will be like this,
https://api.playlyfe.com/v2/runtime/leaderboards/game_leaderboard?sort=ascending&cycle=alltime
{
"data" : [
{
"player": {
"id": "player1",
},
"score": 20,
"rank": 1,
}
]
}
2.Your custom scoped leaderboard for course1
will be like this,
https://api.playlyfe.com/v2/runtime/leaderboards/custom_leaderboard?sort=ascending&cycle=alltime&scope_id=course1
{
"data" : [
{
"player": {
"id": "player1",
},
"score": 10,
"rank": 1,
}
]
}
3.Your custom scoped leaderboard for course2
will be like this,
https://api.playlyfe.com/v2/runtime/leaderboards/custom_leaderboard?sort=ascending&cycle=alltime&scope_id=course2
{
"data" : [
{
"player": {
"id": "player1",
},
"score": 10,
"rank": 1,
}
]
}
Scope works by creating the new scope you specified on the fly and creating a leaderboard on it.
You just need to pass any scope you want to the record the action points you earned with the request.
Nope you won't have all your users on a custom scoped leaderboard since its created on the fly only those who have done the action with that scope_id will be seen
Hello,
Thanks for this great answer, it's clear. I tested and it works.
But i think my mistake was trying to visualize my scope in game app, from the UI.
You can only watch scoped rank with an API call right?
Yes. It's not there in the UI.