eaglelegend Posted April 9, 2008 Share Posted April 9, 2008 this is the code to the battle system, that is however hidden from the public at direct access but shows if you go the right way ie. explore > Battle.php > Bat.php (this file) which is correct, however the users "pet" does not show, nor does anything to attack, the users side is just blank however the oppanants side is there... any ideas? <? include("config.php"); include("members.php"); ?> <html> <head> <title>Battle</title> <link rel="stylesheet" href="<? echo $style_file; ?>" type="text/css"> <body> <? $a = $_GET['action']; if($a == 'battle') { $newbattle = $_GET['newbattle']; if($newbattle!="") { $pet = rand(1,11); $health = rand(70,100); $rrID = rand(1,999999999); if($pet == 1) { $peti = "Avvis"; $petn = "Avvis"; } if($pet == 2) { $peti = "Bibbit"; $petn = "Bibbit"; } if($pet == 3) { $peti = "Blyger"; $petn = "Blyger"; } if($pet == 4) { $peti = "Foresal"; $petn = "Foresal"; } if($pet == 5) { $peti = "Quadra"; $petn = "Quadra"; } if($pet == 6) { $peti = "Skitty"; $petn = "Skitty"; } if($pet == 7) { $peti = "Snikra"; $petn = "Snikra"; } if($pet == { $peti = "Taurus"; $petn = "Taurus"; } if($pet == 9) { $peti = "Thistlehog"; $petn = "Thistlehog"; } if($pet == 10) { $peti = "Urchyn"; $petn = "Urchyn"; } if($pet == 11) { $peti = "Wolflint"; $petn = "Wolflint"; } $insert = mysql_query("INSERT `battle_pets` (`site`, `pet`, `petName`, `user`, `health`, `rID`) VALUES(\"$Z\", '$peti', '$petn', '{$_COOKIE['ELv2']}', '$health', '$rrID')"); } else { $rrID = $_GET['rID']; } if($insert || $newbattle == "") { print "<h2>Battle</h2><p>"; print "<table border=0 cellpadding=3 cellspacing=0 width=100%> <tr> <td width=47% valign=top>"; $sql = mysql_query("SELECT * FROM `battle_pets` WHERE `rID`='$rrID' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row = mysql_fetch_array($sql)) { extract($row); print "<table border=0 cellpadding=2 cellspacing=0 width=100%> <tr> <td colspan=2 class=other><b>Computer</b></td> </tr> <tr> <td valign=middle align=center class='other'> <img src='http://www.eaglelegend.com/images/pets/battle/$pet.png'></td> <td valign=top class='other' width=100%><b>$petName</b><p> Health: $health</td> </tr> </table>"; } print "</td> <td width=5% valign=top align=center><h2>VS.</h2></td> <td width=48% valign=top>"; $myPet = mysql_query("SELECT * FROM `battles` WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($myPetRow = mysql_fetch_array($myPet)) { extract($myPetRow); $weaponsql = mysql_query("SELECT * FROM `items` WHERE `user`='{$_COOKIE['ELv2']}' AND `id`='$weapon1' AND `site`=\"$Z\""); while($weaponrow = mysql_fetch_array($weaponsql)) { $name = $weaponrow["name"]; $damage = $weaponrow["damage"]; if($name && $damage) { $opt .= "<option value='weapon1'>Attack with $name [up to $damage damage]</option>"; } } $weaponsql = mysql_query("SELECT * FROM `items` WHERE `user`='{$_COOKIE['ELv2']}' AND `id`='$weapon2' AND `site`=\"$Z\""); while($weaponrow = mysql_fetch_array($weaponsql)) { $name = $weaponrow["name"]; $damage = $weaponrow["damage"]; if($name && $damage) { $opt .= "<option value='weapon2'>Attack with $name [up to $damage damage]</option>"; } } $weaponsql = mysql_query("SELECT * FROM `items` WHERE `user`='{$_COOKIE['ELv2']}' AND `id`='$weapon3' AND `site`=\"$Z\""); while($weaponrow = mysql_fetch_array($weaponsql)) { $name = $weaponrow["name"]; $damage = $weaponrow["damage"]; if($name && $damage) { $opt .= "<option value='weapon3'>Attack with $name [up to $damage damage]</option>"; } } $petsql = mysql_query("SELECT * FROM `pets` WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($petrow = mysql_fetch_array($petsql)) { $petName = $petrow["petName"]; $petHealth = $petrow["health"]; $petSpecies = $petrow["species"]; $petID = $petrow["petID"]; $sql11 = mysql_query("SELECT * FROM `available_pets` WHERE `id`='$petID' AND `site`=\"$Z\""); while($row11 = mysql_fetch_array($sql11)) { $img = $row11["img"]; } if($img == "") { $i = "<img src='http://www.eaglelegend.com/images/pets/$petSpecies.png'>"; } else { $i = "<img src='http://www.eaglelegend.com/images/pets/$img.png'>"; } } print "<table border=0 cellpadding=2 cellspacing=0 width=100%> <tr> <td colspan=2 class=other><b>My Pet</b></td> </tr> <tr> <td valign=middle align=center>$i </td> <td width=100% valign=top class=other> <b>$petName</b><p> Health: $petHealth</td> </tr> </table><br> <b>Attack</b><br> <form action='http://www.eaglelegend.com/bat.php?action=fight' method='post'> <input type='hidden' value='$rrID' name='againstpet'> <select name='attack' size='1'> <option value='normal'>Normal Attack</option>"; print $opt; print "</select><p><input type=\"submit\" value=\"Attack\" onclick=\"this.disabled=true\"></form>"; } print "</td> </tr> </table>"; $msql = mysql_query("SELECT * FROM `battles` WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($mrow = mysql_fetch_array($msql)) { $message = $mrow["last_message"]; } print "<h2>Battle Messages</h2><p> $message"; } } if($a == 'hospital') { print "<h2>Hospital</h2><p>"; $aa = $_GET['haction']; if($aa == '') { $sql = mysql_query("SELECT * FROM `pets` WHERE `health` < `maxhealth` AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); $num = mysql_num_rows($sql); if($num > 0) { print "It costs $10 to heal each pet! What would you like to do!<p>"; print "<a href='http://www.eaglelegend.com/bat.php?action=hospital&haction=all'>Heal All</a><p>"; print "<b>Heal Individual</b><br> <form action='http://www.eaglelegend.com/bat.php?action=hospital&haction=pet' method='post'> Pet <select name='pet' size='1'>"; while($row = mysql_fetch_array($sql)) { extract($row); print "<option value='$id'>Heal $petName to $maxhealth</option>"; } print "</select> <input type='submit' value=' Heal Pet '></form>"; } else { print "<p>All of your pets are at full health!<p> <a href='http://www.eaglelegend.com/bat.php?action=battle&newbattle=1'>Click here to battle again!</a>"; } } else { if($aa == 'pet') { $petID = $_POST['pet']; $sql = mysql_query("SELECT * FROM `pets` WHERE `id`='$petID' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if(10 > $MONEY) { print "Sorry you do not have enough money to heal all of your pets!"; } else { while($row = mysql_fetch_array($sql)) { $h = $row["health"]; $m = $row["maxhealth"]; $i = $row["id"]; $query = mysql_query("UPDATE `pets` SET `health`='$m' WHERE `id`='$i' AND `site`=\"$Z\""); if($query) { $total = $total + 1; } else { print mysql_error(); } } $newmoney = $MONEY - 10; $update = mysql_query("UPDATE `members` SET `money`='$newmoney' WHERE `username`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if($update) { print $total . " pets were restored to full health!<p> This cost you 10 dollars!<p> <a href='http://www.eaglelegend.com/bat.php?action=battle&newbattle=1'>Click here to battle again!</a>"; } else { print mysql_error(); } } } if($aa == 'all') { $sql = mysql_query("SELECT * FROM `pets` WHERE `user`='{$_COOKIE['ELv2']}' AND `health` < `maxhealth` AND `site`=\"$Z\""); $num = mysql_num_rows($sql); $cost = $num * 10; if($cost > $MONEY) { print "Sorry you do not have enough money to heal all of your pets!"; } else { while($row = mysql_fetch_array($sql)) { $h = $row["health"]; $m = $row["maxhealth"]; $i = $row["id"]; $query = mysql_query("UPDATE `pets` SET `health`='$m' WHERE `id`='$i' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if($query) { $total = $total + 1; } else { print mysql_error(); } } $newmoney = $MONEY - $cost; $update = mysql_query("UPDATE `members` SET `money`='$newmoney' WHERE `username`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if($update) { print $total . " pets were restored to full health!<p> This cost you $cost dollars!<p> <a href='http://www.eaglelegend.com/bat.php?action=battle&newbattle=1'>Click here to battle again!</a>"; } else { print mysql_error(); } } } } } if($a == 'fight') { $againstpet = $_POST['againstpet']; $attack = $_POST['attack']; $sql2 = mysql_query("SELECT * FROM `battles` WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row2 = mysql_fetch_array($sql2)) { $pet = $row2["pet"]; $weapon1 = $row2["weapon1"]; $weapon2 = $row2["weapon2"]; $weapon3 = $row2["weapon3"]; $lm = $row2["last_message"]; } $sql3 = mysql_query("SELECT * FROM `pets` WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row3 = mysql_fetch_array($sql3)) { $my_health = $row3["health"]; $my_name = $row3["petName"]; } $sql = mysql_query("SELECT * FROM `battle_pets` WHERE `rID`='$againstpet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row = mysql_fetch_array($sql)) { $against_health = $row["health"]; $against_pet = $row["petName"]; } if($against_health < 1 && $my_health < 1) { $sql5 = mysql_query("SELECT * FROM `pets` WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row5 = mysql_fetch_array($sql5)) { $wins = $row5["ties"]; } $wins = $wins + 1; $result = "This battle was a tie!"; $user = $_COOKIE['ELv2']; $against = $against_pet; $userpet = $my_name; $date = date("m/d/y"); mysql_query("INSERT INTO `recent_battles` ( `site`, `user` , `result` , `against` , `userpet` , `id` , `date` ) VALUES ( \"$Z\", '$user', '$result', '$against', '$userpet', '', '$date' );"); $update5 = mysql_query("UPDATE `pets` SET `ties`='$wins' WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); $update55 = mysql_query("UPDATE `battles` SET `last_message`='' WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if($update55 && $update5) { print "<h2>The result was a tie!</h2><p> <a href='http://www.eaglelegend.com/bat.php?action=hospital'>Click here to visit the hospital!</a><p>"; } else { print mysql_error(); } die; } if($against_health < 1 && $my_health > 0) { $sql5 = mysql_query("SELECT * FROM `pets` WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row5 = mysql_fetch_array($sql5)) { $wins = $row5["wins"]; } $wins = $wins + 1; $result = "$my_name won this battle!"; $user = $_COOKIE['ELv2']; $against = $against_pet; $userpet = $my_name; $date = date("m/d/y"); mysql_query("INSERT INTO `recent_battles` ( `site`, `user` , `result` , `against` , `userpet` , `id` , `date` ) VALUES ( \"$Z\", '$user', '$result', '$against', '$userpet', '', '$date' );"); $update5 = mysql_query("UPDATE `pets` SET `wins`='$wins' WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); $update55 = mysql_query("UPDATE `battles` SET `last_message`='' WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if($update55 && $update5) { print "<h2>You won the battle!</h2><p> <a href='http://www.eaglelegend.com/bat.php?action=battle&newbattle=1'>Click here to start a new battle!</a><p> <a href='http://www.eaglelegend.com/bat.php?action=hospital'>Click here to visit the hospital!</a><p>"; } else { print mysql_error(); } die; } if($against_health > 0 && $my_health < 1) { $sql5 = mysql_query("SELECT * FROM `pets` WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row5 = mysql_fetch_array($sql5)) { $wins = $row5["loses"]; } $wins = $wins + 1; $result = "$my_name lost this battle!"; $user = $_COOKIE['ELv2']; $against = $against_pet; $userpet = $my_name; $date = date("m/d/y"); mysql_query("INSERT INTO `recent_battles` ( `site`, `user` , `result` , `against` , `userpet` , `id` , `date` ) VALUES ( \"$site\", '$user', '$result', '$against', '$userpet', '', '$date' );"); $update5 = mysql_query("UPDATE `pets` SET `loses`='$wins' WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); $update55 = mysql_query("UPDATE `battles` SET `last_message`='' WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if($update55 && $update5) { print "<h2>You lost the battle!</h2><p> <a href='http://www.eaglelegend.com/bat.php?action=hospital'>Click here to visit the hospital!</a><p>"; } else { print mysql_error(); } die; } if($attack == 'normal') { $damage = rand(2,10); $against_health = $against_health - $damage; $mess .= "You attacked the enemy and caused $damage damage!<br>\n"; } if($attack == 'weapon1') { $sql4 = mysql_query("SELECT * FROM `items` WHERE `id`='$weapon1' AND `type`='weapon' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row4 = mysql_fetch_array($sql4)) { $dam = $row4["damage"]; $nam = $row4["name"]; } $half = ($dam / 2); $half = round($half,0); $newdam = rand($half, $dam); $against_health = $against_health - $newdam; $mess .= "You attacked with a $nam and caused $newdam damage!<br>\n"; } if($attack == 'weapon2') { $sql4 = mysql_query("SELECT * FROM `items` WHERE `id`='$weapon2' AND `type`='weapon' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row4 = mysql_fetch_array($sql4)) { $dam = $row4["damage"]; $nam = $row4["name"]; } $half = ($dam / 2); $half = round($half,0); $newdam = rand($half, $dam); $against_health = $against_health - $newdam; $mess .= "You attacked with a $nam and caused $newdam damage!<br>\n"; } if($attack == 'weapon3') { $sql4 = mysql_query("SELECT * FROM `items` WHERE `id`='$weapon3' AND `type`='weapon' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row4 = mysql_fetch_array($sql4)) { $dam = $row4["damage"]; $nam = $row4["name"]; } $half = ($dam / 2); $half = round($half,0); $newdam = rand($half, $dam); $against_health = $against_health - $newdam; $mess .= "You attacked with a $nam and caused $newdam damage!<br>\n"; } $mydam = rand(1,20); $block = rand(1,2); if($block == 1) { $mydamm = round(($mydam/2),0); $my_health = $my_health - $mydamm; $mess .= "You were attacked. You blocked the attacked but still was hit for $mydamm damage!<br>\n"; } else { $my_health = $my_health - $mydam; $mess .= "You were attacked and you were hit for a total of $mydam damage!<br>\n"; } $me = $mess . $lm; $update = mysql_query("UPDATE `battle_pets` SET `health`='$against_health' WHERE `rID`='$againstpet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); $update2 = mysql_query("UPDATE `pets` SET `health`='$my_health' WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); $update3 = mysql_query("UPDATE `battles` SET `last_message`=\"$me\" WHERE `user`='{$_COOKIE['ELv2']}'"); if($update && $update2 && $update3) { Header("Location: http://www.eaglelegend.com/bat.php?action=battle&rID=$againstpet"); } else { print mysql_error(); } } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/100318-battle-system-something-wrong/ Share on other sites More sharing options...
quiettech Posted April 9, 2008 Share Posted April 9, 2008 Please provide only the relevant parts of your code. Also explain better what is that you want. Be as concise as possible in the code, but be as detailed as possible in the question. Remember we didn't write that code. And if you want more people to look for an answer to your problem you may try and make their life easier, by using your time preparing the question so that we don't use ours searching for the answer. Link to comment https://forums.phpfreaks.com/topic/100318-battle-system-something-wrong/#findComment-512964 Share on other sites More sharing options...
eaglelegend Posted April 9, 2008 Author Share Posted April 9, 2008 ok sorry, I have just solved that problem. now on IE, unfortunately I cannot test this as I don't have windows however the last time I played with it or test the code should I say on win XP on IE and a american user, you click the attack button and it dont do anything however on other browsers including firefox it works perfectly here is updated battle code... <? include("config.php"); include("members.php"); ?> <html> <head> <title>Battle</title> <link rel="stylesheet" href="<? echo $style_file; ?>" type="text/css"> <body> <? $a = $_GET['action']; if($a == 'battle') { $newbattle = $_GET['newbattle']; if($newbattle!="") { $pet = rand(1,11); $health = rand(70,100); $rrID = rand(1,999999999); if($pet == 1) { $peti = "Avvis"; $petn = "Avvis"; } if($pet == 2) { $peti = "Bibbit"; $petn = "Bibbit"; } if($pet == 3) { $peti = "Blyger"; $petn = "Blyger"; } if($pet == 4) { $peti = "Foresal"; $petn = "Foresal"; } if($pet == 5) { $peti = "Quadra"; $petn = "Quadra"; } if($pet == 6) { $peti = "Skitty"; $petn = "Skitty"; } if($pet == 7) { $peti = "Snikra"; $petn = "Snikra"; } if($pet == { $peti = "Taurus"; $petn = "Taurus"; } if($pet == 9) { $peti = "Thistlehog"; $petn = "Thistlehog"; } if($pet == 10) { $peti = "Urchyn"; $petn = "Urchyn"; } if($pet == 11) { $peti = "Wolflint"; $petn = "Wolflint"; } $insert = mysql_query("INSERT `battle_pets` (`site`, `pet`, `petName`, `user`, `health`, `rID`) VALUES(\"$Z\", '$peti', '$petn', '{$_COOKIE['ELv2']}', '$health', '$rrID')"); } else { $rrID = $_GET['rID']; } if($insert || $newbattle == "") { print "<h2>Battle</h2><p>"; print "<table border=0 cellpadding=3 cellspacing=0 width=100%> <tr> <td width=47% valign=top>"; $sql = mysql_query("SELECT * FROM `battle_pets` WHERE `rID`='$rrID' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row = mysql_fetch_array($sql)) { extract($row); print "<table border=0 cellpadding=2 cellspacing=0 width=100%> <tr> <td colspan=2 class=other><b>Computer</b></td> </tr> <tr> <td valign=middle align=center class='other'> <img src='http://www.eaglelegend.com/images/pets/battle/$pet.png'></td> <td valign=top class='other' width=100%><b>$petName</b><p> Health: $health</td> </tr> </table>"; } print "</td> <td width=5% valign=top align=center><h2>VS.</h2></td> <td width=48% valign=top>"; $myPet = mysql_query("SELECT * FROM `battles` WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($myPetRow = mysql_fetch_array($myPet)) { extract($myPetRow); $weaponsql = mysql_query("SELECT * FROM `items` WHERE `user`='{$_COOKIE['ELv2']}' AND `id`='$weapon1' AND `site`=\"$Z\""); while($weaponrow = mysql_fetch_array($weaponsql)) { $name = $weaponrow["name"]; $damage = $weaponrow["damage"]; if($name && $damage) { $opt .= "<option value='weapon1'>Attack with $name [up to $damage damage]</option>"; } } $weaponsql = mysql_query("SELECT * FROM `items` WHERE `user`='{$_COOKIE['ELv2']}' AND `id`='$weapon2' AND `site`=\"$Z\""); while($weaponrow = mysql_fetch_array($weaponsql)) { $name = $weaponrow["name"]; $damage = $weaponrow["damage"]; if($name && $damage) { $opt .= "<option value='weapon2'>Attack with $name [up to $damage damage]</option>"; } } $weaponsql = mysql_query("SELECT * FROM `items` WHERE `user`='{$_COOKIE['ELv2']}' AND `id`='$weapon3' AND `site`=\"$Z\""); while($weaponrow = mysql_fetch_array($weaponsql)) { $name = $weaponrow["name"]; $damage = $weaponrow["damage"]; if($name && $damage) { $opt .= "<option value='weapon3'>Attack with $name [up to $damage damage]</option>"; } } $petsql = mysql_query("SELECT * FROM `pets` WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($petrow = mysql_fetch_array($petsql)) { $petName = $petrow["petName"]; $petHealth = $petrow["health"]; $petSpecies = $petrow["species"]; $petID = $petrow["petID"]; $sql11 = mysql_query("SELECT * FROM `available_pets` WHERE `id`='$petID' AND `site`=\"$Z\""); while($row11 = mysql_fetch_array($sql11)) { $img = $row11["img"]; } if($img == "") { $i = "<img src='http://www.eaglelegend.com/images/pets/$petSpecies.png'>"; } else { $i = "<img src='http://www.eaglelegend.com/images/pets/$img.png'>"; } } print "<table border=0 cellpadding=2 cellspacing=0 width=100%> <tr> <td colspan=2 class=other><b>My Pet</b></td> </tr> <tr> <td valign=middle align=center>$i </td> <td width=100% valign=top class=other> <b>$petName</b><p> Health: $petHealth</td> </tr> </table><br> <b>Attack</b><br> <form action='http://www.eaglelegend.com/bat.php?action=fight' method='post'> <input type='hidden' value='$rrID' name='againstpet'> <select name='attack' size='1' class='text_box'> <option value='normal'>Normal Attack</option>"; print $opt; print "</select><p><input type=\"submit\" value=\"Attack\" onclick=\"this.disabled=true\" class='text_box'></form>"; } print "</td> </tr> </table>"; $msql = mysql_query("SELECT * FROM `battles` WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($mrow = mysql_fetch_array($msql)) { $message = $mrow["last_message"]; } print "<h2>Battle Messages</h2><p> $message"; } } if($a == 'hospital') { print "<h2>Hospital</h2><p>"; $aa = $_GET['haction']; if($aa == '') { $sql = mysql_query("SELECT * FROM `pets` WHERE `health` < `maxhealth` AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); $num = mysql_num_rows($sql); if($num > 0) { print "It costs $10 to heal each pet! What would you like to do!<p>"; print "<a href='http://www.eaglelegend.com/bat.php?action=hospital&haction=all'>Heal All</a><p>"; print "<b>Heal Individual</b><br> <form action='http://www.eaglelegend.com/bat.php?action=hospital&haction=pet' method='post'> Pet <select name='pet' size='1'>"; while($row = mysql_fetch_array($sql)) { extract($row); print "<option value='$id'>Heal $petName to $maxhealth</option>"; } print "</select> <input type='submit' value=' Heal Pet '></form>"; } else { print "<p>All of your pets are at full health!<p> <a href='http://www.eaglelegend.com/bat.php?action=battle&newbattle=1'>Click here to battle again!</a>"; } } else { if($aa == 'pet') { $petID = $_POST['pet']; $sql = mysql_query("SELECT * FROM `pets` WHERE `id`='$petID' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if(10 > $MONEY) { print "Sorry you do not have enough money to heal all of your pets!"; } else { while($row = mysql_fetch_array($sql)) { $h = $row["health"]; $m = $row["maxhealth"]; $i = $row["id"]; $query = mysql_query("UPDATE `pets` SET `health`='$m' WHERE `id`='$i' AND `site`=\"$Z\""); if($query) { $total = $total + 1; } else { print mysql_error(); } } $newmoney = $MONEY - 10; $update = mysql_query("UPDATE `members` SET `money`='$newmoney' WHERE `username`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if($update) { print $total . " pets were restored to full health!<p> This cost you 10 dollars!<p> <a href='http://www.eaglelegend.com/bat.php?action=battle&newbattle=1'>Click here to battle again!</a>"; } else { print mysql_error(); } } } if($aa == 'all') { $sql = mysql_query("SELECT * FROM `pets` WHERE `user`='{$_COOKIE['ELv2']}' AND `health` < `maxhealth` AND `site`=\"$Z\""); $num = mysql_num_rows($sql); $cost = $num * 10; if($cost > $MONEY) { print "Sorry you do not have enough money to heal all of your pets!"; } else { while($row = mysql_fetch_array($sql)) { $h = $row["health"]; $m = $row["maxhealth"]; $i = $row["id"]; $query = mysql_query("UPDATE `pets` SET `health`='$m' WHERE `id`='$i' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if($query) { $total = $total + 1; } else { print mysql_error(); } } $newmoney = $MONEY - $cost; $update = mysql_query("UPDATE `members` SET `money`='$newmoney' WHERE `username`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if($update) { print $total . " pets were restored to full health!<p> This cost you $cost dollars!<p> <a href='http://www.eaglelegend.com/bat.php?action=battle&newbattle=1'>Click here to battle again!</a>"; } else { print mysql_error(); } } } } } if($a == 'fight') { $againstpet = $_POST['againstpet']; $attack = $_POST['attack']; $sql2 = mysql_query("SELECT * FROM `battles` WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row2 = mysql_fetch_array($sql2)) { $pet = $row2["pet"]; $weapon1 = $row2["weapon1"]; $weapon2 = $row2["weapon2"]; $weapon3 = $row2["weapon3"]; $lm = $row2["last_message"]; } $sql3 = mysql_query("SELECT * FROM `pets` WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row3 = mysql_fetch_array($sql3)) { $my_health = $row3["health"]; $my_name = $row3["petName"]; } $sql = mysql_query("SELECT * FROM `battle_pets` WHERE `rID`='$againstpet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row = mysql_fetch_array($sql)) { $against_health = $row["health"]; $against_pet = $row["petName"]; } if($against_health < 1 && $my_health < 1) { $sql5 = mysql_query("SELECT * FROM `pets` WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row5 = mysql_fetch_array($sql5)) { $wins = $row5["ties"]; } $wins = $wins + 1; $result = "This battle was a tie!"; $user = $_COOKIE['ELv2']; $against = $against_pet; $userpet = $my_name; $date = date("m/d/y"); mysql_query("INSERT INTO `recent_battles` ( `site`, `user` , `result` , `against` , `userpet` , `id` , `date` ) VALUES ( \"$Z\", '$user', '$result', '$against', '$userpet', '', '$date' );"); $update5 = mysql_query("UPDATE `pets` SET `ties`='$wins' WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); $update55 = mysql_query("UPDATE `battles` SET `last_message`='' WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if($update55 && $update5) { print "<h2>The result was a tie!</h2><p> <a href='http://www.eaglelegend.com/bat.php?action=hospital'>Click here to visit the hospital!</a><p>"; } else { print mysql_error(); } die; } if($against_health < 1 && $my_health > 0) { $sql5 = mysql_query("SELECT * FROM `pets` WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row5 = mysql_fetch_array($sql5)) { $wins = $row5["wins"]; } $wins = $wins + 1; $result = "$my_name won this battle!"; $user = $_COOKIE['ELv2']; $against = $against_pet; $userpet = $my_name; $date = date("m/d/y"); mysql_query("INSERT INTO `recent_battles` ( `site`, `user` , `result` , `against` , `userpet` , `id` , `date` ) VALUES ( \"$Z\", '$user', '$result', '$against', '$userpet', '', '$date' );"); $update5 = mysql_query("UPDATE `pets` SET `wins`='$wins' WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); $update55 = mysql_query("UPDATE `battles` SET `last_message`='' WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if($update55 && $update5) { print "<h2>You won the battle!</h2><p> <a href='http://www.eaglelegend.com/bat.php?action=battle&newbattle=1'>Click here to start a new battle!</a><p> <a href='http://www.eaglelegend.com/bat.php?action=hospital'>Click here to visit the hospital!</a><p>"; } else { print mysql_error(); } die; } if($against_health > 0 && $my_health < 1) { $sql5 = mysql_query("SELECT * FROM `pets` WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row5 = mysql_fetch_array($sql5)) { $wins = $row5["loses"]; } $wins = $wins + 1; $result = "$my_name lost this battle!"; $user = $_COOKIE['ELv2']; $against = $against_pet; $userpet = $my_name; $date = date("m/d/y"); mysql_query("INSERT INTO `recent_battles` ( `site`, `user` , `result` , `against` , `userpet` , `id` , `date` ) VALUES ( \"$site\", '$user', '$result', '$against', '$userpet', '', '$date' );"); $update5 = mysql_query("UPDATE `pets` SET `loses`='$wins' WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); $update55 = mysql_query("UPDATE `battles` SET `last_message`='' WHERE `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); if($update55 && $update5) { print "<h2>You lost the battle!</h2><p> <a href='http://www.eaglelegend.com/bat.php?action=hospital'>Click here to visit the hospital!</a><p>"; } else { print mysql_error(); } die; } if($attack == 'normal') { $damage = rand(2,10); $against_health = $against_health - $damage; $mess .= "You attacked the enemy and caused $damage damage!<br>\n"; } if($attack == 'weapon1') { $sql4 = mysql_query("SELECT * FROM `items` WHERE `id`='$weapon1' AND `type`='weapon' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row4 = mysql_fetch_array($sql4)) { $dam = $row4["damage"]; $nam = $row4["name"]; } $half = ($dam / 2); $half = round($half,0); $newdam = rand($half, $dam); $against_health = $against_health - $newdam; $mess .= "You attacked with a $nam and caused $newdam damage!<br>\n"; } if($attack == 'weapon2') { $sql4 = mysql_query("SELECT * FROM `items` WHERE `id`='$weapon2' AND `type`='weapon' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row4 = mysql_fetch_array($sql4)) { $dam = $row4["damage"]; $nam = $row4["name"]; } $half = ($dam / 2); $half = round($half,0); $newdam = rand($half, $dam); $against_health = $against_health - $newdam; $mess .= "You attacked with a $nam and caused $newdam damage!<br>\n"; } if($attack == 'weapon3') { $sql4 = mysql_query("SELECT * FROM `items` WHERE `id`='$weapon3' AND `type`='weapon' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row4 = mysql_fetch_array($sql4)) { $dam = $row4["damage"]; $nam = $row4["name"]; } $half = ($dam / 2); $half = round($half,0); $newdam = rand($half, $dam); $against_health = $against_health - $newdam; $mess .= "You attacked with a $nam and caused $newdam damage!<br>\n"; } $mydam = rand(1,20); $block = rand(1,2); if($block == 1) { $mydamm = round(($mydam/2),0); $my_health = $my_health - $mydamm; $mess .= "You were attacked. You blocked the attacked but still was hit for $mydamm damage!<br>\n"; } else { $my_health = $my_health - $mydam; $mess .= "You were attacked and you were hit for a total of $mydam damage!<br>\n"; } $me = $mess . $lm; $update = mysql_query("UPDATE `battle_pets` SET `health`='$against_health' WHERE `rID`='$againstpet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); $update2 = mysql_query("UPDATE `pets` SET `health`='$my_health' WHERE `id`='$pet' AND `user`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); $update3 = mysql_query("UPDATE `battles` SET `last_message`=\"$me\" WHERE `user`='{$_COOKIE['ELv2']}'"); if($update && $update2 && $update3) { Header("Location: http://www.eaglelegend.com/bat.php?action=battle&rID=$againstpet"); } else { print mysql_error(); } } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/100318-battle-system-something-wrong/#findComment-512973 Share on other sites More sharing options...
quiettech Posted April 9, 2008 Share Posted April 9, 2008 Only the relevant code please. Is that much to ask? Link to comment https://forums.phpfreaks.com/topic/100318-battle-system-something-wrong/#findComment-512985 Share on other sites More sharing options...
eaglelegend Posted April 9, 2008 Author Share Posted April 9, 2008 meaning? this is the code that you battle on and IE has a problem with attacking on it... it don't do anything when you click attack, however it works fine on firefox etc. Link to comment https://forums.phpfreaks.com/topic/100318-battle-system-something-wrong/#findComment-513003 Share on other sites More sharing options...
quiettech Posted April 9, 2008 Share Posted April 9, 2008 meaning? this is the code that you battle on and IE has a problem with attacking on it... it don't do anything when you click attack, however it works fine on firefox etc. And so you dump the whole thing on us and expect someone to fix it for you, when you didn't even try and find the solution yourself... or at least work the part of the code that may be giving you the problems? The answer to your question is here: http://catb.org/~esr/faqs/smart-questions.html Link to comment https://forums.phpfreaks.com/topic/100318-battle-system-something-wrong/#findComment-513006 Share on other sites More sharing options...
blackcell Posted April 9, 2008 Share Posted April 9, 2008 There is no link to your site? Link to comment https://forums.phpfreaks.com/topic/100318-battle-system-something-wrong/#findComment-513008 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.