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
#Script help
1 messages · Page 1 of 1 (latest)
is it the speciffy command or only 1 command every 5 hours to 5 days?
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:
- Check if the key exists in the YAML file.
- Verify if the current time falls between the start and end timestamps.
It's the easiest and most accurate way.
just set difference between
If the server is restart that value will be wiped unless you store it (Also what I explained is literally what that is)
To find the difference between you need to valid refrence points.
Thank you for the advice, but it is very difficult for me, can it be done in a different way, please? easier
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