var
EXP_CHARACTER_REWARD_LIMIT = 1000 // variable that sets how many characters someone has to type before being rewarded, adjust as needed.
DAILY_EXP_CAP = 3 // variable that sets how much exp a player can earn from dailies in a day, adjust as needed.
mob/var
last_exp_gain_time = 0 //the last time the user's experience gain was reset so they could gain exp again
dailyExpGained = 0 //total number of exp (out of 5) that the user has gained so far
characterTotal = 0 //total number of characters user has typed to gain reward
mob/proc/characterCheck(msg)
var/chars = length(msg) //this assigns a variable with the number of characters in the message/roleplay
src.characterTotal += chars //add the length of the message to the total number of characters the user has typed already
if(src.characterTotal >= EXP_CHARACTER_REWARD_LIMIT) //if the user has written enough to warrant a reward
src.award_daily_exp() //reward them
src.characterTotal = 0 //and reset their progress to the next exp point to 0
mob/proc/award_daily_exp()
if (world.time > src.last_exp_gain_time + (24 * 3600)) // Check if 24 hours have passed
//RESET VARIABLES HERE
src.dailyExpGained = 1 //reset their exp gained to 1, since we'll be rewarding them a point right now
src.exptunarank += 1 //give htem one more experience point
src.last_exp_gain_time = world.time //set the last rewarded time to now
src <<"You have earned 1 EXP for your activity! Total EXP: [usr.exptunarank]"
else //if 24 hours hasn't passed
if(src.dailyExpGained >= DAILY_EXP_CAP)
src << "You have already earned the maximum EXP within your 24-hour time period"
return //if the user has already earned the max amount of exp, leave.
src.dailyExpGained++ // increase the number of daily exp points gained by one
src.exptunarank++ //and reward 1 experience
src << "You have earned 1 EXP for your activity! Total EXP: [usr.exptunarank]"
return
Problem description:
Players are hitting their daily cap of 3, however even after a supposed 24 hours has passed they are still being met with the msg that they have hit their daily limit. How do I remedy this?
world.realtime is the value you want to use to get the server's clock datetime. This is a value that is relative to Jan 1, 2000 in 1/10th seconds. Note that there will be a little bit of inaccuracy in this time.