Code: Select all
<?php
$currenttime = time();
////////////////////static variables////////////////////
//// Everything is done in seconds////
$hptime = 30;
$healedhealth = 2;
$turntime = 60;
$healedturns = 5;
//////////////////////////////////////////////////////
if($stats['crontime'] < 1)
{
$updateplayer="update stats set crontime='$currenttime' where id='$id'";
mysql_query($updateplayer) or die("Could not update player");
}
else
{
$timepassed = $currenttime - $stats['crontime'];
if($timepassed > $hptime)
{
$intervals = $timepassed / $hptime;
$intervals = (int)$intervals;
$healedhealth = $intervals * $healedhealth;
$totalhealth = $stats['hpoints'] + $healedhealth;
if($totalhealth > $stats['maxhp']){$totalhealth = $stats['maxhp'];}
$updateplayer="update stats set crontime='$currenttime',hpoints='$totalhealth' where id='$id'";
mysql_query($updateplayer) or die("Could not update player");
}
}
if($stats['crontime'] < 1)
{
$updateplayer="update stats set crontime='$currenttime' where id='$id'";
mysql_query($updateplayer) or die("Could not update player");
}
else
{
$timepassed = $currenttime - $stats['crontime'];
if($timepassed > $turntime)
{
$intervals = $timepassed / $turntime;
$intervals = (int)$intervals;
$healedturns = $intervals * $healedturns;
$totalturns = $stats['turns'] + $healedturns;
if($totalturns > $stats['maxturns']){$totalturns = $stats['maxturns'];}
$updateplayer="update stats set crontime='$currenttime',turns='$totalturns' where id='$id'";
mysql_query($updateplayer) or die("Could not update player");
}
}
?>Notice: Undefined variable: stats in C:\xampp\htdocs\flash\runcron.php on line 13
Notice: Undefined variable: id in C:\xampp\htdocs\flash\runcron.php on line 15
Could not update player
Now I can probably define the id as $id = $stats['id']; and that would remove the 2nd one, but also add another one because stats is not defined.
The reason this is important to me, is 1, I hate errors and want them fixed, but 2... It's resetting my turns to zero for whatever reason. All I can think is that it's something to do with this particular coding. Can't go around having turns getting set back to zero now can we? lol. Any ideas? Thanks