Having problems with my cooldown script.

Discussion in 'Skript' started by SprutarN, Apr 9, 2021.

  1. It works for me since i have been playing around with the code and testing it myself so i have recived the key so that the timer has started and when i think i have fixed it i let a friend try it out and they just get sent: "&cYou have to wait &a%difference between 24 hours and {_waited}% &cbefore you can use this command again!" and the time being always <none>. This is the code:

    command /key day:
    description: Give the player a daily key.
    usage: /key day
    permission: key.day
    permission message: &cYou do not have permission to execute this command.
    executable by: player

    trigger:
    set {_waited} to difference between {key.%player%.lastused} and now
    if {_waited} is less than 24 hours:
    message "&cYou have to wait &a%difference between 24 hours and {_waited}% &cbefore you can use this command again!"
    stop
    if {_waited} is more than 24 hours:
    execute console command "crate givekey %player% day 1"
    set {key.%player%.lastused} to now
    stop

    #added this after because when i tested it out , and the "{_waited}" time says "none" instead of the time and it doesn't start or reset the timer nor does it execute the console command.

    if {_waited} is none:
    execute console command "crate givekey %player% donator 1"
    set {key.%player%.lastused} to now
    stop
     
  2. are you sure the lastused variable is set? additionally, you should follow the correct variable format: {key::%uuid of player%::lastused} instead of {key.%player%.lastused}
     
  3. Changed it so that the code now looks like this:

    command /key day:
    description: Give the player a daily key.
    usage: /key day
    permission: key.day
    permission message: &cYou do not have permission to execute this command.
    executable by: player

    trigger:
    set {_waited} to difference between {key::%uuid of player%::lastused} and now
    if {_waited} is less than 24 hours:
    message "&cYou have to wait &a%difference between 24 hours and {_waited}% &cbefore you can use this command again!"
    stop
    if {_waited} is more than 24 hours:
    execute console command "crate givekey %player% day 1"
    set {key::%uuid of player%::lastused} to now
    stop

    #added this after because when i tested it out , and the "{_waited}" time says "none" instead of the time and it doesn't start or reset the timer nor does it execute the console command.

    if {_waited} is none:
    execute console command "crate givekey %player% donator 1"
    set {key::%uuid of player%::lastused} to now
    stop


    This is what it now shows: https://gyazo.com/03457d36b27b4e3b3a8609b445d0a2ff same as before but for me too.
    This is what it showed me when i had {key.%player%.lastused} : https://gyazo.com/14aa2f2648b74c5431f0154ca601b68f

    And these are the variables i belive:
    key::a39c3d89-3e15-415b-960a-2ad66270c259, timespan, 81066D696C6C6973040000000000019C0F
    key.sprutarn.lastused, date, 810974696D657374616D700400000178B3D5A850
     
  4. you need to account for unset variables
     
  5. How?
    And in the code?
    Tried around but couldn't get a grip of how to.
     
  6. if ... is not set:
    #do something
    else:
    ...
     

  7. if {_waited}/{key.%player%.lastused}/{key::%uuid of player%::lastused} is not set:
    execute console command "crate givekey %player% day 1"
    set {key.%player%.lastused}/{key::%uuid of player%::lastused} to now
    stop

    Doesn't work, adding else or else if instead of having if,if,if doesn't work either the script says there's errors.
     
  8. could you send the full script? also that's not correct syntax: if {_waited}/{key.%player%.lastused}/{key::%uuid of player%::lastused}


    and you shouldn't be checking if {_waited} is not set, because it will always be not set
     

  9. command /key day:
    description: Give the player a dayily key.
    usage: /key da
    permission: key.day
    permission message: &cYou do not have permission to execute this command.
    executable by: player

    trigger:
    set {_waited} to difference between {key::%uuid of player%::lastused} and now
    if {_waited} is less than 24 hours:
    message "&cYou have to wait &a%difference between 24 hours and {_waited}% &cbefore you can use this command again!"
    stop
    if {_waited} is more than 24 hours:
    execute console command "crate givekey %player% day 1"
    set {key::%uuid of player%::lastused} to now
    stop
    if {key::%uuid of player%::lastused} is not set:
    execute console command "crate givekey %player% day 1"
    set {key::%uuid of player%::lastused} to now
    stop

    i didn't use tha syntax i tried using the different once, and just wrote / / / to clarify that i had used and tried all of them and it made no diffrenece. Im using the plugin script. https://dev.bukkit.org/projects/skript
     
  10. the link is very outdated, you should use a newer version of Skript

    I do not know why it does not work for you, it sounds like you did it right
     
  11. Yeah the link is outdated but i have the newest verison.
    Here's the link i donwloaded it from. https://github.com/SkriptLang/Skript/releases
    Being the .jar file, version 2.5.3.
     
  12. could you send your code properly formatted in code tags?
    Code (Text):
    [code]
    [/code]
     
  13. Code (Text):

    command /key day:
    description: Give the player a dayily key.
    usage: /key day
    permission: key.day
    permission message: &cYou do not have permission to execute this command.
    executable by: player

    trigger:
    set {_waited} to difference between {key::%uuid of player%::lastused} and now
    if {_waited} is less than 24 hours:
    message "&cYou have to wait &a%difference between 24 hours and {_waited}% &cbefore you can use this command again!"
    stop
    if {_waited} is more than 24 hours:
    execute console command "crate givekey %player% day 1"
    set {key::%uuid of player%::lastused} to now
    stop
    if {key::%uuid of player%::lastused} is not set:
    execute console command "crate givekey %player% day 1"
    set {key::%uuid of player%::lastused} to now
    stop
     
     
  14. Found anything?
     
  15. sorry I didn't see it, well your trigger: is with same tabs count as code..? you sure it is correctly formatted?
     
  16. I checked and it's not in the same tabs count as the code under the trigger. It just got sent wrong. I belive it is, iv'e check multiple videos and other things to try to make it work but nothing works.
     
  17. well it doesn't look like you're accounting for unset variables still
     
  18. Wouldn't this be it?
    Code (Text):

    if {key::%uuid of player%::lastused} is not set:
    execute console command "crate givekey %player% day 1"
    set {key::%uuid of player%::lastused} to now
    stop
     
    Plus if not idk how to :/
     
  19. yes that it is

    but you're checking waited on top, this should be first
     
  20. Im lost, what do you mean?