Tutorial Leaderboard to one player in GUI

Reaction score
149
First of all, this is not a tutorial, thsi is just a basic covering of something I haven't seen covered up before.

I found it out some time ago and thought it's nothing too fabulous. But it seems that people might need to show a leaderboard to one player only, and the JASS solution of "if (that_player == GetLocalPlayer()) then..." might seem somewhat difficult for unexpierenced users, and so I thought I might share how to make a leaderboard via GUI that actually works for each player seperately!
The only bad thing is that it doesn't work with multiboards.. or does it? (I'll have to check it out again)

A small explanaition of how it works:
You make not one leaderboard, you make a few leaderboards that are shown to player seperately. Simple :p

Allright, let's begin.

You will need:
-1 Leaderboard Array Variable, let's call it "Skillboard" (for example :p )
-# of Leaderboard value Arrays (usually integer, if you want to change the values only), you will need an array for every leaderbord value.
-1 Integer variable called "tempInt"
-Few minutes to read this and do everything in your WE.


Allright, here goes the code for making the whole leaderboard:
Code:
SkillBoard Copy
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        Set Players = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))
        Player Group - Pick every player in (All players) and do (Actions)
            Loop - Actions
                Set tempInt = (Player number of (Picked player))
                Leaderboard - Create a leaderboard for (Player group((Picked player))) titled Hero Ability Levels:
                Leaderboard - Add Player 1 (Red) to (Last created leaderboard) with label Skill and value Hero_Ability_level_1st[tempInt]
                Leaderboard - Add Player 2 (Blue) to (Last created leaderboard) with label Skill and value Hero_Ability_level_2nd[tempInt]
                Leaderboard - Add Player 3 (Teal) to (Last created leaderboard) with label Skill and value Hero_Ability_level_3rd[tempInt]
                Leaderboard - Add Player 4 (Purple) to (Last created leaderboard) with label Skill and value Hero_Ability_level_4th[tempInt]
                Set SkillBoard[(Player number of (Picked player))] = (Last created leaderboard)
                Leaderboard - Show (Last created leaderboard)

Voila, you have a leaderboard for every player.
Each player represents something, for example, a Hero Ability level, as in my case, they are all Integer Arrays.

Pretty cool already, just it shows (probably) the same (probably) information for everyone.

So, we have to update it, as in this trigger below:
Code:
Skill Update
    Events
        Unit - A unit Learns a skill
    Conditions
Actions
    Leaderboard - Hide SkillBoard[tempInt]
    Set tempInt = (Player number of (Owner of (Learning Hero)))
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Level of <Ability> for (Learning Hero)) Greater than Hero_Ability_level_1st[tempInt]
        Then - Actions
            Set Hero_Ability_level_1st[tempInt] = (Level of <Ability> for (Learning Hero))
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Level of <Ability> for (Learning Hero)) Greater than Hero_Ability_level_2nd[tempInt]
        Then - Actions
            Set Hero_Ability_level_2nd[tempInt] = (Level of <Ability> for (Learning Hero))
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Level of <Ability> for (Learning Hero)) Greater than Hero_Ability_level_3rd[tempInt]
        Then - Actions
            Set Hero_Ability_level_3rd[tempInt] = (Level of <Ability> for (Learning Hero))
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Level of <Ability> for (Learning Hero)) Greater than Hero_Ability_level_4th[tempInt]
        Then - Actions
            Set Hero_Ability_level_4th[tempInt] = (Level of <Ability> for (Learning Hero))
        Else - Actions
    Leaderboard - Show SkillBoard[tempInt]


Voila! A working leaderboard that shows shows different values for different players!
 

Mr Zero

Junior Regular (Got the T-shirt)
Reaction score
64
You're a tricky one, nice idea. :)
It should work with multiboards too.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
You're a tricky one, nice idea. :)
It should work with multiboards too.

For multiboards, you would have less hassle, since you can choose what row you want to alter.

In leaderboards you have to alter player "scores"


Which leads to me saying: nicely thought of to set player names to skill names, etc.

Nice one ;)
+rep
 
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