grlayouts Posted January 31, 2007 Share Posted January 31, 2007 Ok i have my own online game.. every 15 mins it should pay out 15 energy with the code <?php $time=time(); include("config.php"); mysql_query("update players set energy=energy+15"); mysql_query("update players set energy=750 where energy>750"); mysql_query("update players set hp=max_hp"); mysql_query("update players set ops=ops+1 "); mysql_query("update players set ops=150 where ops>150"); if(!mysql_fetch_row(mysql_query("SELECT cronjob FROM cronjobs WHERE cronjob='turns';"))){mysql_query("INSERT INTO cronjobs VALUES ('turns','$time');");} else{ mysql_query("UPDATE cronjobs SET lastran=$time WHERE cronjob='turns'");} ?> however the problem is that its payout twice. but i only have it as one cron job.. any idea's? Link to comment https://forums.phpfreaks.com/topic/36541-cron-jobs-php/ Share on other sites More sharing options...
mandukar Posted January 31, 2007 Share Posted January 31, 2007 Would that happen to be using Exofusion Scripts? I am having a problem with using cron jobs myself, I am interested, what are you using in your SQL table for your cron timer jobs? Link to comment https://forums.phpfreaks.com/topic/36541-cron-jobs-php/#findComment-174013 Share on other sites More sharing options...
grlayouts Posted January 31, 2007 Author Share Posted January 31, 2007 im not im working with cpanel Link to comment https://forums.phpfreaks.com/topic/36541-cron-jobs-php/#findComment-174015 Share on other sites More sharing options...
ShogunWarrior Posted January 31, 2007 Share Posted January 31, 2007 <?php $time=time(); include("config.php"); mysql_query("UPDATE players SET energy=energy+15"); mysql_query("UPDATE players SET energy=750 where energy>750"); mysql_query("UPDATE players SET hp=max_hp, ops=ops+1"); mysql_query("UPDATE players SET ops=150 where ops>150"); if( mysql_num_rows( mysql_query("SELECT cronjob FROM cronjobs WHERE cronjob='turns';") )<1 ) { mysql_query("INSERT INTO cronjobs VALUES ('turns','$time');"); } else{ mysql_query("UPDATE cronjobs SET lastran=$time WHERE cronjob='turns'"); } I just refactored the code a bit, could you log something to a file to check if the script is running twice somehow? Link to comment https://forums.phpfreaks.com/topic/36541-cron-jobs-php/#findComment-174018 Share on other sites More sharing options...
grlayouts Posted January 31, 2007 Author Share Posted January 31, 2007 no idea? Link to comment https://forums.phpfreaks.com/topic/36541-cron-jobs-php/#findComment-174019 Share on other sites More sharing options...
mandukar Posted January 31, 2007 Share Posted January 31, 2007 no Exofusion is a web based game thats open source. same people that made Gamer fusion Link to comment https://forums.phpfreaks.com/topic/36541-cron-jobs-php/#findComment-174021 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.