Solved Having problems making a cooldown for my custom item

  • 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 community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Cynacol

New Member
Jul 14, 2022
6
0
1
I'm trying to make a cooldown for my custom item's ability and I have tried multiple methods and it has not worked. I want a cooldown that makes you not able to use the ability for 15 seconds, and when you try to use it within that time, it creates an action bar only the user can see and it states that they cannot use the item due to the cooldown. Here is the current code, also let me know if there are any addons I will have to add in order for it to work.

Code:
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:
            set {_weapon} to unbreakable iron axe of sharpness 30
            give {_weapon} named "&f&lStormbreaker" with lore "&7You are now Thor. This axe has high sharpness and can strike lightning." and "&4&lBEWARE: LIGHTNING STRIKES WILL REMOVE DROPPED ITEMS" and "&5&lMythic" to player
        else:
            stop
       
on rightclick:
    if player's tool is unbreakable iron axe named "&f&lStormbreaker" with lore "&7You are now Thor. This axe has high sharpness and can strike lightning." and "&4&lBEWARE: LIGHTNING STRIKES WILL REMOVE DROPPED ITEMS" and "&5&lMythic":
        strike lightning at the targeted block
    else:
        stop
 
Last edited:
Hey there again!

Here's how I've made cooldown on my server for a wand

Code:
on rightclick with stick:
    if event-item's name contains "&6Nuclear Wand":
        cancel event
        if {beam.lastused.%player's uuid%} is not set:
            set {beam.lastused.%player's uuid%} to 1
        if {beam.lastused.%player's uuid%} = 1:
            set {beam.lastused.%player's uuid%} to 0
            wait 0.7 second #Cooldown time
            add 1 to {beam.lastused.%player's uuid%}

for the action bar

Code:
if {beam.lastused.%player's uuid%} = 0:
    send action bar "Lightning wand in cooldown!" to player

If you want to show the cooldown left, you will have to instead of the cooldown skript above to use something like

Code:
set {_cooldown} to 1 #COOLDOWN
if {beam.lastused.%player's uuid%} is not set:
    set {beam.lastused.%player's uuid%} to 1#Put it the same as cooldown for the first time
if {beam.lastused.%player's uuid%} = {_cooldown}:
        #proc lightning here
        set {beam.lastused.%player's uuid%} to 0
        loop {_cooldown} times:
            wait 1 second #Cooldown time
            add 1 to {beam.lastused.%player's uuid%}

then you can do something like that for the action bar

Code:
if {beam.lastused.%player's uuid%} != {_cooldown}:
    send action bar "Lightning wand in cooldown! %{_cooldown}-{beam.lastused.%player's uuid%}% seconds left!" to player

edit:Just realized you dont need non temp variable for cooldown, changed
 
Last edited:
Status
Not open for further replies.