Designers
malcolm_cocklin
—
2015-12-14T09:31:45-05:00 —
#1
Hi,
Is there currently any way that certain metrics can be reset automatically based on a date i.e. midnight on the last day of the month?
This will allow the ability for me to run monthly competitions for staff in certain teams.
Please help!!
Malc
khs
—
2015-12-14T12:41:22-05:00 —
#2
Hi Malcolm,
Currently there's no built in way to reset player scores based on time, but it can be done on your aplication level by writing some code, or via the Explorer in Playlyfe.
Using the Explorer is simple: open your game, go into the explorer and open the Players tab. There you'll get the list of all players within your game, and you can edit each player's score from there.
The other way is to write a little bit of code to edit player scores automatically, but it will require some code to be written. Are you able to program, or have access to someone who can do it for you?
rajanrastogi
—
2015-12-17T23:37:15-05:00 —
#3
@khs I might be a little out of touch, but would it be possible to create a custom rule with a timed condition, where the points of all/selected players can be set
to 0 on the first of every month ? All they would have to do then is just make that call instead of resetting player scores individually.
IIRC, that was the point of custom rules, wasn't it ?
khs
—
2015-12-18T03:44:22-05:00 —
#4
Yes, but as of now, there is no wildcard identifier to refer to ALL the players. You'll still have to pass the IDs of all the players to be affected into the custom rule.
And since custom rules require some code to be written, I'd like to know from Malcolm if he's comfortable dealing with writing code, else the other currently available way is to use the Explorer.
peter_john
—
2015-12-18T04:37:58-05:00 —
#5
Well if you have php installed I already have a script which does this for you.You just need to execute this when you want to reset all your players.
You can checkout how to setup the php sdk from here https://github.com/playlyfe/playlyfe-php-sdk
Here is the script
<?php
require __DIR__ . '/';
use Playlyfe\Sdk\Playlyfe;
use Playlyfe\Sdk\PlaylyfeException;
$pl = new Playlyfe(
array(
'version' => 'v2',
'client_id' => "your_client_id",
'client_secret' => "your_client_secret",
'type' => 'client'
)
);
$collection = $pl->get('/admin/players', ['skip' => 0, 'limit' => 1]);
$total = $collection["total"];
for($skip = 0; $skip < $total + 10; $skip += 10) {
$collection = $pl->get('/admin/players', ['fields' => 'id', 'skip' => $skip, 'limit' => 10]);
foreach($collection["data"] as $player) {
$pl->post('/admin/players/'.$player["id"].'/reset');
}
}
?>
This will reset all the players and all their scores. If you want to reset only certain metrics then you need to change the post request a bit.
rajan_rastogi
—
2015-12-20T12:08:16-05:00 —
#6
Quick note on the player resets, the docs currently say resets can only be performed on dummy players. If that has indeed been changed, you might want to update the docs.