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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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