Archian
Site Director
- Joined
- Jan 1, 2006
- Messages
- 3,106
Leaderboards
By Archian
Description
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.
Adjusting the Elapsed game time to 0.00 seconds will work just like Map Initialization and actually work.
Variable
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.
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:
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.
By Archian
Description
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
- Time - Elapsed game time is 2.00 seconds
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
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
- Leaderboard - Show (Last created leaderboard)
-
Events
Variable
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
-
Events
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)
-
Events
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: