SC2Mapster Forums

Development > Triggers

How do you sort by kills for a dialog leaderboard?

  • 11 posts
    #1 Jan 15, 2013 at 17:46 UTC - 0 likes

    I have a leaderboard that is made of dialogs (with images as portraits, etc)

    How do you sort a dialog leaderboard by kills though?

    Thanks in advance

    #2 Jan 15, 2013 at 21:15 UTC - 0 likes

    What do you mean by sort the dialog by kills? Do you want to sort the kills into catagories, do you want to sort them by the type of unit killed, do you want to sort the by who has the most kills.  A little light into what you are doing would be appreciated. :)

    #3 Jan 16, 2013 at 15:33 UTC - 0 likes

    Since it's a dialog, and not an actual leaderboard element, you'll have to re-populate the dialog every time you want it updated.

    So the loop that you use to fill out all the variable values, you'll want to run that again with the new order of players based on current kills.

    That sounds like a lot of updating to me though.

    Last edited Jan 16, 2013 by playpong
    #4 Jan 18, 2013 at 18:05 UTC - 0 likes

    You're going to need to do a bubble sort against parallel arrays (one array holding kills, another holding the player Ids) and then update your dialog accordingly.

    #5 Jan 18, 2013 at 19:59 UTC - 0 likes

    yea to clarify what i want is the player with most kills on the top slot, player with the 2nd amount of kills in the 2nd slot etc,

    What is bubble sort? what are the actions i should use to actually sort the amount of kills?

    #6 Jan 19, 2013 at 00:40 UTC - 0 likes

    essentially you need to run a periodic check that sorts the players on kills into the correct order, here i'll work on an example map for you.

    #7 Jan 19, 2013 at 02:28 UTC - 0 likes

    When players are tied for kills it will go with the highest numbered player.

    Name Size MD5
    Leaderboard_example.SC2Map 19.9 KiB 5a9bf1956f05...
    #8 Jan 20, 2013 at 04:30 UTC - 0 likes

    @willuwontu: Go

    Thanks!

    going try it out right now! :)

    #9 Jan 28, 2013 at 04:07 UTC - 0 likes

    from the example map, how would you find the specific "rank" for each player?

    for example, player 1(red) has most kills, so he is at the top of the leaderboard, and I want to display a big "#1" on his screen

    if he is in 2nd place, then a dialog would display a big "#2" on his screen

    is there anyway to get the "rank #" for that player?

    (i looked at the variables in the example map, and see a "rank variable" but it doesnt match up to the actual rank that the player is)

    I displayed the "rank variable" in the debug, and doesnt always match up (player 1 has most kills and top of the leaderboard but the "rank variable" displays 4................posted screenshot)

    Is there someway to return the actual rank of the player so I can display a dialog that shows a big "YOU ARE RANK #..."

    Thanks

    Last edited Jan 28, 2013 by HatsuneMikuMegurine
    • How_to_return_the_rank_for_each_player.jpg
    #10 Jan 28, 2013 at 05:16 UTC - 0 likes

    like this? it seems to work for me?. check it out closely. make sure you understand the triggers if you don't just ask me.

    Last edited Jan 28, 2013 by willuwontu
    Name Size MD5
    Leaderboard_example.SC2Map 22.3 KiB 4704ba1dc0c6...
    #11 Jan 28, 2013 at 17:33 UTC - 0 likes

    @willuwontu: Go

    yea i think i may have messed up somewhere with the active players/all players/and the general debug message lol

    works now

    you are super awesome, thanks!

  • 11 posts

You must login to post a comment. Don't have an account? Register to get one!