Leadetboard kills

MissKerrigan

Active Member
Reaction score
23
Does anyone knows how I make a leaderboard which shows the kills?
I want the leaderboard shows only the players who are in the game.

MissKerrigan
 

Dave312

Censored for your safe viewing
Reaction score
269
This trigger should make a basic kills leaderboard. You need to create a global variable called Lboard
Trigger:
  • Build Leaderboard
    • Events
    • Local Variables
      • i = 0 <Integer>
    • Conditions
    • Actions
      • Leaderboard - Create a leaderboard with 2 columns and 12 rows, with the name "", and using (100%, 100%, 100%) color.
      • Variable - Set Lboard = (Last created leaderboard)
      • Leaderboard - Set Lboard item text at column 1 and row Header to "Player"
      • Leaderboard - Set Lboard item text at column 2 and row Header to "Kills"
      • Leaderboard - Set the automatic player column for Leaderboard to column 1 (Do Not group by teams)
      • ------- Add Players
      • General - For each integer i from 1 to 12 with increment 1, do (Actions)
        • Actions
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • (Status of player i) == Playing
              • (Controller of player i) == User
            • Then
              • Leaderboard - Add player i to Lboard
              • Leaderboard - Set Lboard item text at column 2 and row (i + 1) to (Text((Player i Enemy Units Killed score)))
            • Else

You will also need to create another trigger which updates the leaderboard when a unit dies.
Trigger:
  • Kills
    • Events
      • Unit - Any Unit dies
    • Local Variables
    • Conditions
      • (Controller of player (Owner of (Killing unit))) == User
    • Actions
      • Leaderboard - Set Lboard item text at column 2 and row ((Owner of (Killing unit)) + 1) to (Text((Player (Owner of (Killing unit)) Enemy Units Killed score)))
 

MissKerrigan

Active Member
Reaction score
23
omg is that really all nessesary to create just a leaderboard??

Pff I'll have to look this like 10 times before I understand I guess

Thx anyway dave !
 

Dave312

Censored for your safe viewing
Reaction score
269
That is actually a simplified version of the one I'm using in my map (I have a couple of extra columns).

Here is a video tutorial on creating leaderboards. This guy manually adds the players rather than using the Add Player to Leaderboard action which I used.
 

Dave312

Censored for your safe viewing
Reaction score
269
Pls can you also make a 'step by step' how to create a leaderboard of kills because the way Dave did it confused me a little :)
But I want the leaderboard only for the kills 'nova' does and not the other units
MissKerrigan

What in particular don't you understand?

Let me see If I can explain how the trigger works:

The first step is to create a global variable to store the Leaderboard. Siretu explained variables in a fair amount of detail in that other thread so hopefully you can create global variables now. I called mine LBoard in the trigger I posted above. It should be of the type Leaderboard. Since you now also want to only count kills made by a particular unit, you will need to create another global variable of the type Integer. I have called mine Kills. This variable needs to be an Array so check that box when creating the variable and set it's length to the number of players in your map (only type the length into the top "size box" and leave the rest). An Array is a variable that can store multiple values, and each value can be referenced by entering an index. In our case, index 1 will refer to player 1, index 2 will refer to player 2, index 3 will refer to player 3 and so on. So what will happen is that we can call this Kills variable, and by setting the index to a player number, it will return how many kills that player has made. Make sense?

The next step is to create the triggers. The first trigger is designed to run when the game starts, and it will create all the components for your leaderboard and set them to its default state. The first action in the trigger above is the Create Leaderboard action. When running this action we need to specify the size of the leader. The leaderboard we are creating will have 2 columns: the name of the player in the first, and the number of kills in the second. For the number of rows, we want 1 row per player. So when creating this action, set the number of columns to 2 and number of rows to the number of players (I have assumed 12). You also have the option of giving your leader a name and setting its colour. I have decided to leave the name blank (edit the name property and just hit "ok" to set it to nothing) and to leave the colour at its default.

The next action is the Set Variable action and it stores the leaderboard we just created in our previous action into the global variable we created before (LBoard). After using this action, every time you need to reference the Leaderboard, use this variable.

Although our leaderboard has been created, it is currently empty so we need to fill it in. The first thing we should do is give each column a title (or Header). The next two actions in our trigger do exactly this. They use the Set Leaderboard Item Text action. Set the Board parameter to LBoard (our leaderboard variable); the Row parameter to Header (under the Preset tab). Finally in the first action, set the Column parameter to 1 and Text to "[/i]Player[/i]" and in the second Column to 2 and Text to "[/i]Kills[/i]".

The next action is the Set Leaderboard Player Column action. This action makes adding players to the leaderboard much simpler and it also allows us to specify a column where the names of the players will be shown. Set the Board parameter to our variable LBoard and Column to 1. You also have the option of grouping the players into teams if you wish to do so.

Now we are ready to start adding players to the leaderboard. The simplest way to do this is to create a loop which will add each player for us. To do this, you need to create a local variable of the type Integer and call it "[/i]i[/i]". Then you can add the For Each Integer action to the trigger and set the Variable parameter to the local variable we just created (i), Start to 1, End to the number of players (I'm assuming 12) and Increment to 1. What this action does is count from the Start value, up to the End value using the Increment (so it will count 1,2,3,4,5,6,7,8,9,10,11,12). We can use the variable to reference which value it is currently at. The value will represent the player we are adding to our leaderboard.

Our next action needs to be located underneath our Loop we just created with our previous action. It is a If Then Else action. We will use this to determine if the selected player (the player selected by our loop) should be added to the leaderboard. We only want to add Human players that are actually playing. To do this, we need to create 2 Conditions under the If part of the action. The first condition is a Comparision which uses the function Status of Player (where the Player parameter is set to our local variable i) and compares it against the preset Playing. The second condition is also a Comparision but uses the function Controller of Player (where the Player parameter is set to our local variable i) and compares it against the preset User.

Now we need to add our actions to add a player should they pass our condition of the player being a Human player (user) and currently playing the game. The first action is the Add Player to Leaderboard action, where the Player parameter is set to our local variable i and the Board parameter is set our our global variable LBoard. This action add the player to the leaderboard and displays their name under the player column.

Our final action for this trigger is to display the number of kills for each player as they are added to the leaderboard since our previous action does not do this. This action again should be under the Then actions of the If Then Else action. You want to use the Set Leaderboard Item Text action and set the Board parameter to LBoard (our leaderboard variable); the Row parameter to an Arithmetic (Integer) function with the first value set to our local variable i and our second value to 1; the Column parameter to 2 and Text to "[/i]0[/i]" since every player will start off on 0 kills.

That is it for the first function. It should properly create the leaderboard and display all the correct information. However, as players make kills, we need to update the information displayed. This leads us to the second trigger which is shown below (I had to update it based on some new requirements). This trigger uses the event Unit Dies where the Unit parameter is set to the preset Any Unit.

We now need to a condition which make this trigger only run when a players hero makes the kill. I'm assuming that all players will be using the same unit type for their hero (Nova). The condition you need to make is a Comparision which uses the function Unit Type of Unit with the Unit parameter set to the function Killing Unit. The value on the other side of the Comparision equation should be your hero unit type.

Now we can add the actions to update the display of the leaderboard. First we need to update our Kills variable we made at the very start. To do this use are going to use the Modify Variable (Integer) action to add 1 to the total kills made by the killing player. Set the Variable parameter to our Kills variable. You should notice that an Index parameter now shows up. Set this to the function Owner of Unit with the Unit parameter set to the function Killing Unit. Leave the Operator parameter as + and Value as 1.

Now we can add our final action. This action will update the display of the leaderboard to show the new number of kills stored in the Kills variable. Use the Set Leaderboard Item Text action and set the Board parameter to LBoard (our leaderboard variable); the Row parameter to an Arithmetic (Integer) function with the first value set the function Owner of Unit and Unit parameter set to the function Killing Unit, and our second value of the Arithmetic (Integer) function to 1; the Column parameter to 2 and Text to the function Convert Integer to Text, with the Integer parameter set to our global variable Kills and index to the function Owner of Unit with the Unit parameter set to the function Killing Unit.

Trigger:
  • Kills
    • Events
      • Unit - Any Unit dies
    • Local Variables
    • Conditions
      • (Unit Type of Unit (Owner of (Killing unit))) == Nova
    • Actions
      • Variable - Modify Kills[(Owner of (Killing unit))]: + 1
      • Leaderboard - Set Leaderboard item text at column 2 and row ((Owner of (Killing unit)) + 1) to (Text(Kills[(Owner of (Killing unit))]))



There that should be it. Hopefully I have covered everything in enough detail. If I have missed something or something doesn't make sense, please let me know and I'll try to clarify it for you.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top