I want to system daily bonus
code_language.skript:
on join:
if first join of day:
send "you get reward"
Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.
If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!
Now, what are you waiting for? Join the community now!
You can always check out skUnity Downloads for downloads and any other information about Skript!
on join:
if first join of day:
send "you get reward"
on join:
if {TIme::%player%} is not set:
set {Time::%player%} to true
send "You got rewards of daily"
on script load: #IF YOU NEVER Reload the Script. Would it reset evertime at your Server restart (0PM?)
delete {Time::*}
... >_< Documentions can help you...
code_language.skript:on join: if {TIme::%player%} is not set: set {Time::%player%} to true send "You got rewards of daily" on script load: #IF YOU NEVER Reload the Script. Would it reset evertime at your Server restart (0PM?) delete {Time::*}
Else you need check time difference more than 24 hours
on join:
# if not set, set variable to yesterday
if {dailyBonus::%player%} is not set:
set {dailyBonus::%player%} to now
subtract 1 day from {dailyBonus::%player%}
# if it's been a day or more since the last reward was given
if (difference between {dailyBonus::%player%} and now) >= 24 hours:
# make sure to update variable
set {dailyBonus::%player%} to now
# then, we can do stuff
send "You've earned your Daily Bonus!"
on join:
# if not set, set variable to yesterday
if {dailyBonus::%player%} is not set:
set {dailyBonus::%player%} to now
subtract 1 day from {dailyBonus::%player%}
# if the day between now and the variable are different
if (day of year from date now) is not (day of year from date {dailyBonus::%player%}):
# make sure to update variable
set {dailyBonus::%player%} to now
# then, we can do stuff
send "You've earned your Daily Bonus!"
It seems kind of odd to do it like that. I don't see a reason not to just check the time difference. Your code requires the server/script to restart/reload every 24 hours; at least it seems like it- or else {Time::*} would never get cleared.
My code should be works. Ever server most restart evertime at 0 pm, because of laggs reduce or some things, So its called every day will the varaibles reset. Why will it never get cleared? Of course.
With your code i can just tell. BRUH! A lot variables. Example i joined 1x on the server. and never joined. there is a useless variables there. and somewhen will it bigger and bigger and bigger...
every 24 hours:
loop {dailyBonus::*}:
if (difference between loop-value and now) >= 24 hours:
delete {dailyBonus::%loop-index%}
... >_< Documentions can help you...
code_language.skript:on join: if {TIme::%player%} is not set: set {Time::%player%} to true send "You got rewards of daily" on script load: #IF YOU NEVER Reload the Script. Would it reset evertime at your Server restart (0PM?) delete {Time::*}
Else you need check time difference more than 24 hours
Good, make as solved by pressed best answer under message box
If you're trying to cut down on variables theres much better ways to do it... >_< Documentions can help you...
code_language.skript:on join: if {TIme::%player%} is not set: set {Time::%player%} to true send "You got rewards of daily" on script load: #IF YOU NEVER Reload the Script. Would it reset evertime at your Server restart (0PM?) delete {Time::*}
Else you need check time difference more than 24 hours