Reset leaderboard (server side)


I want to reset leaderboard after x no of seconds/minutes when created. How can i do this on server side lua module and what value to set in reset or cron format ? i m unable to figure this out.


Hello Faisal,

From docs
you you can find this LUA code to create leaderboard

local id = "4ec4f126-3f9d-11e7-84ef-b7c182b36521"
local authoritative = false
local sort = "desc"
local operator = "best"
local reset = "0 0 * * 1"
local metadata = {
  weather_conditions = "rain"
nk.leaderboard_create(id, authoritative, sort, operator, reset, metadata)

Also in they docs the mentioned

reset ==> (string) The cron format used to define the reset schedule for the leaderboard. This controls when a leaderboard is reset and can be used to power daily/weekly/monthly leaderboards. Optional in Lua.

For cron format you can use this link to generate the proper cron for your need

Hello Mohammad,

I already done all of these things. My question is, i have created a leaderboard and want to reset it e.g after 2 days of its creation, what value we need to set in reset param to make this work.


local reset  =  " 0 0 0 1/2 * ? *"

you can use this

to make it reset the leaderboard on

  1. 2020-09-15 Tue 00:00:00
  2. 2020-09-17 Thu 00:00:00
  3. 2020-09-19 Sat 00:00:00
  4. 2020-09-21 Mon 00:00:00
  5. 2020-09-23 Wed 00:00:00
    and so on …

you can change the time to do the reset
I recommend you to check this link to know more about cron format

Again, i don’t want to bind this with week days nor at a specific time instead want to reset after some hour/s min/s etc. After a bit of research i have found that tournaments are a better option instead of leaderboards for my use case.

Anyways, thank you for investing time in this.