Variables getLeaderboardPosition

$getLeaderboardPosition[]

Returns the position of the user in the current leaderboard during iteration through a leaderboard.

Syntax
$getLeaderboardPosition

$getLeaderboardPosition

The function $getLeaderboardPosition allows retrieving the position (rank) of the current user in the active leaderboard. This function only makes sense in the context of iterating through a leaderboard — that is, after calling $globalUserLeaderboard, $serverLeaderboard or $userLeaderboard and while iterating through their results.

How It Works

When you use a leaderboard, the system iterates through each entry one by one. During this iteration, $getLeaderboardPosition exposes the current rank (1 for the first, 2 for the second, etc.).

The returned value corresponds to the internal variable ((leaderboard.position)) which is resolved at runtime by the dedicated leaderboard action.

Use Cases

Typically, you use $getLeaderboardPosition with $textSplit to split the leaderboard result line by line, then display the positions:

  • Display a formatted ranking with ranks
  • Compare the current user’s position with others
  • Build custom messages based on rank (podium, top 10, etc.)

Important

  • $getLeaderboardPosition returns nothing outside the context of an active leaderboard.
  • The function takes no parameters.
  • It is typically paired with $getLeaderboardValue which gives the value associated with that position.
  • The leaderboard itself is generated by a dedicated action at code execution time.

See Also