# Leaderboards

#### Leaderboards Type

Type of leaderboards on the current platform.

<figure><img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2FqgSv9FQNSQoXUenl8WQU%2FScreenshot%202025-06-26%20at%2010.59.37%E2%80%AFAM.png?alt=media&#x26;token=c955fd64-7976-47be-b6a1-d46e1102da32" alt=""><figcaption></figcaption></figure>

<table><thead><tr><th width="176.140625">Type</th><th>Game Logic</th></tr></thead><tbody><tr><td><code>not_available</code></td><td>Leaderboards are not available. Any leaderboard functionality must be disabled in the game.</td></tr><tr><td><code>in_game</code></td><td><p>Leaderboards are available. </p><p>The game must use the <code>setScore</code> method to set the player's score.</p><p>The game should display custom in-game leaderboards using the data from the <code>getEntries</code> method.</p></td></tr><tr><td><code>native</code></td><td><p>Leaderboards are available. </p><p>The game must use the <code>setScore</code> method to set the player's score.</p><p>The game should not display custom in-game leaderboards because leaderboards are displayed in the platform interface and the <code>getEntries</code> method does not work.</p></td></tr><tr><td><code>native_popup</code></td><td><p>Leaderboards are available. </p><p>The game must use the <code>setScore</code> method to set the player's score.</p><p>The game should call <code>showNativePopup</code> to display leaderboards overlay and the <code>getEntries</code> method does not work.</p></td></tr></tbody></table>

#### Setup

Setup leaderboards in the [config file](https://wiki.playgama.com/playgama/sdk/playgama-bridge-config). For each leaderboard add an `id`. You can override which id is sent to the platform's native SDK.

```json
{
    ...    
    "leaderboards": [
        {
            "id": "test_leaderboard", // use this id in game logic
            "<ANY_PLATFORM_ID_HERE>": "<OVERRIDED_ID_FOR_PLATFORM_HERE>"
        }
    ]
}
```

#### Set Score

Submit the player's score to the leaderboard to update their rank and position.

<figure><img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2FztFZJQg5kps9EUjqgnkp%2FScreenshot%202025-06-26%20at%2011.02.18%E2%80%AFAM.png?alt=media&#x26;token=f3c6579d-9980-4f19-a9e6-2f2e186aa64b" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```
{"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-start-of-layout","objectClass":"System"}],"actions":[{"id":"leaderboards-set-score","objectClass":"PlaygamaBridge","parameters":{"id":"\"YOUR_LEADERBOARD_ID_HERE\"","score":"42"}}]},{"eventType":"block","conditions":[{"id":"on-leaderboards-set-score-completed","objectClass":"PlaygamaBridge"}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"is-last-action-completed-successfully","objectClass":"PlaygamaBridge"}],"actions":[{"type":"comment","text":"success"}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"}],"actions":[{"type":"comment","text":"error"}]}]}]}
```

</details>

#### Get Entries

{% hint style="info" %}
Works only when `LeaderboardsType` = `in_game`
{% endhint %}

Retrieve entries from the leaderboard, including the player's rank and score, to display a custom leaderboard in the game.

<figure><img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2F9HcgDirvtm7SKggCT3oX%2FScreenshot%202025-06-26%20at%2011.08.21%E2%80%AFAM.png?alt=media&#x26;token=234a1af0-f4e2-46a2-9f0d-11c269f2348d" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```
{"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-start-of-layout","objectClass":"System"}],"actions":[{"id":"leaderboards-get-entries","objectClass":"PlaygamaBridge","parameters":{"id":"\"YOUR_LEADERBOARD_ID_HERE\""}}]},{"eventType":"block","conditions":[{"id":"on-leaderboards-get-entries-completed","objectClass":"PlaygamaBridge"}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"is-last-action-completed-successfully","objectClass":"PlaygamaBridge"}],"actions":[{"type":"comment","text":"success"}],"children":[{"eventType":"block","conditions":[{"id":"for","objectClass":"System","parameters":{"name":"\"\"","start-index":"0","end-index":"PlaygamaBridge.LeaderboardEntriesCount - 1"}}],"actions":[{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"ID: \" & PlaygamaBridge.LeaderboardEntryId(loopindex)"}},{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"Name: \" & PlaygamaBridge.LeaderboardEntryName(loopindex)"}},{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"Photo: \" & PlaygamaBridge.LeaderboardEntryPhoto(loopindex)"}},{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"Rank: \" & PlaygamaBridge.LeaderboardEntryRank(loopindex)"}},{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"\"Score: \" & PlaygamaBridge.LeaderboardEntryScore(loopindex)"}}]}]}]}]}
```

</details>

#### Show Native Popup

{% hint style="info" %}
Works only when `LeaderboardsType` = `native_popup`
{% endhint %}

Displays the leaderboard overlay, including the player's rank and score.&#x20;

<figure><img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2F7UyrIN6oukQzDkMjbhVu%2FScreenshot%202025-08-29%20at%2013.08.23.png?alt=media&#x26;token=96837019-602f-43cd-81a9-19f0479aa349" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```
{"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-start-of-layout","objectClass":"System"}],"actions":[{"id":"leaderboards-show-native-popup","objectClass":"PlaygamaBridge","parameters":{"id":"\"YOUR_LEADERBOARD_ID_HERE\""}}]},{"eventType":"block","conditions":[{"id":"on-leaderboards-show-native-popup-completed","objectClass":"PlaygamaBridge"}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"is-last-action-completed-successfully","objectClass":"PlaygamaBridge"}],"actions":[{"type":"comment","text":"success"}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"}],"actions":[{"type":"comment","text":"error"}]}]}]}
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.playgama.com/playgama/sdk/engines/construct-3/leaderboards.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
