Cooldown

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

  • LOOKING FOR A VERSION OF SKRIPT?

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

AdenR84

Active Member
Sep 4, 2023
72
0
6
23
So i am doing a skript were you have a wool sword and you right click it summons a bed fro you to sleep in yea but i need a 35 second cooldown i have this:
on right click:
name of player's tool is "&f&lWool Sword &f&l✪"
if player's held item is arrow:
# Check if the cooldown variable is set to a time after the current time
if {cooldown::%player's uuid%::bed} is greater than now:
set block above event-location to air

# Calculate the remaining cooldown time
set {_waited} to difference between {cooldown::%player's uuid%::bed} and now
send "&cYou cant Do That You Need to wait %{_waited}%"

else:
# Set the cooldown to 10 seconds from the current time
set {cooldown::%player's uuid%::bed} to 45 seconds from now
name of player's tool is "&f&lWool Sword &f&l✪"
if player's held item is arrow:
if {mana.%player%} is greater than 34:
add -35 to {mana.%player%}
send "&4Used (Deep Sleep)! &b(-35 Mana)" to player
else:
send "&cYou don't have enough mana to do that!" to player
set block above event-location to air
set block above event-location to white bed
wait 10 seconds
message "&cYou Could not sleep in the bed in enough time it has parished."
set block above event-location to air
on right click on white bed:
heal player by 15 hearts
send "&cYou Are Well Rested. Healed 15 Hearts!" to player
set block at event-location to air
on right click:
name of player's tool is "&f&lCooldown Reset"
set {cooldown::%player's uuid%::bed} to 0 seconds from now it works butttttt it doesn't cancel the event i will be back in 24 to 36 hours to check replies ty!
 
So i am doing a skript were you have a wool sword and you right click it summons a bed fro you to sleep in yea but i need a 35 second cooldown i have this:
on right click:
name of player's tool is "&f&lWool Sword &f&l✪"
if player's held item is arrow:
# Check if the cooldown variable is set to a time after the current time
if {cooldown::%player's uuid%::bed} is greater than now:
set block above event-location to air

# Calculate the remaining cooldown time
set {_waited} to difference between {cooldown::%player's uuid%::bed} and now
send "&cYou cant Do That You Need to wait %{_waited}%"

else:
# Set the cooldown to 10 seconds from the current time
set {cooldown::%player's uuid%::bed} to 45 seconds from now
name of player's tool is "&f&lWool Sword &f&l✪"
if player's held item is arrow:
if {mana.%player%} is greater than 34:
add -35 to {mana.%player%}
send "&4Used (Deep Sleep)! &b(-35 Mana)" to player
else:
send "&cYou don't have enough mana to do that!" to player
set block above event-location to air
set block above event-location to white bed
wait 10 seconds
message "&cYou Could not sleep in the bed in enough time it has parished."
set block above event-location to air
on right click on white bed:
heal player by 15 hearts
send "&cYou Are Well Rested. Healed 15 Hearts!" to player
set block at event-location to air
on right click:
name of player's tool is "&f&lCooldown Reset"
set {cooldown::%player's uuid%::bed} to 0 seconds from now it works butttttt it doesn't cancel the event i will be back in 24 to 36 hours to check replies ty!
Hmmmmmmmm

Maybe do:

Code:
if {cooldown::%player's uuid%::bed} is true:
    send "You have to wait a bit longer to do this again!
else:
    # run code
    set {cooldown::%player's uuid%::bed} to true
    wait 45 seconds
    set {cooldown::%player's uuid%::bed} to false

There is no need to make it a number if you are not going to call any number or remaining time thing.

Edit: I realized you did call a remaining time, but this code is for you to play around with.
 
Last edited:
Here is how you can do a proper cooldown using variables
Code:
on right click:
    name of player's tool is "&f&lWool Sword &f&l✪"
    if player's held item is not arrow:
        stop
     # Check if the cooldown variable is set to a time after the current time
    if {cooldown::%player's uuid%::bed} is greater than now:
          # Cancel the event since the cooldown is not yet over
        cancel event

          # Calculate the remaining cooldown time
        set {_waited} to difference between {cooldown::%player's uuid%::bed} and now
        send "Try again in %{_waited}%"

    else:
          # Set the cooldown to 10 seconds from the current time
        set {cooldown::%player's uuid%::bed} to 10 seconds from now

        # under here you put the what you want your code to do after the cooldown is over
 
Last edited:
  • Like
Reactions: Doodle