Jump to content

Archived

This topic is now archived and is closed to further replies.

teothoyang

Im Having Cron.PHP problem

Recommended Posts

Hey guys, Im making an online Game clone !
my site is at
www.solarcombat.co.uk
it is a clone of the game at
www.kingsofchaos.com

i got the files needed but my cron.php file aint working, i did the crontab but it seems like my cron.php file is spoilt

here it is

<?
function defSort ($a, $b) {
    if ($a->DefenseAction == $b->DefenseAction) return 0;
    return ($a->DefenseAction > $b->DefenseAction) ? -1 : 1;
}
function atSort ($a, $b) {
    if ($a->StrikeAction == $b->StrikeAction) return 0;
    return ($a->StrikeAction > $b->StrikeAction) ? -1 : 1;
}
function covSort ($a, $b) {
    if ($a->CovertAction == $b->CovertAction) return 0;
    return ($a->CovertAction > $b->CovertAction) ? -1 : 1;
}
function rankFloat ($a, $b) {
    if ($a->RankFloat == $b->RankFloat) return 0;
    return ($a->RankFloat < $b->RankFloat) ? -1 : 1;
}

include "vsys.php";
deleteOldUsers();
$users=getActiveUsers("ID, race, fortificationLevel, siegeLevel, currentSpySkill, trainedAttackSold, trainedAttackMerc, trainedDefSold, trainedDefMerc, untrainedSold, untrainedMerc, spies ");
for ($i=0; $i<count($users);$i++){
//print_r($users[$i]);print "<br>";
$users[$i]->StrikeAction=getStrikeAction($users[$i]);
$users[$i]->DefenseAction=getDefenseAction($users[$i]);
$users[$i]->CovertAction=getCovertAction($users[$i]);
$money=getUserIncome($users[$i]);
updateUser($users[$i]->ID," gold = gold+'$money', attackTurns = attackTurns+2, untrainedSold=untrainedSold+currentUnitProduction ");
//echo getStrikeAction($users[$i])."<br>";
//echo getDefenseAction($users[$i])."<br>";
//echo getCovertAction($users[$i])."<br>";
}
$users1=$users;
usort($users1,"atSort");
//echo "--------------users1---<br>";
//print_r ($users1);
$users2=$users;
usort($users2,"defSort");
//echo "--------------users2---<br>";
//print_r ($users2);
$users3=$users;
usort($users3,"covSort");
//echo "--------------users3---<br>";
//print_r ($users3);

for ($i=0;$i<count($users1);$i++){
$usersA[$users1[$i]->ID]->ID=$users1[$i]->ID;
$usersA[$users1[$i]->ID]->StrikeAction=$i+1;
}
for ($i=0;$i<count($users2);$i++){
$usersA[$users2[$i]->ID]->DefenseAction=$i+1;
}
for ($i=0;$i<count($users3);$i++){
$usersA[$users3[$i]->ID]->CovertAction=$i+1;
$usersA[$users3[$i]->ID]->RankFloat=($usersA[$users3[$i]->ID]->StrikeAction+$usersA[$users3[$i]->ID]->DefenseAction+$usersA[$users3[$i]->ID]->CovertAction)/3;
}
usort($usersA,"rankFloat");
for ($i=0;$i<count($usersA);$i++){
//echo $usersA[$i]->RankFloat.";;";
setUserRank($usersA[$i]->ID, $i+1, $usersA[$i]->StrikeAction, $usersA[$i]->DefenseAction , $usersA[$i]->CovertAction);
}
setLastTurnTime(time());
updateMercenary(" attackSpecCount=attackSpecCount+'{$conf['mercenaries_per_turn']}', defSpecCount =defSpecCount +'{$conf['mercenaries_per_turn']}', untrainedCount =untrainedCount +'{$conf['mercenaries_per_turn']}' ");
?>

Share this post


Link to post
Share on other sites
Do you have a error? Is it path error (working directory problem), it's kind of hard to tell you what is wrong without knowing how your calling this or if the script has errors due to permissions, or it may not be changing the directory so the include files don't get included. All of these are guesses, because we can't see what really is happening. So try to post more information, such as your PHP log if your logging errors or your server log that gives information about the cron task associated with this script!


me!

Share this post


Link to post
Share on other sites
Well, the game is based on turns every 15 minutes. So what the cron does is to update the game every 15 minutes.

But the cron doesnt work so it is stuck at 0 minutes to go forever

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.