HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Leaderboards

06-29-2006, 11:09 PM#1
Archian
Leaderboards
By Archian

Leaderboards are a simple way for players to keep track of their scores or points.
It's a score board which shows up in the top-right corner.

Click image for larger version

Name:	leaderboards.jpg
Views:	124
Size:	6.9 KB
ID:	9392
(Leaderboard)

Leaderboards can only keep track of two columns; a name and a value.
If you want multiple columns you have to make a multiboard.
However, leaderboards are a lot more simple to make.

Notice a leaderboard can't be created useing the trigger; Map Initialization.
Use a trigger like Time - Elapsed game time is 2.00 seconds to make the trigger.
Adjusting the Elapsed game time to 0.00 seconds would work like Map Initialization; you won't know the diffrence.

Creating the Leaderboard:
Leaderboards
Collapse Events
Time - Elapsed game time is 0.00 seconds
Conditions
Collapse Actions
Leaderboard - Create a leaderboard for (All players) titled Leaderboards
Collapse Player Group - Pick every player in (All players) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Picked player) controller) Equal to User
((Picked player) slot status) Equal to Is playing
Collapse Then - Actions
Leaderboard - Add (Picked player) to (Last created leaderboard) with label (Name of (Picked player)) and value 0
Collapse Else - Actions
Do nothing
Leaderboard - Show (Last created leaderboard)
(Example of making a leaderboard)

Tally Score
A leaderboard can keep track of several different scores etc.
For instance; perhaps you'd want your board to keep track of kills like in a TD or if your playing a capture the flag game; perhaps you'd want it to keep track of flags stolen.
The board works fine with Integers, you can assign it any integer values you like.

For this tutorial, I'm going to make the leaderboard keep track of "kills".

Variable
Create a Variable to keep track of kills for each player.
Open the Variable editor and create a new Variable Type; Integer variable called PlayerKills (I call it PlayerKills).
Check the Array box to keep track of more than just one value.

Click image for larger version

Name:	leaderboard.jpg
Views:	111
Size:	27.6 KB
ID:	8573

Tally Trigger
You'll need a trigger to tally the score.
In this example it will keep track of kills for each player; for instance a TD.
Perhaps you might want to keep track of just one unit's kills.
You can also add conditions to limit what kinds of kills are allowed.

Trigger Tally Score:
Trigger Tally Score
Collapse Events
Unit - A unit Dies
Collapse Conditions
((Killing unit) belongs to an ally of Player 1 (Red)) Equal to True
Collapse 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
(Example of the tally score trigger)

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.
Attached Images
File type: jpgleaderboard.jpg (27.6 KB)
File type: jpgleaderboards.jpg (6.9 KB)
07-12-2006, 09:44 AM#2
PitzerMike
Quote:
Originally Posted by Archian
...It's a score board which shows up in the top-left corner...

I guess you mean top-right.

Quote:
Originally Posted by Archian
...Adjusting the Elapsed game time to 0.01 seconds would work like Map Initialization...

I'd suggest time elapsed 0.00 seconds - to be on the save side.

Otherwise I approve this tutorial, it's well written!
07-12-2006, 11:16 AM#3
ragingspeedhorn
Nice simple tutorial, good for beginners, + rep.
07-16-2006, 08:38 AM#4
PitzerMike
Yes, I approve.
07-16-2006, 12:17 PM#5
ragingspeedhorn
Quote:
Originally Posted by Archian
hmm, perhaps i should include a image of a leaderboard..
anyways thank you

Good idea, you should do that.
12-20-2006, 11:32 PM#6
warbucket
Nice guide. Helped a lot.