UUID->Username in %loop-value%

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

JaynitXI

Member
Mar 8, 2024
3
0
1
25
Hello, I would like to display the username and not the UUID:
Code:
            if arg-1 is "top":
                loop all offline players:
                    set {_player} to loop-value
                    set {_list::%loop-value%} to "%{_player}.getStatistic(Statistic.PLAY_ONE_MINUTE)% ticks" parsed as timespan
                loop {_list::*}:
                    add loop-index to {_inverted::%loop-value%::*}
                set {_position} to 1
                loop reversed sorted {_list::*}:
                    {_last} is not loop-value
                    set {_last} to loop-value
                    loop {_inverted::%loop-value%::*}:
                        set {_sorted::%{_position}%} to loop-value-2
                        add 1 to {_position}
                send "%nl%&aClassement - Playtime &7: Les meilleurs temps de jeu%nl%"
                loop {_sorted::*}:
                    stop if loop-index parsed as an integer > 8
                    send " &7• &l%loop-index%&r &7: &e%loop-value% &7(%ptConvertTime({_list::%loop-value%}, true)%&7)"
                stop

Full code:
Code:
# Copyright 2020  Clément Raynaud (carlodrift)

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import:
    ch.njol.skript.Skript
    java.io.BufferedReader
    java.io.InputStreamReader
    java.net.URL
    org.bukkit.Statistic

function ptConvertTime(timespan: timespan, top: boolean) :: text:
    set {_string} to "%{_timespan}%"
    replace all "." with "," in {_string}
    if {_top} is true:
        replace all "and" with "et" in {_string}
    else:
        replace all "and" with "&7et&e" in {_string}
    replace all "second" with "seconde" in {_string}
    replace all "hour" with "heure" in {_string}
    replace all "day" with "jour" in {_string}
    return {_string}
    
command /playtime [<text>] [<text>]:
    trigger:
        if arg-1 is not set:
            set {_player} to player
            set {_time} to ptConvertTime("%player.getStatistic(Statistic.PLAY_ONE_MINUTE)% ticks" parsed as timespan, false)
            send "%nl%&aPlaytime &8• &7Votre temps de jeu est de &e%{_time}%&7."
        else:
            if arg-1 is "top":
                loop all offline players:
                    set {_player} to loop-value
                    set {_list::%loop-value%} to "%{_player}.getStatistic(Statistic.PLAY_ONE_MINUTE)% ticks" parsed as timespan
                loop {_list::*}:
                    add loop-index to {_inverted::%loop-value%::*}
                set {_position} to 1
                loop reversed sorted {_list::*}:
                    {_last} is not loop-value
                    set {_last} to loop-value
                    loop {_inverted::%loop-value%::*}:
                        set {_sorted::%{_position}%} to loop-value-2
                        add 1 to {_position}
                send "%nl%&aClassement - Playtime &7: Les meilleurs temps de jeu%nl%"
                loop {_sorted::*}:
                    stop if loop-index parsed as an integer > 8
                    send " &7• &l%loop-index%&r &7: &e%loop-value% &7(%ptConvertTime({_list::%loop-value%}, true)%&7)"
                stop
            else if arg-1 is "player":
                arg-2 is set
                set {_players::*} to all offline players
                {_players::*} contains arg-2:
                    set {_player} to arg-2 parsed as an offline player
                    set {_time} to ptConvertTime("%{_player}.getStatistic(Statistic.PLAY_ONE_MINUTE)% ticks" parsed as timespan, false)
                    send "%nl%&aPlaytime &8• &7Le temps de jeu du joueur est de &e%{_time}%&7."
                else:
                    send "%nl%&aPlaytime &8• &7Ce joueur n'a jamais joué ici."
                stop    
            send "%nl%&aAide - Playtime &7: Les différentes commandes%nl%"
            send " &7• &e/playtime"
            send " &7• &e/playtime top"
            send " &7• &e/playtime player <joueur>"
            send " &7• &e/playtime help%nl%"
 
Try parsing the uuid as a player. For exemple, if loop-index is a player's uuid, do (loop-index parsed as player)
 
set {_example} to loop-value parsed as offline player before the send, it's solved! thank you very much.
 
Last edited: