Sort scores + player together

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

TACStudios

Member
Apr 21, 2025
10
0
1
Im trying to do a top 5 scores system for my game using this:
Code:
function sortGameRoundIndiv(gameName: string, type: string):
Where gameName is a game name and type is either round or game. The players score that would be parsed through this is stored like this:
Code:
{%{_type}%Indiv.%player%.%{_gameName}%}

Im trying to take that value and sort it BUT making sure there is a reference to who's score it is so that I can store it in a variable to broadcast later on in a format of "[position]. [player name] - [score of player]"

Im open to anything (using more function etc) because honestly ive been tryna get my brain around this for the past 2 hours and just cant think of a way that will work the way i want it to
 
Okay a little bit of an update that can help people answering, ive made this to determine the placement people are in for the game/round
Code:
function sortGameRoundIndiv(gameName: string, type: string):
  loop all players
    contains({spectator team::*}, loop-player) is false:
      set {IndivPlacement.%loop-player%} to (online player count - amount of elements in {spectator team::*})
      loop all players:
        loop-player-1 is equal to loop-player-2:
          stop
        contains({spectator team::*}, loop-player) is false:
          if {%{_type}%Indiv.%loop-player-1%.%{_gameName}%} > {%{_type}%Indiv.%loop-player-2%.%{_gameName}%}:
            remove 1 from {IndivPlacement.%loop-player-1%}
just dont know how to broadcast it in the way I want (that being top 5)
 
Final update, I think I found a way. For anyone out there who might ask the same question: I did not know you can have a list index be letters and not just numbers, but even better you can store a list index as a variable, for example a player name

That is amazing