How to clean a leaderboard without deleting it?  

  RSS
(@danilletov)
Active Member Registered

Hello,

Every month I need to clear the leaderboard and start fixing the players rating again. Is it possible to do this without deleting the table completely?

This topic was modified 3 months ago by DanilLetov
Quote
Posted : 28/02/2019 12:29 pm
(@skaredcreations)
Honorable Member Admin

You can execute a query to delete all records of a single leaderboard from the table LeaderBoard_User:

DELETE FROMĀ LeaderBoard_User WHERE IdLeaderboard = 123456;

If you can create a job schedule on your server (Cronjob on Linux or Scheduled Task on Windows) then you could also create a small PHP script to be executed once per day at 00:00, for example create a file /combu/_services/empty_leaderboard.php:

<?php

include '../lib/api.php';

use Combu\LeaderBoard_User;

// Delete all scores of a leaderboard on day '1' of every month
if (intval(date("d")) === 1) {
    $query = "DELETE FROM " . LeaderBoard_User::GetTableName(LeaderBoard_User::class) . " WHERE IdLeaderboard = 123456";
    $Database->Query($query);
}

This post was modified 3 months ago 2 times by Skared Creations

FRANCESCO CROCETTI @ SKARED CREATIONS

ReplyQuote
Posted : 28/02/2019 6:51 pm
(@danilletov)
Active Member Registered

Thank you very much!
You really helped.

ReplyQuote
Posted : 28/02/2019 7:51 pm
Share: