Nicholas Posted August 17, 2010 Posted August 17, 2010 hi, im wondering can anyone help me out little please? im trying to do modification where if your offline for certain amount of days for example 1 week you will lose you job. if its already been made can you give me the link please to it or tell me how to make it? ill be very greatful, thanks Nicholas. i do know a way to do it but i was wondering if there is a quick way to do it as i can add daysoffline to the users table ALTER TABLE users ADD daysoffline INT(11) NOT NULL DEFAULT 0; and add this in cron day $db->query("UPDATE users SET daysoffline=daysoffline+1"); $db->query("UPDATE users SET jobrank=0, daysoffline=0 WHERE daysoffline=7"); and that add this to authication.php file $db->query("UPDATE users SET daysoffline=0 WHERE userid=$userid"); but im wondering if there is a easier way? Quote
rulerofzu Posted August 17, 2010 Posted August 17, 2010 You dont really need to add another field to the users table. Check the laston field for the user which has the time they was last on the game. select userid,laston from users where laston <= unix_timestamp()-60*60*168 that will give you the results you need then update the users table making them lose their job. This could go in your day cron. Quote
Nicholas Posted August 17, 2010 Author Posted August 17, 2010 yeh i know i dont have to add anything into users tables, thats why i need help i can figure out the formula for the unix_timestamp thing where the 60*60*168 bit is if you understand where im coming at lol. it help alot if someone could post up what to copy and paste into the cron file. Quote
rulerofzu Posted August 17, 2010 Posted August 17, 2010 That is the formula 168 = 7 days. Simple quicky n dirty way. $query=mysql_query('select userid,laston from users where laston <= unix_timestamp()-60*60*168'); while($results=mysql_fetch_array($query)){ mysql_query('update users set job=0,jobrank=0 where userid='.$results['userid'].'');event_add($results['userid'], "You lost your job for not turning up for 7 days you lazy ass!"); } Would do what you need and also send them an event so they know why just in case they do login and go wtf?!? You could always give them vacation days depending on the job they have. Higher the job the more days. So if the player knows they will not be online for 7 days then they can also set their player on vacation so they dont get sacked :D Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.