Jump to content

Recommended Posts

can anyone someone please help me..

 

I am doing a battle page for my game.

 

i am getting the output... but its not doing any of the 4 queries

 

 

<?php
else if ($enemy->hp <= 0) //PLAYER WINS
        {
            //Calculate losses
            $expwin = ($enemy->level - $player->level * 100 + 100);
            if($expwin <= 1) 
            {
            $expwin =  rand(1, 10);
            }
            $moneywin = intval($enemy->money * 0.05);
            
            $output .= "<br />You attacked " . $enemy->username . " and won.<br />";
            $output .= "<br />You gained <b>" . $expwin . "</b> EXP and <b>$" . $moneywin . "</b>.";
            
            $newexp = $exploss + $enemy->exp - $enemy->maxexp;
        
             //Update Enemy (THE LOSER)
            $query = $db->execute("update `players` set `money`=?, `battle_loss`=?, `battle_total`=?, `battle_money`=?, `hospital`=20 where `id`=?", array($enemy->money - $moneywin, $enemy->battle_loss + 1, $enemy->battle_total + 1, $enemy->battle_money - $moneywin, $enemy->id));
            $logmsg = "You were attacked by <a href=\"profile.php?id=" . $player->username . "\">" . $player->username . "</a> and lost<br />\nYou lost $" . $moneyloss ."";
            addlog($enemy->id, $logmsg, $db);
            
            
            //Update player (the winner).
            if ($expwin + $player->exp < $player->maxexp)
            {
                $query = $db->execute("update `players` set `exp`=?, `money`=?, `battle_won`=?, `battle_total`=?, `battle_total`, `hp`=? where `id`=?", array($player->exp + $exploss, $player->money + $moneyloss, $player->battle_won + 1, $player->battle_total + 1, $player->battle_money + $moneyloss, $player->hp, $player->id));
            }

            // MAX LEVEL (NO EXP).
            if ($player->exp + $expgain >= $player->maxexp && $player->level >= $player->maxlevel)
            {
            $query = $db->execute("update `players` set `money`=?, `exp`=?, `battle_won`=?, `battle_total`=? `battle_money`=? where `id`=?", array($player->money + $moneywin, $player->exp + $expwin, $player->battle_won + 1, $player->battle_total + 1, $player->battle_money + $moneyloss, $player->id ));
            }

        
            // GAINED A LEVEL.
            if ($player->exp + $expgain >= $player->maxexp && $player->level < $player->maxlevel)  
            {
            $query = $db->execute("Update `players` set `level`= `level`+?, `maxexp` =?, `exp` =?, `money` = `money` + ?, `hp`=?, `maxhp`=?,`maxenergy`=`maxenergy`+?, `energy`=?, `battle_won`=?, `battle_money`=?, `battle_total`=?, `maxnerve`=? where `id`=?",array(1, $maxexpgain, $newexp, $player->money + $moneywin, $player->maxhp + 10, $player->maxhp + 10, $player->maxenergy + 1, $player->energy = $player->maxenergy, $player->battle_won + 1, $player->battle_money + $moneywin, $player->battle_total + 1, $player->maxnerve + 1, $player->id));    
            }
        }
?>

Link to comment
https://forums.phpfreaks.com/topic/156593-help-me-please/
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.