(Skript) Every x seconds delayed?

Discussion in 'Spigot Plugin Development' started by LachGameZ, Jul 5, 2017.

  1. Hello Spigot! I've been experimenting with Skript and some of it's features, but I found in my code below, each every statement is delayed by 7 or so seconds?
    Code (Text):
    every 300 seconds:
      delete all dropped items
      loop all players:
        send action bar from "Dropped items were removed." to loop-player
      stop
    every 240 seconds:
      loop all players:
        send action bar from "Dropped items will be removed in 1 minute" to loop-player
      stop
    every 270 seconds:
      loop all players:
        send action bar from "Dropped items will be removed in 30 seconds" to loop-player
      stop
    every 290 seconds:
      loop all players:
        send action bar from "Dropped items will be removed in 10 seconds" to loop-player
      stop
    every 295 seconds:
      loop all players:
        send action bar from "dropped items will be removed in 5 seconds" to loop-player
      stop
    every 296 seconds:
      loop all players:
        send action bar from "Dropped items will be removed in 4 seconds" to loop-player
      stop
    every 297 seconds:
      loop all players:
        send action bar from "Dropped items will be removed in 3 seconds" to loop-player
      stop
    every 298 seconds:
      loop all players:
        send action bar from "dropped items will be removed in 2 seconds" to loop-player
      stop
    every 299 seconds:
      loop all players:
        send action bar from "dropped items will be removed in 1 second" to loop-player
      stop
    Would anyone know why this is slow?

    Thanks.
     
  2. Praya

    Benefactor

    what statement do you mean?
     
  3. Praya

    Benefactor

    the code is delayed because you send an action bar to all players in 1 code.

    this means every loop player, the code will create new Packet that needs time.
    ex:
    - 1 action bar in skript need 0.01 seconds and on your server, there are 100 players online this means the first loop player will get a message instant and the last loop player will receive after 1 seconds. It's better to make a function

    to make a better performance. You should write the code in 1 event rather than make multi-events.
    ex:

    Code (Text):
    every 300 seconds:
      set {_loop} to 10
      loop {_loop} times:
        set {_timeLeft} to ({_loop} + 1) - (loop-number)
        loop all players:
          send action bar from "Dropped items will be removed in %{_timeLeft}%" to loop-player
        wait 1 seconds
     
    • Useful Useful x 1
  4. sorry, didn't see it
    thanks, i'll try this.

    EDIT: works perfectly! thank you very much.
     
    #5 LachGameZ, Jul 5, 2017
    Last edited: Jul 5, 2017
  5. Praya

    Benefactor

    you're welcome
     

Share This Page