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 Projectiles rate too fast

Discussion in 'Skript' started by IDuckz_, Jan 11, 2020.

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

    IDuckz_ Active Member

    Joined:
    Jul 25, 2019
    Messages:
    102
    Likes Received:
    2
    I am stuck with this bug, so I am making a guns script, everything is working fine, but I made an automatic gun and it just fires too quickly that some projectiles sometimes doesn't damage the entity (mob, animals, or players).

    Here is my code:

    Code (Text):
    1. command /gun:
    2.  permission: command.gun
    3.  permission message: no
    4.  trigger:
    5.   set {autoGun} to iron ingot named "&aAuto gun"
    6.   give {autoGun} to player
    7.  
    8. on rightclick:
    9.     if player is holding {autoGun}:
    10.         if {autoGun::%player's uuid%} is set:
    11.             if now > {autoGun::%player's uuid%}:
    12.                 shoot a snowball from the player at speed 2.75
    13.                 set {autoGun::%player's uuid%} to 0.1 seconds from now
    14.             stop
    15.         shoot a snowball from the player at speed 2.75
    16.         set {autoGun::%player's uuid%} to 0.1 seconds from now
    17.  
    18. on damage:
    19.  if attacker is holding {autoGun}:
    20.   if attacker is a player:
    21.    if projectile is a snowball:
    22.     damage victim by 0.5 hearts
    23.     stop
    Skript Version: 2.2dev36

    Skript Addons: SkQuery, SkRayFall, Skellet, TuSKe, SkNBeeT, Sk-Perm, and SkDragon

    I hope someone can find a solution to this issue, thanks.

     
  2. Best Answer:
    Post #4 by Goose, Jan 12, 2020
  3. Goose

    Goose Well-Known Member

    Joined:
    Nov 23, 2019
    Messages:
    402
    Likes Received:
    28
    Can't you just add a delay to the end of skript? Like this
    Code (Text):
    1. command /gun:
    2.  permission: command.gun
    3.  permission message: no
    4.  trigger:
    5.   set {autoGun} to iron ingot named "&aAuto gun"
    6.   give {autoGun} to player
    7.  
    8. on rightclick:
    9.     if player is holding {autoGun}:
    10.         if {autoGun::%player's uuid%} is set:
    11.             if now > {autoGun::%player's uuid%}:
    12.                 shoot a snowball from the player at speed 2.75
    13.                 set {autoGun::%player's uuid%} to 0.1 seconds from now
    14.                 wait 1 second
    15.             stop
    16.         shoot a snowball from the player at speed 2.75
    17.         set {autoGun::%player's uuid%} to 0.1 seconds from now
    18.         wait 1 second
    19.  
    20. on damage:
    21.  if attacker is holding {autoGun}:
    22.   if attacker is a player:
    23.    if projectile is a snowball:
    24.     damage victim by 0.5 hearts
    25.     stop
    You can also decrease the speed of the snowball to make it slower and give the skript a bit of time to think
     
  4. IDuckz_

    IDuckz_ Active Member

    Joined:
    Jul 25, 2019
    Messages:
    102
    Likes Received:
    2
    Didn't work, still the same, and its not about skript, its about minecraft I think, the projectiles shoot fine but whenever it hits the mob, you have to wait for the mob to be damaged then it'll damage the mob again.
     
  5. Goose

    Goose Well-Known Member

    Joined:
    Nov 23, 2019
    Messages:
    402
    Likes Received:
    28
    So yeah, just add a delay that is long enough to give Minecraft enough time to damage the mob for each individual hit
     
    • Agree Agree x 1
  6. IDuckz_

    IDuckz_ Active Member

    Joined:
    Jul 25, 2019
    Messages:
    102
    Likes Received:
    2
    Uh how?

    Edit: Nevermind, I got it working, thanks for telling me about the delay part, it worked :emoji_slight_smile:
     
    #5 IDuckz_, Jan 13, 2020
    Last edited: Jan 13, 2020
  7. Goose

    Goose Well-Known Member

    Joined:
    Nov 23, 2019
    Messages:
    402
    Likes Received:
    28
    No problem. :emoji_slight_smile:
     
Thread Status:
Not open for further replies.
Loading...