Solved Efficient way to display health under playername

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

Cybers_

Member
Feb 21, 2017
18
2
0
I'm currently using


code_language.skript:
on damage:
    wait 1 tick
    set {_health} to floor(health of victim*10)   
    set score "%%" below victim to {_health} for attacker
        
every 1 seconds:
    loop all players:
        world of loop-player is not "Spawn"
        wait 0.1 tick
        set {_health} to floor(health of loop-player*10)   
        loop all players:
            set score "%%" below loop-player-1 to {_health} for loop-player-2

to display the health percentage of each player to all players, but once it reaches about 50+ players online it starts to drop the tps, what would be the most efficient way to display player health without it causing lag?
 
code_language.skript:
on damage:
    wait 1 tick
    set {_health} to floor(health of victim*10) 
    $ thread
    set score "%%" below victim to {_health} for attacker
      
every 1 seconds:
    loop all players:
        world of loop-player is not "Spawn"
        wait 0.1 tick
        set {_health} to floor(health of loop-player*10) 
        loop all players:
            $ thread
            set score "%%" below loop-player-1 to {_health} for loop-player-2

"$ thread" executes the next line asynchronous.
Updating takes a bit longer.
 
code_language.skript:
on damage:
    wait 1 tick
    set {_health} to floor(health of victim*10)
    $ thread
    set score "%%" below victim to {_health} for attacker
    
every 1 seconds:
    loop all players:
        world of loop-player is not "Spawn"
        wait 0.1 tick
        set {_health} to floor(health of loop-player*10)
        loop all players:
            $ thread
            set score "%%" below loop-player-1 to {_health} for loop-player-2

"$ thread" executes the next line asynchronous.
Updating takes a bit longer.
Thanks! I use "$ thread" for all the mysql stuff, didn't realise it could be used for other effects.
 
Status
Not open for further replies.