Skript - robbery

Discussion in 'Bukkit Help' started by Giuliox_Sniper, Oct 9, 2023.

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

    Giuliox_Sniper

    Hello, today i skripting this script:


    on right click on entity:
    if entity's name is "&4&lRapinami":
    send "a" to player
    wait 1 second
    send "b" to player
    wait 1 second
    give 1 stick named "&f500€" with custom model data 118 to player


    How can i make a cooldown that only after 5 minutes the player can reuse the npc?
     
  2. Offline

    KarimAKL

    @Giuliox_Sniper You could keep track of the time from the last use, then compare it with the current time. I believe Skript allows you to store variables with a curly brackets syntax, so a variable for each player could be something like {stick.last_use.%uuid of player%}.
    Some pseudo-code would be:
    Code:
    if difference between current time and {stick.last_use.%uuid of player%} is greater than or equal to 5 minutes:
        # do your thing
        set {stick.last_use.%uuid of player%} to current time
    else:
        # do nothing
        stop
    The else-statement is unnecessary, but I added it for clarification.
     
Thread Status:
Not open for further replies.

Share This Page