NEEDS HELP FIXING CODE - LEADERBOARD

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

daniel_

Member
Feb 20, 2025
4
0
1
Hi,

I'm trying to make a leaderboard skript for my server with holograms.

I need to know how to find the player's (online + offline) with the highest number in their {time::%player's uuid%} variable and then set their time and username in a variable for a hologram.
I need to make the console execute the command /db line set 1st 1 2 [this would be the player's username] and then also do /db line set 1st 1 3 [this would be the {time::%player's uuid%} variable.

I would need to repeat this for 1st, 2nd and 3rd.

Anything helps, thanks.
- daniel_
 
Hi,

I'm trying to make a leaderboard skript for my server with holograms.

I need to know how to find the player's (online + offline) with the highest number in their {time::%player's uuid%} variable and then set their time and username in a variable for a hologram.
I need to make the console execute the command /db line set 1st 1 2 [this would be the player's username] and then also do /db line set 1st 1 3 [this would be the {time::%player's uuid%} variable.

I would need to repeat this for 1st, 2nd and 3rd.

Anything helps, thanks.
- daniel_
Hi,

You can loop every player by:

loop all offline players:

You can use execute console command "command" to make console run a command.
 
Code:
command /updateleaderboard:
    trigger:
        # Step 1: Create an empty list to store pairs of UUID and time
        set {_leaderboard::*} to all elements of {time::*}

        # Step 2: Sort the leaderboard by time, descending
        set {_sorted::*} to the sorted elements of {_leaderboard::*} by value descending

        # Step 3: Get the top 3 UUIDs from the sorted list
        set {_1st} to {_sorted::1}
        set {_2nd} to {_sorted::2}
        set {_3rd} to {_sorted::3}

        # Step 4: Get the player names based on their UUIDs
        set {_name1} to {playername::%_1st%}
        set {_name2} to {playername::%_2nd%}
        set {_name3} to {playername::%_3rd%}

        # Step 5: Get the times for top players
        set {_time1} to {time::%_1st%}
        set {_time2} to {time::%_2nd%}
        set {_time3} to {time::%_3rd%}

        # Step 6: Display the leaderboard
        execute console command "/db line set 1st 1 2 %{_name1}%"
        execute console command "/db line set 1st 1 3 %{_time1}%"

        execute console command "/db line set 2nd 1 2 %{_name2}%"
        execute console command "/db line set 2nd 1 3 %{_time2}%"

        execute console command "/db line set 3rd 1 2 %{_name3}%"
        execute console command "/db line set 3rd 1 3 %{_time3}%"

        # Optional: Send a message to the player
        send "&7Leaderboard updated!" to player

i got this code from chatgpt and I need help. I get these errors attacked, can you help?
 

Attachments

  • image_2025-02-23_153336307.png
    image_2025-02-23_153336307.png
    29.5 KB · Views: 100
  • image_2025-02-23_153404730.png
    image_2025-02-23_153404730.png
    28.4 KB · Views: 106
error 1:
use set {_leaderboards::*} to {_time::*}

error 2:
You can't do this like that.

error 3:
it's {_1st} not _1st


All other errors are same with error3.
 
 
thank you everythings working but this. I tried this:

Code:
set {_sorted::*} to {_leaderboard::*} sorted in decending order of value