Kasabian Posted March 11, 2009 Posted March 11, 2009 hey, i haven't posted in a while but I've started playing around with pog1 5 min cron alternative: $result = mysql_query("SELECT * FROM `cron` WHERE `name` = '5min'"); $result = mysql_fetch_array($result,MYSQL_ASSOC); $howLongAgo = time() - $result['last']; if($howLongAgo > (300)) { $n = floor($howLongAgo / 300); // 300 = 5 mins $user = mysql_fetch_array($db->query(sprintf("SELECT * FROM users WHERE userid = '%u'",abs(@intval($_SESSION['userid'])) )),MYSQL_ASSOC); $v = ($set['validate_on']) ? "verified = '0', " : FALSE; $e = ($user['donatordays'] > 0) ? 10 : 5; $energy = ($user['energy']) + ($e * $n); $energy = (int) ($energy > $user['maxenergy']) ? $user['maxenergy'] : $energy; $brave = ($user['brave']) + (2 * $n); $brave = (int) ($brave > $user['brave']) ? $user['maxbrave'] : $brave; $hp = $user['hp'] + (($user['maxhp'] * .25) * $n); $hp = (int) ($hp > $user['maxhp']) ? $user['maxhp'] : $newhp; $will = ($user['will']) + (5 * $n); $will = (int) ($will > $user['will']) ? $user['maxwill'] : $will; $string = sprintf("UPDATE `users` SET %s `energy` = '%u', `brave` = '%u', `hp` = '%u', `will` = '%u'", $v,$energy,$brave,$hp,$will); mysql_query($string) or die('CRON ERROR'); $t = time(); $result = $db->query("UPDATE `cron` SET `last` = '%u' WHERE `name` = '5min'",$t); $l = $t - (floor($t / 300) * 300); if ($l > 0) { $newUpdate = time() - $l; $result = $db->query(sprintf("UPDATE `cron` SET `last` = '%u' WHERE `name` = '5min'",$newUpdate)); } } but I'm having problems its refilling the energy, its refilling at about 41.5% without donator packs. this is a big problem for me as i would like it to be the normal 8% and 17% on donator. can anyone help sort it out. The will and brave are also running super fast as well, I have checked the times and its running at the correct speed. i just wanna put a key point right out there about me: Yes i am retarded at maths... thank you for point that out any help will be much appreciated. Thanks Quote
Lithium Posted March 11, 2009 Posted March 11, 2009 Re: 5 min cron alternative Correct me if i'm wrong... user has 20% energy 20% (let's say 100 out of a max of 500 energy) $energy = ($user['energy']) + ($e * $n); $e = 301 / 300 = 1 $n = 10 $energy = 100 + 1 * 10 $energy = 110 = 22% best would be $e = ($user['donatordays'] > 0) ? 5 : 10; $energy = $user['energy'] + ($user['maxenergy']/$e) This way you are giving 20% energy to donators and 10% to non donators. From here, you can play around with the values Quote
Kasabian Posted March 11, 2009 Author Posted March 11, 2009 Re: 5 min cron alternative ye that worked perfect thanks Lithium, im still having problems with the brave but i will try and work it out. Quote
POG1 Posted March 11, 2009 Posted March 11, 2009 Re: 5 min cron alternative with the brave just try and break it down like lithium did with the energy.. 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.