• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!


Not open for further replies.


Site Director
Level 62
Jan 1, 2006
By Archian

A leaderboard is a table displayed in the top right corner. Each row can contain a name and a value. In most maps this is used for displaying kills wins of your team. In this tutorial I will explain how to setup the leaderboard, how to update the leaderboard and how to remove a leaving player from the board.

The image below is part of a screenshot of a leaderboard.

Sometimes you need more columns than just the two standard, but that is impossible with leaderboards so you will have to use [THREAD=6402]multiboards[/THREAD]. Multiboards are a lot tougher to work with so I will recommend leaderboards.

Creating the Leaderboard
The Event when creating a leaderboard in triggers is very important. Creating the leaderboard with the event below will just not work.
  • Map Initialization
Use an event like
  • Time - Elapsed game time is 2.00 seconds
to make it work.
Adjusting the Elapsed game time to 0.00 seconds will work just like Map Initialization and actually work.

  • Leaderboard
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Leaderboard - Create a leaderboard for (All players) titled Score
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) controller) Equal to User
              • ((Picked player) slot status) Equal to Is playing
            • Then - Actions
              • Leaderboard - Add (Picked player) to (Last created leaderboard) with label (Name of (Picked player)) and value 0
            • Else - Actions
      • Leaderboard - Show (Last created leaderboard)
This trigger runs with the event we decided to use. It creats a leaderboard called "Score" and is displayed for all players. Then it loops through each player and if he is playing, he will be added to the board.

We need something to keep track of the kills for each player so we have to use a variable.
Open the variable editor and create a new variable of the type Integer.
Call it "PlayerKills" (Because I do).
Check the Array box to keep track of more than just one value.

Updating the Leaderboard
The leaderboard does not update by itself. Each time a value should raise, you have to make it raise. That's why we need a trigger that updates the board.
  • Trigger Update
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) belongs to an enemy of (Owner of (Killing unit))) Equal to True
    • Actions
      • Set PlayerKills[(Player number of (Owner of (Killing unit)))] = (PlayerKills[(Player number of (Owner of (Killing unit)))] + 1)
      • Leaderboard - Change the value for (Owner of (Killing unit)) in (Last created leaderboard) to PlayerKills[(Player number of (Owner of (Killing unit)))]
      • Leaderboard - Sort (Last created leaderboard) by Value in Descending order
This trigger runs every time a unit dies, if the dying unit is an enemy of the killing unit, the PlayerKills variable will raise with one. I put in the condition because I do not want people to make commit teamkills and score by that.

The Leaving Player
Having a leaderboard only display the players who are actually still playing is very important. Or at least make it so people easily can keep track of who are playing and who are not. I decided to make a trigger to remove the leavers from the board. The trigger will look like this:
  • Leavers
    • Events
      • Player - Player 1 (Red) leaves the game
      • Player - Player 2 (Blue) leaves the game
      • Player - Player 3 (Teal) leaves the game
    • Conditions
    • Actions
      • Leaderboard - Remove (Triggering player) from (Last created leaderboard)
This trigger does only act when player 1, 2 or 3 leavers so add one for each available slot.

The Trigger Functions of Leaderboards
Here's a overview of the functions which are available for leaderboard triggers.

Leaderboard - Create
Creates the leaderboard. Make a main title for the leaderboard.

Leaderboard - Destroy
Destroys a leaderboard. Once destroyed, players can no longer see it.

Leaderboard - Show/Hide
Shows and hides the leaderboard.

Leaderboard - Change Title
Changes the main title of the leaderboard.

Leaderboard - Change Label Colors
Changes the color of a players label.

Leaderboard - Change Value Colors
Changes the color of a players score.

Leaderboard - Change Style
Changes the leaderboard style. You can hide the title, labels, or player values, for all players.

Leaderboard - Add Player
Adds a player to the leaderboard.

Leaderboard - Remove Player
Removes a player from the leaderboard.

Leaderboard - Change Player Label
Changes the label for a player.

Leaderboard - Change Player Label Color
Changes the color of a players label.

Leaderboard - Change Player Value
Updates the value, or score, for a player.

Leaderboard - Change Player Value Color
Changes the color of a players score.

Leaderboard - Change Player Style
Changes the leaderboard style. You can hide the labels or player values, for a specific player.
Last edited by a moderator:
Not open for further replies.