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 Cooldown Help

Discussion in 'Skript' started by SMH, Sep 19, 2021.

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

    SMH New Member

    Joined:
    Sep 19, 2021
    Messages:
    5
    Likes Received:
    0
    I have a throwable tnt skript but i wanted to make that have a cooldown so i merged my another skript that had a cooldown with this skript but i couldn't get it to work, any help ?


    Code (Text):
    1. on leftclick holding tnt:
    2.   if name of event-item is "&1&lDinamit":
    3.     set {_waited} to difference between {cooldown::%player%::epearl} and now
    4.     if {_waited} is less than 45 seconds:
    5.     send "&d&lTekrar &c&lDinamit &d&latman için &a&l%difference between 45 seconds and {_waited}% &d&lbeklemelisin!" to player
    6.     cancel the event
    7.          else:
    8.             player has 1 tnt
    9.         set {cooldown::%player%::epearl} to now
    10.             spawn a primed tnt 1 meter above the player
    11.             push the spawned entity in direction of player at speed 0.9
    12.             push the spawned entity upwards at speed 0.2
    13.             remove 1 tnt from player
     
    #1 SMH, Sep 19, 2021
    Last edited: Sep 19, 2021
  2. Eszi

    Eszi New Member

    Joined:
    Sep 19, 2021
    Messages:
    5
    Likes Received:
    0
    I'm looking into this code too much, but the simple problem could be that the variable "{cooldown::%player%::epearl}" is not set, so it can't really be a difference of anything, thus "{_waited}" is not set.
     
  3. TheCubPlays

    TheCubPlays Member

    Joined:
    Jun 22, 2021
    Messages:
    35
    Likes Received:
    3
    You should try this:

    Code (Text):
    1. on leftclick:
    2.   if player's held item is tnt named "&1&lDinamit":
    3.     if {cooldown::%player%::epearl} is set:
    4.        set {_waited} to difference between {cooldown::%player%::epearl} and now
    5.     else:
    6.        set {_waited} to 46 seconds
    7.     if {_waited} is less than 45 seconds:
    8.        send "&d&lTekrar &c&lDinamit &d&latman için &a&l%difference between 45 seconds and {_waited}% &d&lbeklemelisin!" to player
    9.        cancel the event
    10.     else:
    11.        player has 1 tnt
    12.        set {cooldown::%player%::epearl} to now
    13.        spawn a primed tnt 1 meter above the player
    14.        push the spawned entity in direction of player at speed 0.9
    15.        push the spawned entity upwards at speed 0.2
    16.        remove 1 tnt from playe
    I didn't test it but I don't see why it wouldn't work.
    Also you should probably use "player's uuid" instead of "player", you could try to find out more about that one. All I know is that if someone changes their name their stats will reset if you didn't use their uuid.
     
  4. SMH

    SMH New Member

    Joined:
    Sep 19, 2021
    Messages:
    5
    Likes Received:
    0
    hmmm didn't work, it says nothing when you left click where as before with the original code, it would only say the cooldown error message with none as the timer
     
  5. TheCubPlays

    TheCubPlays Member

    Joined:
    Jun 22, 2021
    Messages:
    35
    Likes Received:
    3
    Weird, try the one you did originally but replace
    Code (Text):
    1.     set {_waited} to difference between {cooldown::%player%::epearl} and now
    with
    Code (Text):
    1.     if {cooldown::%player%::epearl} is set:
    2.        set {_waited} to difference between {cooldown::%player%::epearl} and now
    3.     else:
    4.        set {_waited} to 46 seconds
     
  6. SMH

    SMH New Member

    Joined:
    Sep 19, 2021
    Messages:
    5
    Likes Received:
    0
    Now, it always gives the cooldown message with 0 seconds as the timer and, the time doesnt pass its stuck there, still good progress

    this is what i went with

    Code (Text):
    1. on leftclick holding tnt:
    2.   if name of event-item is "&1&lDinamit":
    3.         if {cooldown::%player%::epearl} is set:
    4.        set {_waited} to difference between {cooldown::%player%::epearl} and now
    5.     else:
    6.     set {_waited} to 46 seconds
    7.     if {_waited} is less than 45 seconds:
    8.     send "&d&lTekrar &c&lDinamit &d&latman için &a&l%difference between 46 seconds and {_waited}% &d&lbeklemelisin!" to player
    9.     cancel the event
    10.          if else:
    11.             player has 1 tnt
    12.             set {cooldown::%player%::epearl} to now
    13.             spawn a primed tnt 1 meter above the player
    14.             push the spawned entity in direction of player at speed 0.9
    15.             push the spawned entity upwards at speed 0.2
    16.             remove 1 tnt from player
     
  7. TheCubPlays

    TheCubPlays Member

    Joined:
    Jun 22, 2021
    Messages:
    35
    Likes Received:
    3
    I see why this happends, {_waited} gets set to 46 seconds and then you get the difference between 46 and {_waited} which is 0 since 46 = 46.
    Since it's 46 seconds which is not less than 45 seconds it shouldn't send this message though so I can only assume that you forgot to use spaces after the "if" line? Can you send the code with the exact spaces/tabs you used in the code? Because if this is how it actually looks like you need to change it to this:

    Code (Text):
    1. on leftclick holding tnt:
    2.   if name of event-item is "&1&lDinamit":
    3.     if {cooldown::%player%::epearl} is set:
    4.        set {_waited} to difference between {cooldown::%player%::epearl} and now
    5.     else:
    6.        set {_waited} to 46 seconds
    7.     if {_waited} is less than 45 seconds:
    8.        send "&d&lTekrar &c&lDinamit &d&latman için &a&l%difference between 46 seconds and {_waited}% &d&lbeklemelisin!" to player
    9.     cancel the event
    10.     player has 1 tnt
    11.     set {cooldown::%player%::epearl} to now
    12.     spawn a primed tnt 1 meter above the player
    13.     push the spawned entity in direction of player at speed 0.9
    14.     push the spawned entity upwards at speed 0.2
    15.     remove 1 tnt from player
     
  8. SMH

    SMH New Member

    Joined:
    Sep 19, 2021
    Messages:
    5
    Likes Received:
    0
    Tried with the latest one you posted, still didn't work like i want, let me clarify again, this is a throwing tnt skript where you can throw a tnt with left click but i want the tnt to be able to thrown every 45 seconds, the latest ones results are i can throw the tnt but simply there is no cooldown and i can throw infinitely
     
  9. TheCubPlays

    TheCubPlays Member

    Joined:
    Jun 22, 2021
    Messages:
    35
    Likes Received:
    3
    If the issue is that the tnt gets thrown infinitely but the cooldown message does work it's once again because of spaces/tabs, at the momment even when it does send the message it still throws the tnt because it doesn't depend on any of the if/else statements, try changing it to this:

    Code (Text):
    1. on leftclick holding tnt:
    2.   if name of event-item is "&1&lDinamit":
    3.     if {cooldown::%player%::epearl} is set:
    4.        set {_waited} to difference between {cooldown::%player%::epearl} and now
    5.     else:
    6.        set {_waited} to 46 seconds
    7.     if {_waited} is less than 45 seconds:
    8.        send "&d&lTekrar &c&lDinamit &d&latman için &a&l%difference between 46 seconds and {_waited}% &d&lbeklemelisin!" to player
    9.     else:
    10.        cancel the event
    11.        player has 1 tnt
    12.        set {cooldown::%player%::epearl} to now
    13.        spawn a primed tnt 1 meter above the player
    14.        push the spawned entity in direction of player at speed 0.9
    15.        push the spawned entity upwards at speed 0.2
    16.        remove 1 tnt from player
     
  10. SMH

    SMH New Member

    Joined:
    Sep 19, 2021
    Messages:
    5
    Likes Received:
    0
    ah, finally, edited this around and it finally works, thanks :emoji_smile:
     
Thread Status:
Not open for further replies.

Share This Page

Loading...