1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Stop a specific loop

Discussion in 'Skript' started by Goetheus, Feb 6, 2017.

Thread Status:
Not open for further replies.
  1. Goetheus

    Goetheus Guest

    Hi everybody!

    As titles, I would like to stop a specefic loop and not all the tree.

    For exemple:
    Code (Skript):
    1. loop 5 times:
    2.     #do stuff
    3.     loop 3 times:
    4.         if {_var} is set:
    5.             #do stuff
    6.         else:
    7.             stop loop-2
    Is it possible?!

    Thank you in advance!
    Kiss <3
     
  2. Best Answer:
    Post #2 by ShaneBee, Feb 6, 2017
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    225
    http://skunity.com/search?search=exit
    You would use it as:
    Code (Skript):
    1. exit %amount of loops in descnding order% loop(s)
    2.  
    3. exit 1 loop
    4. # Exits the most current loop.
    5.  
    6. exit 2 loops
    7. # Exits the current loop and the parent loop.
     
    • Agree Agree x 2
    • Useful Useful x 2
    • Like Like x 1
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    225
    You can also try adding a counter.

    Code (Skript):
    1. loop 5 times:
    2.     add 1 to {_c}
    3.     if {_c} is 3:
    4.         # Do stuff
    Idk if this helps you though :emoji_stuck_out_tongue:
     
    • Like Like x 1
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    225
    Hi mathhulk and Charles!

    Thank you for you answers! Both are usefull! :emoji_slight_smile:
     
Thread Status:
Not open for further replies.

Share This Page

Loading...