Jump to content

Im Having Cron.PHP problem


teothoyang

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']}' ");
?>
Link to comment
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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.