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.

Problem with looping, even though there is no loop...

Discussion in 'Skript' started by memes, Apr 21, 2019.

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

    memes Member

    Joined:
    Jun 24, 2018
    Messages:
    23
    Likes Received:
    2
    So this is my skript, pretty much it will keep on looping until {_n} is 1... I have no clue why...
    Code (Text):
    1. on damage:
    2.     if attacker is player:
    3.         if victim is player:
    4.             if victim is not attacker:
    5.                 set {_e::*} to enchantments of attacker's tool
    6.                 if "%{_e::*}%" contains "Knockback" or "punch":
    7.                     if slot 8 of victim's inventory is an eye of ender:
    8.                         set {_l} to lore of slot 8 of victim's inventory
    9.                         replace all "&7Uses: &d&n" in {_l} with ""
    10.                         set {_n} to {_l} parsed as integer
    11.                         remove 1 from {_n}
    12.                         broadcast "%{_n}%"
    13.                         if {_n} > 0:
    14.                             set slot 8 of victim's inventory to eye of ender of mending 1 named "&d&lCHARM &8| &5Anti-Knockback" with lore "&7Uses: &d&n%{_n}%"
    15.                             cancel event
    16.                             make attacker damage victim by damage
    17.                             send "&d&lCHARMS &8| &7%victim% has used their anti-knockback charm." to attacker
    18.                             send "&d&lCHARMS &8| &7You have used your anti-knockback charm! &7Uses: &d&n%{_n}%" to victim
    19.                             stop
    20.  
     
  2. AsuDev

    VIP

    Joined:
    Jan 27, 2017
    Messages:
    243
    Likes Received:
    22
    You stated "make attacker damage victim by damage" which repeats the damage event. You are basically recursively triggering the damage event until the condition is not met anymore 'if {_n} > 0'. I don't know why you are canceling the event tbh.
     
    #2 AsuDev, Apr 22, 2019
    Last edited: Apr 22, 2019
Thread Status:
Not open for further replies.

Share This Page

Loading...