Solved Infinite Loop?

  • 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.
Jul 1, 2017
22
0
0
34
How do I make an infinite loop in skript because whenever I try to do something periodically like "every second" it gives me an error.
 
Error:
https://gyazo.com/c98d06ff53279ec63adaa33ba7d40885

c98d06ff53279ec63adaa33ba7d40885


Code:
code_language.skript:
command /ksmenu13:
    trigger:
        if {team.%player%} is equal to "Red":
            if {corejump.progress.redteam} >= 20:
                message "&7Core Jump Buff Already Purchased."
            else if {kill_streak.%player%.count} >= 1:
                add 1 to {corejump.progress.redteam}
                set {kill_streak.%player%.count} to {kill_streak.%player%.count} - 1
                message "&7Added to Core Jump Buff total."
                if {corejump.progress.redteam} is equal to 20:
                    set {corejump.redteam} to 1
                    every second
                        if {corejump.redteam} is equal to 0:
                            stop loop
                        add 1 to {loop.count}
                        wait 1 second
                        broadcast "test"

https://gyazo.com/145ba92f3c9c2e84373c42b7fbf9da9f

145ba92f3c9c2e84373c42b7fbf9da9f
 
ah oky so you need to set it up similarly to how you do an if statement and define a world for it to count in.
code_language.skript:
every 1 seconds in "world":
    if {corejump.redteam} is equal to 0:
        stop loop
 
Ok, thanks sorry I didn't realize that can you loop all worlds or all players around a location? Like I have a variable set at a location I want to loop every second
[doublepost=1501385224,1501384659][/doublepost]
code_language.skript:
every second in radius 8 of {redcore}:
#     do stuff

Like that?
How would I make it loop players
[doublepost=1501385802][/doublepost]It's not working

code_language.skript:
command /ksmenu13:
    trigger:
        if {team.%player%} is equal to "Red":
            if {corejump.progress.redteam} >= 20:
                message "&7Core Jump Buff Already Purchased."
            else if {kill_streak.%player%.count} >= 1:
                add 1 to {corejump.progress.redteam}
                set {kill_streak.%player%.count} to {kill_streak.%player%.count} - 1
                message "&7Added to Core Jump Buff total."
                if {corejump.progress.redteam} is equal to 20:
                    set {corejump.redteam} to 1
                    every second in radius 8 of {redcore}:
                        if {corejump.redteam} is equal to 0:
                            stop loop
                        wait 1 second
                        apply jump boost to loop-player for 1 second

https://gyazo.com/afdfe1f5cff760b71b8a83b88b67c52d
 
Ok, thanks sorry I didn't realize that can you loop all worlds or all players around a location? Like I have a variable set at a location I want to loop every second
[doublepost=1501385224,1501384659][/doublepost]
code_language.skript:
every second in radius 8 of {redcore}:
#     do stuff

Like that?
How would I make it loop players
[doublepost=1501385802][/doublepost]It's not working

code_language.skript:
command /ksmenu13:
    trigger:
        if {team.%player%} is equal to "Red":
            if {corejump.progress.redteam} >= 20:
                message "&7Core Jump Buff Already Purchased."
            else if {kill_streak.%player%.count} >= 1:
                add 1 to {corejump.progress.redteam}
                set {kill_streak.%player%.count} to {kill_streak.%player%.count} - 1
                message "&7Added to Core Jump Buff total."
                if {corejump.progress.redteam} is equal to 20:
                    set {corejump.redteam} to 1
                    every second in radius 8 of {redcore}:
                        if {corejump.redteam} is equal to 0:
                            stop loop
                        wait 1 second
                        apply jump boost to loop-player for 1 second

https://gyazo.com/afdfe1f5cff760b71b8a83b88b67c52d
maybe try it like this? I just tried testing a bunch of possible sytaxes to loop at a set of coords, but no dice.
code_language.skript:
#This is just the test code I used, but it works for checking a player's proximity to a location
command /test:
    trigger:
        set {loc} to location of player
        send "%{loc}%"

command /loop:
    trigger:
        loop all players:
            if distance between loop-player and {loc} is smaller than 20:
                send "Moo"
 
Now my issue is the periodically loop isn't working, is it one of the plugins I have?

Plugins:
https://gyazo.com/36ba1b44c634968832d683a79a3569ce

Code:
code_language.skript:
command /ksmenu13:
    trigger:
        if {team.%player%} is equal to "Red":
            if {corejump.progress.redteam} >= 20:
                message "&7Core Jump Buff Already Purchased."
            else if {kill_streak.%player%.count} >= 1:
                add 1 to {corejump.progress.redteam}
                set {kill_streak.%player%.count} to {kill_streak.%player%.count} - 1
                message "&7Added to Core Jump Buff total."
                if {corejump.progress.redteam} is equal to 20:
                    set {corejump.redteam} to 1
                    every 1 seconds in "GameWorld":
                        loop all players in "GameWorld":
                            if distance between loop-player and {redcore} is smaller than 9:
                                apply jump boost to loop-player for 1 second

Error:
https://gyazo.com/6c73ca136f95de6e467beda68bb97b4e
[doublepost=1501386888,1501386775][/doublepost]I used to have wildskript that broke a bunch of stuff but I don't know what it is now
 
well right now your periodical isn't by itself it's only activated via command, so I would potentially try putting that bit on it's own(mind you I'm not 100% on that, just a hunch)
However, I see you have WorldGuard. So you could maybe pull off what I think you want to do by using an on region enter event instead of a loop. it'd be way less laggy too. Create a region around the location you want, and when a player enters give them jump boost for something like 900 days to keep it on them. then on region exit, clear them of their effects.
 
Instead of
code_language.skript:
every 1 seconds in "GameWorld":
  loop all players in "GameWorld":
    if distance between loop-player and {redcore} is smaller than 9:
      apply jump boost to loop-player for 1 second
use
code_language.skript:
while 1 is 1:
  loop all players in "GameWorld":
    if distance between loop-player and {redcore} is smaller than 9:
      apply jump boost to loop-player for 1 second
  wait 1 second
No addons required.
 
  • Like
Reactions: Wynnevir
Status
Not open for further replies.