Variables
userLeaderboard
$userLeaderboard[]
Displays the position of the current user in a leaderboard based on a variable, along with nearby users.
Syntax
$userLeaderboard[variable] or $userLeaderboard[variable;sort]
$userLeaderboard
The $userLeaderboard function displays the position of the current user in a leaderboard, surrounded by the users who immediately precede and follow them. Unlike $globalUserLeaderboard or $serverLeaderboard which return the full leaderboard, this function focuses on the user’s immediate context.
Syntax
$userLeaderboard[variable]
$userLeaderboard[variable;sort]
| Parameter | Required | Description |
|---|---|---|
variable |
Yes | The name of the variable to rank |
sort |
No | desc (descending, default) or asc (ascending) |
How It Works
$userLeaderboardis a placeholder resolved at runtime by the leaderboard action.- The system identifies the position of the current user in the leaderboard.
- It returns a neighborhood around that position (the user + a few neighbors above and below).
- The current user is identifiable by their username or ID in the returned lines.
Typical Usage
$textSplit[$userLeaderboard[score;desc];\n]
Then loop through the entries with $splitText, $getLeaderboardPosition, and $getLeaderboardValue.
Use Cases
- 📊 Personal dashboard: show the user where they stand.
- 🎯 Motivation: display direct neighbors to encourage competition.
- 🏆 Congratulation messages: detect if the user is on the podium.
- 📈 Progression tracking: see the gap with players ahead of you.
Comparison with other leaderboards
| Function | Scope | Returns |
|---|---|---|
$userLeaderboard |
Current user | Neighborhood around the user |
$serverLeaderboard |
Current server | Complete leaderboard of the server |
$globalUserLeaderboard |
All users | Complete global leaderboard |
Important Notes
- The user must have a value set for the specified variable, otherwise they will not appear in the leaderboard.
- The number of entries returned around the user depends on the bot’s configuration.
$getLeaderboardPositionand$getLeaderboardValuework normally during iteration.- For a complete leaderboard, prefer
$globalUserLeaderboardor$serverLeaderboard.
See Also
$getLeaderboardPosition— Rank in the active leaderboard$getLeaderboardValue— Value in the active leaderboard$globalUserLeaderboard— Complete global leaderboard$serverLeaderboard— Complete server leaderboard$textSplit— Parse the result$getUserVar— Read a user variable$setUserVar— Set a user variable