bloodless2010 Posted November 25, 2012 Share Posted November 25, 2012 Hey guys. I managed to remove 1minute cronjob for my game, But I'm having problem with the 1day and 5minute ones now. http://makewebgames.io/archive/index.php/t-32642.html Is the thread I used; I am currently using this: (It only works if a person clicks every 5 minutes, so you could leave for 20 and click and it would only update once) $result = mysql_query("SELECT * FROM `updates` WHERE `name` = '5min'"); $result = mysql_fetch_assoc($result); $hla = time() - $result['last']; if($hla > (300)) { $n = floor($hla / 300); $allusers_query = "UPDATE `users` SET `brave` = LEAST(`brave` + ((`maxbrave` / 10) + 0.5), `maxbrave`), `hp` = LEAST(`hp` + (`maxhp` / 3), `maxhp`), `will` = LEAST(`will` + 10, `maxwill`)"; mysql_query($allusers_query, $c); //enerwill update $en_nd_query = "UPDATE `users` SET `energy` = LEAST(`energy` + (`maxenergy` / 12.5), `maxenergy`) WHERE `donatordays` = 0"; $en_don_query = "UPDATE `users` SET `energy` = LEAST(`energy` + (`maxenergy` / 6), `maxenergy`) WHERE `donatordays` > 0"; mysql_query($en_nd_query, $c); mysql_query($en_don_query, $c); $time = time(); mysql_query("UPDATE `updates` SET `last` = ".$time." WHERE `name` = '5min'"); $floor = $time - (floor($time / 300) * 300); if($floor > 0) { $newUpdate = time() - $floor; mysql_query("UPDATE `updates` SET `last` = ".$newUpdate." WHERE `name` = '5min'"); } } I need it to update properly like, if I don't click for 20 minutes and do, it increases it 4 times, if you understand what I mean. Thanks! Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted November 25, 2012 Share Posted November 25, 2012 (edited) You can maybe try this. I believe you have to be logged in to download the file. He also has one for the minute cron for v2 but you can convert it over to v1 http://www.mccodemods.com/devforum/featured-free-v1-mods/remove-5-minute-cron/ Edited November 25, 2012 by KyleMassacre what a noob I forgot the link Quote Link to comment Share on other sites More sharing options...
bloodless2010 Posted November 25, 2012 Author Share Posted November 25, 2012 I did forget to mention I did try the other peoples version of the 5min cron on the thread I posted, but the loop it uses stops my page from loading at all, it keeps loading and loading I'll try that thread you posts Kyle, hope it works :) Quote Link to comment Share on other sites More sharing options...
bloodless2010 Posted November 25, 2012 Author Share Posted November 25, 2012 Works like a charm, thanks! Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted November 25, 2012 Share Posted November 25, 2012 Good, glad I can be of some service. I believe the way he has it set up is it wont work till there is a click but once some on clicks they get their updates that they shouldve been rewarded. Example: No users online and 1 user in jail for 1 minutes, 3 hours later the user is still in jail but a user logs in and boom the jailed user is no out of jail. Hope that makes sense but me personally I run crons. Quote Link to comment Share on other sites More sharing options...
HauntedDawg Posted November 25, 2012 Share Posted November 25, 2012 (edited) Cron's are a lot more accurate and should be used for thing such as hour and day cron. It is best to remove the 5min & 1min cron tho on mccodes. Also, bloodless, you are correct in your code. You just need to "Times by $n" like so: $n = floor($hla / 300); $allusers_query = "UPDATE `users` SET `brave` = LEAST(`brave` + (((`maxbrave` / 10) + 0.5) * ".$n."), `maxbrave`), `hp` = LEAST(`hp` + ((`maxhp` / 3) * ".$n."), `maxhp`), `will` = LEAST(`will` + (10 * ".$n."), `maxwill`)"; mysql_query($allusers_query, $c); //enerwill update $en_nd_query = "UPDATE `users` SET `energy` = LEAST(`energy` + ((`maxenergy` / 12.5) * ".$n."), `maxenergy`) WHERE `donatordays` = 0"; $en_don_query = "UPDATE `users` SET `energy` = LEAST(`energy` + ((`maxenergy` / 6) * ".$n."), `maxenergy`) WHERE `donatordays` > 0"; That way, it will update by * the value by N, which is divided on top. n usually is 1, but then if 10 minutes are past. it will be 2, so the value is times by 2. if that makes sense. But realistically, we don't need 3 queries, and can combine that into one. $n = floor($hla / 300); $update_users = 'UPDATE `users` SET `'; $update_users.= ' `brave` = LEAST(`brave` + (((`maxbrave` / 10) + 0.5) * '.$n.'), `maxbrave`),'; $update_users.= ' `hp` = LEAST(`hp` + ((`maxhp` / 3) * '.$n.'), `maxhp`),'; $update_users.= ' `will` = LEAST(`will` + (10 * '.$n.'), `maxwill`),'; $update_users.= ' `energy` = IF(`donatordays`, LEAST(`energy` + ((`maxenergy` / 6) * '.$n.')), LEAST(`energy` + ((`maxenergy` / 12.5) * '.$n.')))'; mysql_query($update_users); Edited November 25, 2012 by HauntedDawg Quote Link to comment Share on other sites More sharing options...
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.