Solved Loop Players Issue

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

Status
Not open for further replies.

Turb032

Active Member
Jan 16, 2020
109
0
16
21
Hi guys, i've been searching for a long time a way to loop all players at the same time and creating a bossbar. The problem is that the bossbar does not show for all the players, but for only ONE player. Here is my code:
Code:
every 1 tick:
    loop all players:
        create bossbar titled "&a&lLevel &7&l[&6&l%{level.%loop-player%}%&7&l] &7&l[&b%{exp.%loop-player%}%&7&l]" and id "level" for loop-player with progress {exp.%loop-player%} with colors blue
        if {exp.%loop-player%} is greater than or equal to 100:
            set {exp.%loop-player%} to 0
            add 1 to {level.%loop-player%}
            send loop-player title "&a&lLevel Up!" with subtitle "&7&m&l---------------" for 2 seconds
            play sound "entity.player.levelup" with volume 1 at loop-player
            stop
 
Last edited:
try this (?)
Code:
 and id "level.%loop-player%"

and also DON'T use every 1 tick, no one would recommend u to use that shit, this will decrease ur server performance

example: if you have 40 players online and "every x (tick | second)" with "loop all players", the server will loop players 800 times in 1 second = 20 ticks, 1 tick = 50 ms

Code:
on join:
    while player is online:
        #do stuff
        wait 1 second
 
Last edited:
Ok, now i have this:
Code:
on join:
    while player is online:
        create bossbar titled "&6&lLevel &f[&6&l%{level.%player%}%&f]   &bExp &f[&b%{exp.%player%}%&f]" and id "level.%player%" for player with progress {exp.%player%} with colors blue
        if {exp.%player%} is greater than or equal to 100:
            set {exp.%player%} to 0
            add 1 to {level.%player%}
            send player title "&a&lLevel Up!" with subtitle "&7&m&l---------------" for 2 seconds
            play sound "entity.player.levelup" with volume 1 at player
            wait 1 second
But now when i join the server, it shows me 1 Bossbar and often 2 glitched bossbars, also, when i join, the server does not load chunks and than it crashes.. Any idea?
 
Ok, now i have this:
Code:
on join:
    while player is online:
        create bossbar titled "&6&lLevel &f[&6&l%{level.%player%}%&f]   &bExp &f[&b%{exp.%player%}%&f]" and id "level.%player%" for player with progress {exp.%player%} with colors blue
        if {exp.%player%} is greater than or equal to 100:
            set {exp.%player%} to 0
            add 1 to {level.%player%}
            send player title "&a&lLevel Up!" with subtitle "&7&m&l---------------" for 2 seconds
            play sound "entity.player.levelup" with volume 1 at player
            wait 1 second
But now when i join the server, it shows me 1 Bossbar and often 2 glitched bossbars, also, when i join, the server does not load chunks and than it crashes.. Any idea?

https://gyazo.com/8ad70cfeb83be50ec387279e91ad97a9
correct wait
Code:
on join:
    wait 1 second
    while player is online:
        create bossbar titled "&6&lLevel &f[&6&l%{level.%player%}%&f]   &bExp &f[&b%{exp.%player%}%&f]" and id "level.%player%" for player with progress {exp.%player%} with colors blue
        if {exp.%player%} is greater than or equal to 100:
            set {exp.%player%} to 0
            add 1 to {level.%player%}
            send player title "&a&lLevel Up!" with subtitle "&7&m&l---------------" for 2 seconds
            play sound "entity.player.levelup" with volume 1 at player
        wait 1 second

thats why the server is creating bossbars without waiting
 
DO NOT use while player is online..
this means, until the player leaves, every single second, this code was ran 20 times.
this is WAY better than EVERY 1 TICK, the server can do this without problem and read above what I said
 
Last edited:
Code:
on join:
    wait 5 seconds
    while player is online:
        create bossbar titled "&6&lLevel &f[&6&l%{level.%player%}%&f]   &bExp &f[&b%{exp.%player%}%&7 | &b%{maxexp.%player%}%&f]" and id "level.%player%" for player with progress {exp.%player%} with colors blue   
        if {exp.%player%} is greater than or equal to {maxexp.%player%}:
            set {exp.%player%} to 0
            add 1 to {level.%player%}
            send player title "&a&lLevel Up!" with subtitle "&7&m&l---------------" for 2 seconds
            play sound "entity.player.levelup" with volume 1 at player
            add 50 to {maxexp.%player%}
            wait 5 seconds
Aww... It still crashing the server, i just put wait 5 seconds instead of 1, but nothing, every time it crashes. With "every 1 tick" it works well, why shouldn't i do it?
[doublepost=1593684387,1593683898][/doublepost]
Code:
on join:
    wait 5 seconds
    while player is online:
        create bossbar titled "&6&lLevel &f[&6&l%{level.%player%}%&f]   &bExp &f[&b%{exp.%player%}%&7 | &b%{maxexp.%player%}%&f]" and id "level.%player%" for player with progress {exp.%player%} with colors blue  
        if {exp.%player%} is greater than or equal to {maxexp.%player%}:
            set {exp.%player%} to 0
            add 1 to {level.%player%}
            send player title "&a&lLevel Up!" with subtitle "&7&m&l---------------" for 2 seconds
            play sound "entity.player.levelup" with volume 1 at player
            add 50 to {maxexp.%player%}
            wait 5 seconds
Aww... It still crashing the server, i just put wait 5 seconds instead of 1, but nothing, every time it crashes. With "every 1 tick" it works well, why shouldn't i do it?
OOH wait, i just noticed that i put the second "wait seconds" in the wrong place.. It works well but, will it decrese server's performance or something?
 
@Turb032 You need to put the "wait 1 second" after "while player is online:" so that it doesn't lag. A while loop that keeps doing it over and over again without any timing will crash your server.
 
Code:
on join:
    wait 5 seconds
    while player is online:
        create bossbar titled "&6&lLevel &f[&6&l%{level.%player%}%&f]   &bExp &f[&b%{exp.%player%}%&7 | &b%{maxexp.%player%}%&f]" and id "level.%player%" for player with progress {exp.%player%} with colors blue
        if {exp.%player%} is greater than or equal to {maxexp.%player%}:
            set {exp.%player%} to 0
            add 1 to {level.%player%}
            send player title "&a&lLevel Up!" with subtitle "&7&m&l---------------" for 2 seconds
            play sound "entity.player.levelup" with volume 1 at player
            add 50 to {maxexp.%player%}
            wait 5 seconds
Aww... It still crashing the server, i just put wait 5 seconds instead of 1, but nothing, every time it crashes. With "every 1 tick" it works well, why shouldn't i do it?
[doublepost=1593684387,1593683898][/doublepost]
OOH wait, i just noticed that i put the second "wait seconds" in the wrong place.. It works well but, will it decrese server's performance or something?

you just need a good vps and will works without problems
 
Status
Not open for further replies.