Top 3 wont work correctly

  • 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.

Mattllama987

Supporter
Aug 5, 2018
225
7
18
Hello, im working on a fishing skript, and when the contest is over, it should send the top 3 fishers with the biggest fish. But when the contest is over, it will send the most recent fish the player caught. So, lets say i caught a fish thats 12.43cm and after i go that fish, i caught another one thats 4.65cm, it should send the 12.43cm fish because its the biggest one. But it will send the 4.65cm one because it was the most recent fish. It was working just fine not to long ago, and just starting not working the other day. Ive been scratching my head at this for a long time, and not sure what is wrong with it? If anyone can help me, it will be very much appreciated!
Thanks!
~Matt

Skript version: 2.4
Skript-Mirror version: 2.0.0 snapshot
Server version: Paper Spigot 1.14.4

Code:

Code:
function pigeonhole(indices: objects, values: numbers, ascending: boolean = false) :: objects:

  loop {_indices::*}:
    set {_v} to "%(loop-index parsed as integer)th element out of {_values::*}%"
    set {_split::*} to {_v} split at "."
    add length of {_split::2} ? 0 to {_p::*}
    add loop-value to {_temp::%{_v}%::*}
    
  set {_prec} to 10^(max({_p::*})+1)

  loop all integers from min({_values::*})*{_prec} to (max({_values::*})+1)*{_prec}:
    set {_v} to loop-value / {_prec}
    if {_temp::%{_v}%::*} is set:
      loop {_temp::%{_v}%::*}:
        add loop-value-2 to {_sorted::*}
        
  if {_ascending} is true:
    return {_sorted::*}
  else:
    return reversed ({_sorted::*})
command /contestcaughtfishtop:
    trigger:
        set {_indices::*} to indices of {size::fish::*}
        set {_sorted-fish::*} to pigeonhole({_indices::*}, {size::fish::*})
        set {_topfisher} to first element out of {_sorted-fish::*}
        broadcast "&b[Fishing] &fThe fishing contest has ended!"
        loop {_sorted-fish::*}:
            set {_i} to loop-index parsed as integer
            stop loop if {_i} > 3
            broadcast "&e%{_i}%: &a%loop-value%, &b%{size::fish::%loop-value%}%cm"
[doublepost=1586965473,1586194287][/doublepost]bump
 
Status
Not open for further replies.