Hello, I'm having difficulty creating a script for my minecraft server. I want a script that gives players a reward every 24 hours if they log on that day. So basically a daily reward for anyone that logs in that day and it has a 24 hour cooldown after they've received the reward.
This is the code I made with help of chatgpt:
However, when I reload this skript, I get multiple errors in my console:
It seems to be having difficulty with the substraction of now - 24 hours. I don't understand how mathematical operations work within skript. I'm new to coding using skript and I have difficulty finding documentation of these kinds of things. If someone can direct me to good documentation for basic operations like this one I would be very gratefull!
This is the code I made with help of chatgpt:
Code:
on first join:
set {lastreward.%uuid of player%} to now - 24 hours
on join:
if {lastreward.%uuid of player%} is not set:
set {lastreward.%uuid of player%} to now - 24 hours
every minute:
loop all players:
if difference between now and {lastreward.%uuid of player%} is greater than 24 hours:
set {lastreward.%uuid of player%} to now
execute console command "addbalance %player% Shards 1"
send "&a&lThank you for playing United Factions today! 1 Shard has been added to your balance" to p
else:
set {_timeLeft} to 24 hours - (difference between now and {lastreward.%uuid of player%})
send "&eYou need to wait %{_timeLeft}% more hours to reclaim your next daily reward" to p
However, when I reload this skript, I get multiple errors in my console:
Code:
[17:12:48 INFO]: Line 2: (dailyreward.sk)
[17:12:48 INFO]: Can't understand this expression: 'now - 24 hours'
[17:12:48 INFO]: Line: set {lastreward.%uuid of player%} to now - 24 hours
[17:12:48 INFO]:
[17:12:48 INFO]: Line 6: (dailyreward.sk)
[17:12:48 INFO]: Can't understand this expression: 'now - 24 hours'
[17:12:48 INFO]: Line: set {lastreward.%uuid of player%} to now - 24 hours
[17:12:48 INFO]:
[17:12:48 INFO]: Line 11: (dailyreward.sk)
[17:12:48 INFO]: There's no player in a periodical event
[17:12:48 INFO]: Line: if difference between now and {lastreward.%uuid of player%} is greater than 24 hours:
[17:12:48 INFO]:
[17:12:48 INFO]: Line 15: (dailyreward.sk)
[17:12:48 INFO]: 'else' has to be placed just after another 'if' or 'else if' section
[17:12:48 INFO]: Line: else:
[17:12:48 INFO]:
[17:12:48 INFO]: [Skript] Encountered 5 errors while reloading the config, aliases and all scripts! (4293ms)
It seems to be having difficulty with the substraction of now - 24 hours. I don't understand how mathematical operations work within skript. I'm new to coding using skript and I have difficulty finding documentation of these kinds of things. If someone can direct me to good documentation for basic operations like this one I would be very gratefull!