Joshua Posted July 9, 2009 Posted July 9, 2009 Recently purchased a new Log-In script and am having problems updating the Cron. The creator has helped me a lot with the script but atm I'm on and he won't be for quite a bit...SO help me :-) por favor..i've fixed a few errors and he's helped me fix some others. The ERROR is it stopped Updating my Users Will/Brave etc. I thought it was because My users weren't Defined, but after I defined their race i'm still not updating. $db->query("UPDATE users SET exp=exp+$qe WHERE userid={$p['userid']}"); $db->query("UPDATE users SET exp=0 WHERE exp < 0"); eve_add($p['userid'],"[url='viewuser.php?u={$r[']{$r['username']}[/url] attacked you and lost. You gained $qe",$c); } } } if ($ir['race']==1) { $db->query("UPDATE `users` SET `brave`=LEAST(`brave`+((`maxbrave`/'5')+'0.5'), `maxbrave`), `hp`=LEAST(`hp`+(`maxhp`/'3'), `maxhp`), `will`=LEAST((`will`+'20'), `maxwill`), `energy`=IF(`donatordays`<>'0', LEAST(`energy`+(`maxenergy`/'6'), `maxenergy`), LEAST(`energy`+(`maxenergy`/'12.5'), `maxenergy`))"); } elseif ($ir['race']==2) { $db->query("UPDATE `users` SET `brave`=LEAST(`brave`+((`maxbrave`/'10')+'0.5'), `maxbrave`), `hp`=LEAST(`hp`+(`maxhp`/'3'), `maxhp`), `will`=LEAST((`will`+'20'), `maxwill`), `energy`=IF(`donatordays`<>'0', LEAST(`energy`+(`maxenergy`/'3'), `maxenergy`), LEAST(`energy`+(`maxenergy`/'6.25'), `maxenergy`))"); } elseif ($ir['race']==3) { $db->query("UPDATE `users` SET `brave`=LEAST(`brave`+((`maxbrave`/'10')+'0.5'), `maxbrave`), `hp`=LEAST(`hp`+(`maxhp`/'1.5'), `maxhp`), `will`=LEAST((`will`+'10'), `maxwill`), `energy`=IF(`donatordays`<>'0', LEAST(`energy`+(`maxenergy`/'3'), `maxenergy`), LEAST(`energy`+(`maxenergy`/'6.25'), `maxenergy`))"); } $db->query($query); $db->query($query5); $db->query($query2); $db->query($query3); $db->query($query4); if($set['validate_period'] == 5 && $set['validate_on']) { $db->query("UPDATE users SET verified=0"); } if($set['validate_period'] == 15 && $set['validate_on'] && in_array(date('i'),array("00", "15", "30", "45"))) { $db->query("UPDATE users SET verified=0"); } $stocks = mysql_query("SELECT stockID FROM `stock_stocks`"); while($soc = mysql_fetch_assoc($stocks)) { $rand = mt_rand(1,2); if($rand == 2) { $mr = mt_rand(10,250); mysql_query("UPDATE `stock_stocks` SET `stockUD` = 2, `stockCHANGE` = ".$mr.", `stockNPRICE` = (`stockNPRICE` - ".$mr.") WHERE `stockID` = ".$soc['stockID']); } else { $mr = mt_rand(10,250); mysql_query("UPDATE `stock_stocks` SET `stockUD` = 1, `stockCHANGE` = ".$mr.", `stockNPRICE` = (`stockNPRICE` + ".$mr.") WHERE `stockID` = ".$soc['stockID']); } } include_once('global_func.php'); $sel = mysql_query("SELECT stockID,stockNAME FROM `stock_stocks` WHERE `stockNPRICE` < 0"); while($soc = mysql_fetch_assoc($sel)) { if(mysql_num_rows(mysql_query("SELECT holdingID FROM `stock_holdings` WHERE `holdingSTOCK` = ".$soc['stockID']))) { $user = mysql_query("SELECT holdingUSER FROM `stock_holdings` WHERE `holdingSTOCK` = ".$soc['stockID']); $user = mysql_fetch_assoc($user); event_add($user['holdingUSER'], 'Stock '.$soc['stockNAME'].' crashed, you lost all your shares.'); } mysql_query("DELETE FROM `stock_holdings` WHERE `holdingSTOCK` = ".$soc['stockID']); mysql_query("UPDATE `stock_stocks` SET `stockUD` = 1,`stockCHANGE` = 0,`stockNPRICE` = `stockOPRICE` WHERE `stockID` = ".$soc['stockID']); } ?> Quote
Eruondo Posted July 9, 2009 Posted July 9, 2009 Re: +1 for helping me get this Cron_5 Min to work I'm a total beginner, but why not just use if($ir['donatordays'] > 0) { $db->query("UPDATE `users` SET `brave`=`brave`+((`maxbrave`/'5')+'0.5'),`hp`=(`hp`+(`maxhp`/'3')),`will`=`will`+'20',`energy`=`energy`+(`maxenergy`/'6') } else { $db->query("UPDATE `users` SET `brave`=`brave`+((`maxbrave`/'5')+'0.5'),`hp`=(`hp`+(`maxhp`/'3')),`will`=`will`+'20',`energy`=`energy`+(`maxenergy`/'12.5') } instead of $db->query("UPDATE `users` SET `brave`=LEAST(`brave`+((`maxbrave`/'5')+'0.5'), `maxbrave`), `hp`=LEAST(`hp`+(`maxhp`/'3'), `maxhp`), `will`=LEAST((`will`+'20'), `maxwill`), `energy`=IF(`donatordays`<>'0', LEAST(`energy`+(`maxenergy`/'6'), `maxenergy`), LEAST(`energy`+(`maxenergy`/'12.5'), `maxenergy`))"); Now, that's just for race 1, but you get the picture. Not sure if it will work though... Quote
Joshua Posted July 9, 2009 Author Posted July 9, 2009 Re: +1 for helping me get this Cron_5 Min to work The problem was everything was working fine until I added the if race part. There were a few instances in the script written for me I had major errors where the fix was just changing " to ' The Query is exactly like the one I had that was working except it's for individual races now..that's why I'm having problems fixing it...nothing really has changed but the if statement :\ Quote
Eruondo Posted July 9, 2009 Posted July 9, 2009 Re: +1 for helping me get this Cron_5 Min to work Hm. What's the deal with these? As far as I can see, they're not doing anything... $db->query($query); $db->query($query5); $db->query($query2); $db->query($query3); $db->query($query4); Quote
Joshua Posted July 9, 2009 Author Posted July 9, 2009 Re: +1 for helping me get this Cron_5 Min to work I'm not even 100% sure, I may have added a script a long while back and those worked off that then removed script and not removed those...but again, they were just sitting there doing nothing....The only reason i hadnt removed them recently as I wasnt sure if they had something to do with a Call to the Stats update...but looking at it, you're probably right. Also after going over my crons, ALL my other crons are just plain codes w/o the use of ' I'm wondering if I go through and remove all the ' in the crons if it will work....hrm. Quote
glg216 Posted July 11, 2009 Posted July 11, 2009 Re: +1 for helping me get this Cron_5 Min to work the problem is the if ($ir['race']==1). The variable is not filled with anything. You didn't query the data base to populate it. you can query to see who has the race =1 and then do a while statement in conjuction to the if statement. for better coding i recomment taking out the if and adding a where at the end of the query. do that for the three races and it will work $db->query("UPDATE `users` SET `brave`=LEAST(`brave`+((`maxbrave`/'5')+'0.5'), `maxbrave`), `hp`=LEAST(`hp`+(`maxhp`/'3'), `maxhp`), `will`=LEAST((`will`+'20'), `maxwill`), `energy`=IF(`donatordays`<>'0', LEAST(`energy`+(`maxenergy`/'6'), `maxenergy`), LEAST(`energy`+(`maxenergy`/'12.5'), `maxenergy` WHERE race=1))") ; Quote
AlabamaHit Posted July 11, 2009 Posted July 11, 2009 Re: +1 for helping me get this Cron_5 Min to work To simplify what he said the $ir variable is not set in a cron. 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.