Skip to main content

Construct 3 - Create Daily Leaderboards

GamePush has implemented leaderboards - personalized competitive tables that can be shown on the game page. Using Constract 3 as an example, let's create a daily leaderboard showing the player's personal record. In such a table, you can display the “top for today”, thereby increasing the involvement of players.

Creating a Leaderboard

Create a leaderboard in the GamePush control panel. Go to the Leaderboards tab, click the “Add” button and fill in the fields:

Adding Fields

Add the fields by which the rating will be built. At the same time, it is not necessary to create the same fields in the player's fields as in the leaderboard. As an example, let's add a player's earned points field Score. To do this, on the page below, under the leaderboard parameters, click the Add field button and fill it in as shown in the figure below:

After filling in the fields, the Add leaderboard button will become active. Click it to complete the table creation. The final leaderboard setup is shown in the figure below:

Save the Record

Save the record today to a table. In leaderboards, the division of records is carried out through the variant parameter. Variant is any string that can be used to get a slice of the leaderboard and save the results to that slice. For example, variant could be the date string 12/19/2022, the level number 123, or the name of the competition arena3x3. The developer is free to choose any name by which the slice is performed.

To build daily leaderboards, we will use the date. To make the tables non-intersecting, it is enough to store the variant in the format of the current date, for example, 12/19/2022. For example, “today” all players save records in variant 12/19/2022, and “tomorrow” will save them in variant 12/20/2022. To get the current date in Construct 3, use the script:

We created a variantName variable, and at the start of the game we wrote the current date into it in the format 19/20/2022:

localVars.variantName = new Date().toLocaleString('en', {
year: 'numeric',
month: '2-digit',
day: '2-digit',

When passing the level, we save the player's current points and publish the record:

Save the result:

Player record:

Top "for Today"

Open the top for today. If desired, add the rest of the fields to the Leaderboard, for example, display a player class or VIP status next to the record. To do this, in the control panel you can create the corresponding fields of class and vip.

Personal Record

To show a player's personal record, you can request a rating from the server in the menu:

In the caught event, the current position in the rating and the values of the record fields are available. We catch the event of receiving a rating. We are waiting for the rating loading event to fire:

To obtain:

  • current position: you need to read the expression GamePush.LeaderboardPlayerPosition.
  • value of any fields: we can read the expression GamePush.LeaderboardCurPlayerField("score"), passing the field key there (in our example it is score).

Reward Accrual

We accrue to the player a reward for the first places in the rating of yesterday date. The accrual of the award consists of five steps:

  • creating a player field to track the day the reward was awarded - lastRewardedDay;
  • creating a variable to store the date of the past day - lastDate;
  • comparing the variable lastRewardedDay with the date of the current day variantName. If lastRewardedDay != variantName - the reward is calculated;
  • comparison of the player's position in the rating and the accrual of rewards;
  • saving player data.

Let's create a variable in the player's fields that will track the day of the last reward accrual - lastRewardedDay. In the control panel, go to the Players tab - Add field:

When receiving the rating, add another check:

Find out the date of yesterday and write it to the lastDate variable:

let date = new Date();
date.setDate(date.getDate() - 1);
localVars.lastDate = date.toLocaleString('en', {
year: 'numeric',
month: '2-digit',
day: '2-digit',

The next step is to add a comparison: if you haven’t received a reward for yesterday yet, then we accrue a reward. To do this, we compare the lastRewardedDay variable, it should not be equal to the current day variantName.

Next, we compare the player’s position in the ranking and distribute the necessary rewards. At this step, we mark that for today a reward was received, for this we set the value of the player variable lastRewardedDay to lastDate.

Save the player after receiving the reward.

Stay in Touch

Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.

GamePush Community Telegram: @gs_community.

For your suggestions e-mail: [email protected]

We Wish you Success!