Solved What is Better to use?

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

Uzumaki

Well-Known Member
Feb 20, 2017
310
10
18
What is Better to use? - for performance.

1.
code_language.skript:
every second:
    loop all players:
        if stylish scoreboard "HUB-%loop-player%" does not exist:
            create new stylish scoreboard named "HUB-%loop-player%"
            loop 16 times:
                create a new id based score "HUB-%loop-player%Slot%loop-number%" with text "&%loop-number%" slot loop-number for stylish scoreboard "HUB-%loop-player%"
        wait 3 ticks
        set title of stylish scoreboard "HUB-%loop-player%" to "HELLO"
        set stylish scoreboard of loop-player to "HUB-%loop-player%"
        set the text of id "HUB-%loop-player%Slot16" to "BLA"

2.
code_language.skript:
on join:
    while player is online:
        update_scoreboard(player)
        wait 1 seconds
        
        
        
function update_scoreboard(p: player):
    if stylish scoreboard "HUB-%{_p}%" does not exist:
        create new stylish scoreboard named "HUB-%{_p}%"
        loop 16 times:
            create a new id based score "HUB-%{_p}%Slot%loop-number%" with text "&%loop-number%" slot loop-number for stylish scoreboard "HUB-%{_p}%"
    wait 3 ticks
    set title of stylish scoreboard "HUB-%{_p}%" to "HELLO"
    set stylish scoreboard of {_p} to "HUB-%{_p}%"
    set the text of id "HUB-%{_p}%Slot16" to "BLA"
 
the second one is more efficient, alot of known members around heavily advice against ever using the "every x" event, you have the right idea in the second block of code except for your update function you're actually remaking the scoreboard every time, skellett has syntax to update individual lines of the scoreboard including the title if I'm not mistaken, and as far as I know that would decrease the amount of flicker if I'm not wrong, I would advice running the code that creates the scoreboard on the on join event and after that piece of code do the while player is online block of code that updates it every second, obviously remake your update scoreboard function so that it includes the code needed to update the scoreboard
 
  • Like
Reactions: Uzumaki
Status
Not open for further replies.