#Script help

1 messages · Page 1 of 1 (latest)

empty wharf
#

Hi, I've been trying for about a week to program a script that will work in such a way that when the player uses a command, it will be used again after a random time (from 5 hours to 5 days). And when the time runs out, he can use the command again (something like a cooldown function), but so that the countdown is not interrupted by restarting or turning off and on the server, I tried it according to the player's played time... but it didn't work. Does anyone have any advice please? because I'm quite new to Script. well thank you

shut radish
#

is it the speciffy command or only 1 command every 5 hours to 5 days?

shy moth
# empty wharf Hi, I've been trying for about a week to program a script that will work in such...

I recommend using a YAML file or another data storage method. When you run the command, record the current Unix timestamp. Also, generate a random timestamp between 5 hours and 5 days from now. Then, each time you run the command, do the following:

  1. Check if the key exists in the YAML file.
  2. Verify if the current time falls between the start and end timestamps.

It's the easiest and most accurate way.

shut radish
#

just set difference between

shy moth
#

To find the difference between you need to valid refrence points.

empty wharf
#

Thank you for the advice, but it is very difficult for me, can it be done in a different way, please? easier

loud stream
#

So, you don't need file storage at all for this, just variables. And the cooldow can be specified directly in the command: command test: permission: some.perm.here cooldown: 5 hours cooldown storage: {cooldowns::test::%uuid of player%} trigger: your code here