Hey, I'm curently making a game and here's part of the attack script:
$uwepinfo = mysql_fetch_array(mysql_query("SELECT * FROM wep1 WHERE num = '$userinfo[wep1]'"));
$earmorinfo = mysql_fetch_array(mysql_query("SELECT * FROM armor WHERE num = '$enemyinfo[armor]'"));
$dmgc = rand(0,5);
$dmg = ($uwepinfo[dmg] + $dmgc + $userinfo[pwr]) - ($earmorinfo[def]);
$hitperc = rand(0,5);
$hitperm = rand(0,5);
$hitper = ($uwepinfo[acc] + $hitperc) - ($enemyinfo[dex] + $hitperm);
$chit = rand(0,100);
mysql_query("UPDATE players SET wep1a=(wep1a-1) WHERE username = '$userinfo[username]'");
if($hitper >= $chit) {
mysql_query("UPDATE players SET health=(health-$dmg) WHERE username = '$enemyinfo[username]'");
echo "You hit $enemyinfo[username] for $dmg damage!";
echo "<br><br>";
if($enemyinfo[health] <= 0) {
$killtime = time();
mysql_query("UPDATE players SET health=maxhealth, x=5, y=5, deaths=(deaths+1), killed=1, killedby = '$userinfo[username]', killtime=$killtime WHERE username = '$enemyinfo[username]'");
$expgain = rand(20,70);
$moneygain = rand(50,120);
mysql_query("UPDATE players SET exp=(exp+$expgain), texp=(texp+$expgain), money=(money+$moneygain), kills=(kills+1) WHERE username = '$userinfo[username]'");
echo "You have killed $enemyinfo[username]! You gained $expgain experience!";
echo "<br><br>";
}
echo "[<a href=game.php>back</a>]<br>";
} else {
echo "You missed $enemyinfo[username]!";
echo "<br><br>";
echo "[<a href=game.php>back</a>]<br>";
}
now, the problem is, I want the user to die after they reach 0hp or go under, but for some reason, they dont show up as killed until the next attack AFTER 0hp. For example, if I hit someone for like 34 damage and they only have 20 hp, then they would have -14hp, but wouldn't be dead, then in the next attack, even if it's only 1 damage, it'll make them as dead, any idea why? O.o