Jump to content

Having trouble making a cooldown.


Ninjabuilderpro

Recommended Posts

I have a script that makes a Lightning Wand that summons lightning when you right click. I want to add a 4 second cooldown so you can't just spam lightning. Im using 1.16.5 and heres the script.

 

command /lightningwand <player>:
    aliases: lw
    usage: &7[&6LW&7] &cWho do you want to give the wand?
    permission: lw.give
    trigger:
        if arg-1 is set:
            give player 1 stick named "&f&lLightning Wand" with lore "&7Summons lightning where you looking at"
        else:
            stop
             
on rightclick: #you can also change it to leftclick
    if player's tool is stick named "&f&lLightning Wand" with lore "&7Summons lightning where you looking at":
        strike lightning at the targeted block
    else:
        stop

Link to comment
Share on other sites

on rightclick: #you can also change it to leftclick
    if player's tool is stick named "&f&lLightning Wand" with lore "&7Summons lightning where you looking at":
    	if {wandCooldown::%player%} > 0:
        	send "This is on cooldown!"
            stop
        set {wandCooldown::%player%} to 10 # The amount of time in seconds the cooldown is.
        strike lightning at the targeted block
        loop 10 times: # The amount of time in seconds the cooldown is.
        	wait 1 second
            remove 1 from {wandCooldown::%player%}
    else:
        stop 

 

Edited by _omga

If I helped you at all, leave a like!

IGN: _omga
Discord: omega#1000

 

Link to comment
Share on other sites

Here is a cool function you can use to manage cooldowns easily. There also are examples in it so you can look at to see how to use it.

https://pastebin.com/raw/UTtFBK76

Discord - tarna256

In-game name - _Tarna_

Website - https://tarna.dev
Paste Site: https://paste.tarna.dev

---------------------------------------------------------

[VIP] - 7/27/2020

Community Support - 7/8/20 | 11/3/20

Helper  - 11/3/20 - 2/21/21

Moderator - 2/21/21 - 5/17/21

❤️ - 5/17/21 - now

Moderator - 12/20/22 - now

---------------------------------------------------------

image.png.70849a9b84e0347ce107b8e3eaee312c.pngimage.png.2111009afbd8bef10966ba9ede35a199.png

Link to comment
Share on other sites

Im not sure if i'm using it wrong but I still can't get a working cooldown with the function. Here is what I've got

 

on rightclick: #you can also change it to leftclick
    if player's tool is stick named "&f&lLightning Wand" with lore "&7Summons lightning where you looking at":
        cooldownManager(player, "Lightning Wand", 10 seconds) isn't set
        strike lightning at the targeted block
    else:
        stop

Link to comment
Share on other sites

On 3/9/2021 at 5:16 AM, Ninjabuilderpro said:

Im not sure if i'm using it wrong but I still can't get a working cooldown with the function. Here is what I've got

 

on rightclick: #you can also change it to leftclick
    if player's tool is stick named "&f&lLightning Wand" with lore "&7Summons lightning where you looking at":
        cooldownManager(player, "Lightning Wand", 10 seconds) isn't set
        strike lightning at the targeted block
    else:
        stop

Try debug it; does the cooldownManager line actually trigger? add a broadcast just before it to check if it triggers when you rightclick the item. Then test the cooldownManager with other commands to see if it's working or not. Essentially, you're trying to figure out what's not working to fix it.

First Joined: July 2015
VIP: January 2020
Jr.Mod: 1st April 2020
Mod: 16th July 2020

Info:

~ Skript Developer
~ Discord: @nicholxs#0001
~ Previous names: Nichxlxs, Deterno, iHaveSkills, Retrical

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...