#Playtime leaderboard

1 messages · Page 1 of 1 (latest)

wild willow
#

Hello!
I have a skript thats supposed to senda playtime leaderboard (using player's time played rather than storing playtime by counting every second)

command /playtimeleaderboard:
    trigger:

        loop all offline players:
            set {_t} to "%loop-offline player's time played%"

            replace all " days" in {_t} with "d"
            replace all " day" in {_t} with "d"
            replace all " hours" in {_t} with "h"
            replace all " hour" in {_t} with "h"
            replace all " minutes" in {_t} with "m"
            replace all " minute" in {_t} with "m"
            replace all " seconds" in {_t} with "s"
            replace all " second" in {_t} with "s"
            replace all " and" in {_t} with ""


            add "%{_t}% | %loop-offline player%" to {_entries::*}

        set {_sorted::*} to sorted {_entries::*}

        loop reversed {_sorted::*}:
            set {_parts::*} to loop-value split at "|"
            send "%loop-counter%. %{_parts::2}% - %{_parts::1}%" to player

            if loop-counter >= 10:
                stop

The issue is that it doesn't sort properly (out of order) because it takes 19h to be greater than 1 day as its no longer parsed as a timespan (I think), I would appreciate a possible fix avoiding just storing playtime in a conventional way

pure hollow
#

well since its a string, you are sorting alphabetically

#

what you could do, is set {_time::%loop-player's UUID%} to (ticks of loop-player's time played) and then use the sorted indices expression

wild willow
# pure hollow what you could do, is `set {_time::%loop-player's UUID%} to (ticks of loop-playe...

putting the line set {_time::%loop-offline player's UUID%} to (ticks of loop-offline player's time played)
or more specifically (ticks of loop-player's time played)
just stops the playtimeleaderboard command from registering as a command in skript, no errors on load the command just doesnt exist anymore (+lines that previously errored within the section now dont error)
Even doing something like

    permission: op
    trigger:
        broadcast ticks of player's time played
        

stops the testtime command from like existing