Toplist Position

  • 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 community!

    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!

Status
Not open for further replies.
D

Deleted member 239

Hello,

I have a pvp ranking toplist in Skript.

How can i send my position?

Example:

Top 3:
Name
Name
Name

You are #485 in the ranking.

Best regards
H0peLess
 
This is a request. Please post it in the request forum using the correct format.
 
Hello,

I have a pvp ranking toplist in Skript.

How can i send my position?

Example:

Top 3:
Name
Name
Name

You are #485 in the ranking.

Best regards
H0peLess
How have you stored the data?
I have an idea on how to do this.
 
My variables:

{Kills::*}
{Kills::%player's uuid%}

Its possible but i don't know how
 
What does {Kills::*} store?

I'm guessing {Kills::*} stores the amount of kills by a player. The loop-index is the player's uuid, and the loop-value is the amount of kills. I think; this is a speculation. It would make sense for it to be this way from the information given.
 
Ok then it would be something like this:
code_language.skript:
Set {_playerrank} to 1
Loop {Kills::*}:
    If {Kills::%loop-value%} > {Kills::%uuid of player}:
        Add 1 to {_playerrank}
 
doesn't work :/
I think its because there is no such {Kills::*}.
Could you execute this code (assuming you're on a test server) and tell me what it says (or take a screen):
code_language.skript:
Loop {Kills::*}:
    Broadcast "%loop-value%"
[doublepost=1500388255,1500388119][/doublepost]
code_language.skript:
function getTopRanking(type: text) :: texts:
    loop {%{_type}%::*}:
        add 1 to {_size}
        if {_low.to.high.list::%loop-value%} isn't set:
            set {_low.to.high.list::%loop-value%} to loop-index
        else:
            set {_n} to 0
            loop {_size} times:
                set {_n} to {_n}+1
                if {_low.to.high.list::%loop-value-1%.%{_n}%} isn't set:
                    set {_low.to.high.list::%loop-value-1%.%{_n}%} to loop-index
                    stop loop
    set {_n} to size of {_low.to.high.list::*}
    loop {_low.to.high.list::*}:
        set {_high.to.low.list::%{_n}%} to loop-value
        set {_n} to {_n}-1
    return {_high.to.low.list::*}
   
command /top [<text>]:
    trigger:
        if arg-1 is "kills":
            set {_type} to "%arg-1%"
            set {_top::*} to getTopRanking("%{_type}%")
            message ""
            loop {_top::*}:
                add 1 to {_topnumber}
                set {_player} to "%loop-value%" parsed as offlineplayer
                message " &a%{_topnumber}%) &7%{_player}%"
                if {_topnumber} > 9:
                    stop
            message ""
This skript parses the top 10 off players with the most kills right?
But the OP wants to show the ranking of the player executing the command :emoji_slight_smile:
 
I think its because there is no such {Kills::*}.
Could you execute this code (assuming you're on a test server) and tell me what it says (or take a screen):
code_language.skript:
Loop {Kills::*}:
    Broadcast "%loop-value%"
[doublepost=1500388255,1500388119][/doublepost]
This skript parses the top 10 off players with the most kills right?
But the OP wants to show the ranking of the player executing the command :emoji_slight_smile:

Yeah my bad , copy & past the wrong code.

That's the right code.

Rank POSITION
code_language.skript:
function getYourRank(p: player , type: text) :: integer:
    loop {%{_type}%::*}:
        add 1 to {_size}
        if {_low.to.high.list::%loop-value%} isn't set:
            set {_low.to.high.list::%loop-value%} to loop-index
        else:
            set {_n} to 0
            loop {_size} times:
                set {_n} to {_n}+1
                if {_low.to.high.list::%loop-value-1%.%{_n}%} isn't set:
                    set {_low.to.high.list::%loop-value-1%.%{_n}%} to loop-index
                    stop loop
    set {_n} to size of {_low.to.high.list::*}
    loop {_low.to.high.list::*}:
        set {_high.to.low.list::%{_n}%} to loop-value
        set {_n} to {_n}-1
    loop {_high.to.low.list::*}:
        add 1 to {_topnumber}
        set {_player} to "%loop-value%" parsed as offlineplayer
        if "%{_player}%" is "%{_p}%":
            set {_rank} to {_topnumber}
    return {_rank}
 
  • function getYourRank(p: player , type: text) :: integer:
  • loop {%{_type}%::*}:
  • add 1 to {_size}
  • if {_low.to.high.list::%loop-value%} isn't set:
  • set {_low.to.high.list::%loop-value%} to loop-index
  • else:
  • set {_n} to 0
  • loop {_size} times:
  • set {_n} to {_n}+1
  • if {_low.to.high.list::%loop-value-1%.%{_n}%} isn't set:
  • set {_low.to.high.list::%loop-value-1%.%{_n}%} to loop-index
  • stop loop
  • set {_n} to size of {_low.to.high.list::*}
  • loop {_low.to.high.list::*}:
  • set {_high.to.low.list::%{_n}%} to loop-value
  • set {_n} to {_n}-1
  • loop {_high.to.low.list::*}:
  • add 1 to {_topnumber}
  • set {_player} to "%loop-value%" parsed as offlineplayer
  • if "%{_player}%" is "%{_p}%":
  • set {_rank} to {_topnumber}
  • return {_rank}

Wow thanks!
And how can i create a command for this function?
 
@H0peLess Here you go:
code_language.skript:
command /example:
    trigger:
        set {_rank} to getYourRank( player , "kills")
        message "&7You are &c%{_rank}% &7in the ranking."
 
18-07-2017-1500388926.png
 
That's pretty strange , can you let me see what the variable {Kills::*} contains?
 
Only numbers.
18-07-2017-1500389286.png

But with player names.
add 1 to {Kills:%attacker%}
 
Try with caps and be sure you have some kills.
code_language.skript:
CODE=SKRIPT]command /example:
    trigger:
        set {_rank} to getYourRank( player , "Kills")
        message "&7You are &c%{_rank}% &7in the ranking."
[doublepost=1500389854,1500389453][/doublepost]
Try with caps and be sure you have some kills.
code_language.skript:
CODE=SKRIPT]command /example:
    trigger:
        set {_rank} to getYourRank( player , "Kills")
        message "&7You are &c%{_rank}% &7in the ranking."
You forgot one more ":" in the variable set:
code_language.skript:
{Kills:%attacker%} instead of {Kills::%attacker%}
 
Status
Not open for further replies.