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 Need Help For Simple Shooting Script

Discussion in 'Skript' started by RedDiamond, Dec 5, 2020.

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

    RedDiamond Member

    Joined:
    Nov 30, 2020
    Messages:
    16
    Likes Received:
    0
    Hei So i've made a script for shooting entity when holding an item and I wanna make it so player can't spam it, so like I want a cooldown/delay for every shoot, I hope someone understand lol
    This is my current script, I want to make a delay for every fireball shoot

    Code (Text):
    1. #Fireball Shooter
    2. on rightclick holding a blaze rod:
    3.   play sound "entity.blaze.shoot" with volume 1 to the player
    4.   make the player shoot a fireball at speed 4
    I hope someone could help me, I'm still new and learning about script, thx :emoji_slight_smile:
     
  2. Stefqnutz

    Stefqnutz Active Member

    Joined:
    Sep 23, 2019
    Messages:
    67
    Likes Received:
    1
    Well this is the first thing that comes in my mind so you could try this:
    Code (Text):
    1.  
    Code (Text):
    1.  
    2. on join:
    3.     set {Cooldown::%player%} to false
    4. #Fireball Shooter
    5. on rightclick holding a blaze rod:
    6.     if {Cooldown::%player%} is false:
    7.         play sound "entity.blaze.shoot" with volume 1 to the player
    8.         make the player shoot a fireball at speed 4
    9.         set {Cooldown::%player%} to true
    10. every 3 seconds:
    11.     loop all players:
    12.         if {Cooldown::%loop-player%} is true:
    13.             set {Cooldown::%loop-player%} to false
    14. on rightclick holding a blaze rod:
    15.     if {Cooldown::%player%} is true:
    16.         cancel event
    17.         send "&cYou are on cooldown!"
    18.  
    Haven't tested it but it should work.
     
  3. Nikd0

    Nikd0 Active Member

    Joined:
    May 30, 2020
    Messages:
    208
    Likes Received:
    21
    Please, don't use true/false, use true/not set instead. Means that if it's not true, you clear the variable. It's good for your server's performance.
     
  4. Turb032

    Turb032 Active Member

    Joined:
    Jan 16, 2020
    Messages:
    109
    Likes Received:
    0
    Code (Text):
    1. variables:
    2.     {Cooldown.%player%} = 0
    3.  
    4. on rightclick holding a blaze rod:
    5.     if {Cooldown.%player%} = 0:
    6.         set {Cooldown.%player%} to 1
    7.         play sound "entity.blaze.shoot" with volume 1 to the player
    8.         make the player shoot a fireball at speed 4
    9.         wait 3 seconds
    10.         set {Cooldown.%player%} to 0
    11.     elseif {Cooldown.%player%} = 1:
    12.         message "&cYou have to wait 3 seconds to shoot a fireball!" to player
    13.        
    14.  
    this should work (not tested)
     
  5. RedDiamond

    RedDiamond Member

    Joined:
    Nov 30, 2020
    Messages:
    16
    Likes Received:
    0
    This is work really good, thx for the help everyone!
     
Thread Status:
Not open for further replies.

Share This Page

Loading...