Kieran-R Posted December 27, 2010 Posted December 27, 2010 Hey. Ive set up timestamps on my game, but ive come accross a small problem which im not to sure now to fix. WHen a user loads the page, and noone has loaded the page in ages, it wil only update once. Whereas it should be updating however many times the update has ben missed. For example, I have a 5 minutes timestamp. No one loads the page for 30 minutes. then someone does load the page, it only updates once instead of updating 6 times. He is my code for 5 minutes: // 5 MINUTE TIME STAMPS!!!!!! $updates_sql = $db->query("SELECT * FROM `updates` WHERE `name` = 'fivemin'"); while ($line = mysql_fetch_array($updates_sql)) { $update = $line['lastdone']; } $timesinceupdate = time() - $update; if ($timesinceupdate>=300) { $num_updates = floor($timesinceupdate / 300); *** MYSQL QUERY'S HERE $thetime = time(); $result2 = $db->query("UPDATE `updates` SET `lastdone` = '".$thetime."' WHERE `name` = 'fivemin'"); $leftovertime = $timesinceupdate - (floor($timesinceupdate / 300) * 300); if ($leftovertime>0) { $newupdate = time() - $leftovertime; $setleftovertime = $db->query("UPDATE `updates` SET `lastdone` = '".$newupdate."' WHERE `name` = 'fivemin'"); } // 5 MINUTE TIME STAPS DONE!!!! ^^ thats not the full file, but all the timestamps parts. If someone could help me then I would greatly appreciate it! Quote
Curt Posted December 27, 2010 Posted December 27, 2010 $num_updates = floor($timesinceupdate / 300); That is the part that tells how many times it should be updated..if 30 minutes has passed since last update then $num_updates will equal 6.. So you can simply multiply the updates by this.. such as : $ENERGYGAIN=(energy * .10) * $num_updates; Hope that helps you :) 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.