HomeHome  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  DOWNLOADDOWNLOAD  Vote for Wc3LegionVote for Wc3Legion  

Share | 
 

 Leaderboards

Go down 
AuthorMessage
GameOverGR
Admin
avatar

Posts : 145
Reputation : -1
Join date : 2010-06-29
Age : 25
Location : Hell

PostSubject: Leaderboards   Wed Jul 28, 2010 6:28 am

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.

Sometimes you need more columns than just the two standard, but that is impossible with leaderboards so you will have to use multiboards. 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.

Code:
Map Initialization

Use an event like

Code:
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.

Code:
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.

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.

Code:
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:

Code:
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.

_________________
Back to top Go down
View user profile http://wc3legion.darkbb.com
 
Leaderboards
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Burning Legion's Return :: Warcraft III :: Guides-
Jump to: