Solved Loop players not working

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

aescraft

Well-Known Member
Mar 1, 2017
295
13
0
I'm working on a sleep / fatigue system for my server but I'm having trouble with this loop.
How to make it work?

First problem, every minute does not work without a world on it. The docs says it should, as the example has some timespans without a world select (just "every second:", for example).

The other problem is that the skript says there's no player in a periodical event. How I would do it then? The loop player should be set, as I used "loop all players" first.

The code:
code_language.skript:
every minute:
  loop all players:
    subtract 1 from {sono.%player%}
    if {sono.bypass} is set:
      stop
    if {sono.%loop-player%} < 25:
      apply Mining Fatigue to the loop-player for 60 seconds
    if {sono.%loop-player%} < 20:
      remove mining fatigue from the loop-player
      apply Mining Fatigue 2 to the loop-player for 60 seconds
    if {sono.%loop-player%} < 10:
      remove mining fatigue from the loop-player
      apply Mining Fatigue 3 to the loop-player for 60 seconds
    if {sono.%loop-player%} < 5:
      message "§b§oE-e... estou muito cansado... p-preciso dormir"
      apply slowness 1 to the loop-player for 60 seconds
      apply Mining Fatigue 5 to the loop-player for 60 seconds
    if {sono.%loop-player%} < -1:
      apply blindness 2 to the loop-player for 60 seconds
      stop
    if {sono.%loop-player%} < 1:
      apply blindness 1 to the loop-player for 60 seconds
      remove mining fatigue from the loop-player
      apply Mining Fatigue 9 to the loop-player for 60 seconds
      stop
    if {sono.%loop-player%} < 2:
      apply blindness 1 to the player for 30 seconds
      remove mining fatigue from the player
      apply Mining Fatigue 8 to the player for 60 seconds
      stop
    if {sono.%loop-player%} < 3:
      apply blindness 1 to the player for 15 seconds
      remove mining fatigue from the player
      apply Mining Fatigue 7 to the player for 60 seconds
      stop
    if {sono.%loop-player%} < 4:
      apply blindness 1 to the player for 10 seconds
      remove mining fatigue from the player
      apply Mining Fatigue 6 to the player for 60 seconds
      stop
 
I'm working on a sleep / fatigue system for my server but I'm having trouble with this loop.
How to make it work?

First problem, every minute does not work without a world on it. The docs says it should, as the example has some timespans without a world select (just "every second:", for example).

The other problem is that the skript says there's no player in a periodical event. How I would do it then? The loop player should be set, as I used "loop all players" first.

The code:
code_language.skript:
every minute:
  loop all players:
    subtract 1 from {sono.%player%}
    if {sono.bypass} is set:
      stop
    if {sono.%loop-player%} < 25:
      apply Mining Fatigue to the loop-player for 60 seconds
    if {sono.%loop-player%} < 20:
      remove mining fatigue from the loop-player
      apply Mining Fatigue 2 to the loop-player for 60 seconds
    if {sono.%loop-player%} < 10:
      remove mining fatigue from the loop-player
      apply Mining Fatigue 3 to the loop-player for 60 seconds
    if {sono.%loop-player%} < 5:
      message "§b§oE-e... estou muito cansado... p-preciso dormir"
      apply slowness 1 to the loop-player for 60 seconds
      apply Mining Fatigue 5 to the loop-player for 60 seconds
    if {sono.%loop-player%} < -1:
      apply blindness 2 to the loop-player for 60 seconds
      stop
    if {sono.%loop-player%} < 1:
      apply blindness 1 to the loop-player for 60 seconds
      remove mining fatigue from the loop-player
      apply Mining Fatigue 9 to the loop-player for 60 seconds
      stop
    if {sono.%loop-player%} < 2:
      apply blindness 1 to the player for 30 seconds
      remove mining fatigue from the player
      apply Mining Fatigue 8 to the player for 60 seconds
      stop
    if {sono.%loop-player%} < 3:
      apply blindness 1 to the player for 15 seconds
      remove mining fatigue from the player
      apply Mining Fatigue 7 to the player for 60 seconds
      stop
    if {sono.%loop-player%} < 4:
      apply blindness 1 to the player for 10 seconds
      remove mining fatigue from the player
      apply Mining Fatigue 6 to the player for 60 seconds
      stop
Probably because of
code_language.skript:
subtract 1 from {sono.%player%}

Change it to
code_language.skript:
subtract 1 from {sono.%loop-player%}
 
Probably because of
code_language.skript:
subtract 1 from {sono.%player%}

Change it to
code_language.skript:
subtract 1 from {sono.%loop-player%}
The server is crashing now. Is there another way to do this loop?
[doublepost=1491768131,1491754780][/doublepost]Ok, the issue was not with the code.
Its working now with the %loop-player%.
 
Status
Not open for further replies.