Solved Anyone know how to put a cooldown every time you click (LMB)

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

Status
Not open for further replies.

JadeInnit1

Member
Oct 3, 2022
14
0
1
Hello, Ultra beginner noob here. I was just testing out skript the past day and wanted to make an explosion happen in front of the player (already done that) And to stop people from spamming it I want a 1-second delay between each press of the LMB. This is prob simple and my tiny brain can't handle it so I thought I'd ask you, smart people.

Code so far is.

Skript version: 2.6.2.
Skript author: Quiettee (me)
on leftclick holding wooden shovel:
cooldown:1
create an explosion of force 1 10 block infront of player

Any and all help would be much appreciated :emoji_slight_smile:
 
Hello, Ultra beginner noob here. I was just testing out skript the past day and wanted to make an explosion happen in front of the player (already done that) And to stop people from spamming it I want a 1-second delay between each press of the LMB. This is prob simple and my tiny brain can't handle it so I thought I'd ask you, smart people.

Code so far is.

Skript version: 2.6.2.
Skript author: Quiettee (me)
on leftclick holding wooden shovel:
cooldown:1
create an explosion of force 1 10 block infront of player

Any and all help would be much appreciated :emoji_slight_smile:
Code:
on leftclick holding wooden shovel:
  if {-p::%uuid of player%::cooldown} is not set:
    set {-p::%uuid of player%::cooldown} to true
    create an explosion of force 1 10 block infront of player
    wait ? ticks
    delete {-p::%uuid of player%::cooldown}


Code:
on leftclick holding wooden shovel:
  if unix timestamp of now is greater than 0+{-p::%uuid of player%::cooldown}:
    set {-p::%uuid of player%::cooldown} to unix timestamp of now+%cooldown?%
    create an explosion of force 1 10 block infront of player
 
  • Like
Reactions: JadeInnit1
Code:
on leftclick holding wooden shovel:
  if {-p::%uuid of player%::cooldown} is not set:
    set {-p::%uuid of player%::cooldown} to true
    create an explosion of force 1 10 block infront of player
    wait ? ticks
    delete {-p::%uuid of player%::cooldown}
[/CODE]

Mind If I ask what the line "if {-p::%uuid of player%::cooldown} is not set:" and "set {-p::%uuid of player%::cooldown} to true" does
 
Mind If I ask what the line "if {-p::%uuid of player%::cooldown} is not set:" and "set {-p::%uuid of player%::cooldown} to true" does
well we set some variable so we can keep track of the delay. In fact, if the variable is set, then the user still has a delay, if not set, then he can already use the item
I apologize if something is not quite correctly described, I do not know English perfectly
[doublepost=1664913056,1664912805][/doublepost]
Mind If I ask what the line "if {-p::%uuid of player%::cooldown} is not set:" and "set {-p::%uuid of player%::cooldown} to true" does
As for the variable itself, usually the '-' symbol is put in the 'Skript' config so that variables with this prefix are not saved on disk, only in RAM. That is, after a server restart, all player delays will not be saved
Value in Skript's config
Code:
    default:
      
        type: CSV
      
        pattern: (?!-).* # <== here
      
        file: ./plugins/Skript/variables.csv
      
        backup interval: 0 hours
[doublepost=1664913209][/doublepost]
Mind If I ask what the line "if {-p::%uuid of player%::cooldown} is not set:" and "set {-p::%uuid of player%::cooldown} to true" does
but I still prefer to use the second variant of code than the first one you mentioned
Just do not forget when the player exits to free memory from this:
Code:
on disconnect:
  delete {-p::%uuid of player%::*}
 
  • Like
Reactions: JadeInnit1
well we set some variable so we can keep track of the delay. In fact, if the variable is set, then the user still has a delay, if not set, then he can already use the item
I apologize if something is not quite correctly described, I do not know English perfectly
[doublepost=1664913056,1664912805][/doublepost]
As for the variable itself, usually the '-' symbol is put in the 'Skript' config so that variables with this prefix are not saved on disk, only in RAM. That is, after a server restart, all player delays will not be saved
Value in Skript's config
Code:
    default:
     
        type: CSV
     
        pattern: (?!-).* # <== here
     
        file: ./plugins/Skript/variables.csv
     
        backup interval: 0 hours
[doublepost=1664913209][/doublepost]
but I still prefer to use the second variant of code than the first one you mentioned
Just do not forget when the player exits to free memory from this:
Code:
on disconnect:
  delete {-p::%uuid of player%::*}
I see thank you for the explanation! Helped a lot
 
Status
Not open for further replies.