I was just wounderig if any one would look at this and see if you can find any errors, the script does not run, Contact me on burnside360@hotmail.co.uk if you can find any thing wrong with it please.
I think has some thing to do with this bit here cos im getting the stop messing arround error its been doing my head in for 2 weeks now :
if($_GET['action'] == attack)
{
if($info
< 2)
{
echo "You do not have enough energy to battle.";
echo "
<center>[<a href=fight.php>Back[/url]]</center>";
}elseif ($info[hp]<1){
echo "You must be alive to battle";
echo "
<center>[<a href=fight.php>Back[/url]]</center>";
}else
{
$resul = mysql_query("SELECT * FROM enemies WHERE id='$id'");
if(!@mysql_num_rows($resul)){
echo "Stop messing around !";
echo "
<center>[<a href=fight.php?action=fight>Back[/url]]</center>";
}else{
$enemyinfo = mysql_fetch_array($resul);
mysql_free_result($resul);
<?php include("top.php");
mysql_connect("", "", "") or die(mysql_error());
mysql_select_db("") or die(mysql_error());
//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{ header("Location: index.php");
}
else
{
if($_GET['action'] == "")
{
echo "Welcome to the Battle Arena, where you can test your strength against NPC's.<p>";
$select_mon = mysql_query("SELECT * from enemies where enemytype='normal' order by id");
echo "<b>Normal Monsters</b><br>";
while($nmon = mysql_fetch_array($select_mon))
{
echo "<table width=100%><tr><td width=15%><img src=\"image/ene/$nmon[image].jpg\" border=0></td><td width=30%><a href=fight1.php?action=attack&id=$nmon[id]>$nmon[name]</a></td><td width=15%>Level $nmon[level]</td><td width=15%>$nmon[hp] HP</td><td width=40%>($nmon[enemiesleft] left)</td></tr></table>";
}
$select_mon2 = mysql_query("select * from enemies where enemytype='special' order by id");
echo "<p><b>Special Monsters</b>";
while($nmon2 = mysql_fetch_array($select_mon2))
{
echo "<table width=100%><tr><td width=30%><a href=fight1.php?action=attack&id=$nmon2[id]>$nmon2[name]</a></td><td width=15%>Level $nmon2[level]</td><td width=15%>$nmon2[hp] HP</td><td width=55%>($nmon2[enemiesleft] left)</td></tr></table>";
}
$select_mon3 = mysql_query("select * from enemies where enemytype='Boss' order by id");
echo "<p><b>Boss</b>";
while($nmon3 = mysql_fetch_array($select_mon3))
{
echo "<table width=100%><tr><td width=30%><a href=fight1.php?action=attack&id=$nmon3[id]>$nmon3[name]</a></td><td width=15%>Level $nmon3[level]</td><td width=15%>$nmon3[hp] HP</td><td width=55%>($nmon3[enemiesleft] left)</td></tr></table>";
}
}
if($_GET['action'] == attack)
{
if($info
< 2)
{
echo "You do not have enough energy to battle.";
echo "<br><br><center>[<a href=fight.php>Back</a>]</center>";
}elseif ($info[hp]<1){
echo "You must be alive to battle";
echo "<br><br><center>[<a href=fight.php>Back</a>]</center>";
}else
{
$resul = mysql_query("SELECT * FROM enemies WHERE id='$id'");
if(!@mysql_num_rows($resul)){
echo "Stop messing around !";
echo "<br><br><center>[<a href=fight.php?action=fight>Back</a>]</center>";
}else{
$enemyinfo = mysql_fetch_array($resul);
mysql_free_result($resul);
$resul = mysql_query("SELECT * FROM pequipment WHERE equipped='Y' AND userid='$info[id]' AND type='weapon'");
$wep = mysql_fetch_array($resul);
$sel_barmor = mysql_query("select * from pequipment where userid='$info[id]' AND equipped='Y' AND type='barmor'");
$bar = mysql_fetch_array($sel_barmor);
$sel_helm = mysql_query("select * from pequipment where userid='$info[id]' AND equipped='Y' AND type='helm'");
$hel = mysql_fetch_array($sel_helm);
$sel_gloves = mysql_query("select * from pequipment where userid='$info[id]' AND equipped='Y' AND type='gloves'");
$glo = mysql_fetch_array($sel_gloves);
$sel_boots = mysql_query("select * from pequipment where userid='$info[id]' AND equipped='Y' AND type='boots'");
$boo = mysql_fetch_array($sel_boots);
$armor = $bar[effect] + $bar[effect] + $hel[effect] + $glo[effect] + $boo[effect];
$p1hp = $info[hp_left];
$p2hp = $enemyinfo[hp];
// this adds some random values to stats, making battles not the same EVERYTIME! -
srand((double)microtime()*1000000);
$valueofchang2 = (rand(25,35)/10);
$valueofchang1 = (rand(25,35)/10);
$moreorless = rand(1,2);
if($boo[type_id] == "25"){$a1glmod = 10;}
$pagl=$info[agility] + $a1glmod; // Sandals code
$eagl=$enemyinfo[agility] + 0; // Sandals code
$pturn=$pagl;
$pturnmod=$pagl/$valueofchang2;
$oturn=$eagl;
$oturnmod=$eagl/$valueofchang1;
$clock=0;
/*
if($info[id] == 101){
$criticalhit = rand(0,200);
$armor = $armor / 2;
}*/
////
do
{
if ($pturn>$oturn){$oturn=$oturn+$oturnmod;$clock++;
srand((double)microtime()*1000000);
$criticalhit = rand(0,100);
if($info[lucky] == 1){
$criticalhit = rand(0,95);
}
if($info[lucky] == 2){
$criticalhit = rand(0,90);
}
if($info[lucky] == 3){
$criticalhit = rand(0,85);
}
if($info[lucky] == 4){
$criticalhit = rand(0,80);
}
if($info[lucky] == 5){
$criticalhit = rand(0,75);
}
if($info[lucky] > 5){
$criticalhit = rand(0,70);
}
$armoreff = rand(1,$enemyinfo[armoreff]);
if($criticalhit == "33")
{
$dmg = round(rand($wep[effect],$wep[effect2]) * 3 + $info[strength] - $armoreff);
}
else
{
$dmg = round(rand($wep[effect],$wep[effect2]) + $info[strength] - $armoreff);
}
// Removes "the" in a weapon name.
$wepyname = $wep[name];
$wepyname = eregi_replace("the ","",$wepyname);
$wepyname = eregi_replace("THE ","",$wepyname);
if($dmg <= "0")
{
// different missing messages
srand((double)microtime()*1000000);
$missingmess = rand(1,3);
if($missingmess==1){
$missmess1 = "You swung at the";
$missmess2 = "but you missed!";
}
elseif($missingmess==2){
$missmess1 = "You charged at the";
$missmess2 = "but you tripped!";
}
elseif($missingmess==3){
$missmess1 = "You hit the";
$missmess2 = "but the <font color=lightblue>$enemyinfo[name]</font> deflects the attack!";
};
echo "<b>$clock:</b> $missmess1 <font color=lightblue>$enemyinfo[name]</font> with your <font color=lightgreen>$wepyname</font>, $missmess2 ($p2hp left)<br>";}
else
{
$p2hp -= $dmg;
if($p2hp < "0")
{
$p2hp = 0;
}
//Various weapon types say different things -
$showcrit = "<font color=crimson> CRITICAL HIT!</font>";
if($wep[type_id] > 0 && $wep[type_id] < 11){ // First 10 weps
echo "<b>$clock:</b> You attacked the <font color=lightblue>$enemyinfo[name]</font> with your <font color=lightgreen>$wepyname</font> for <font color=lightblue>$dmg</font> damage! ($p2hp left) "; if($criticalhit == "33") { echo "$showcrit"; } echo "<br>";
}elseif($wep[type_id] > 19 && $wep[type_id] < 25) { // Small bow to Streamline Bow
echo "<b>$clock:</b> You shoot arrows at the <font color=lightblue>$enemyinfo[name]</font> with your <font color=lightgreen>$wepyname</font> doing <font color=lightblue>$dmg</font> damage! ($p2hp left) "; if($criticalhit == "33") { echo "$showcrit"; } echo "<br>";
}
elseif($wep[type_id] > 11 && $wep[type_id] < 19){ // Next 10 etc weapons
echo "<b>$clock:</b> You Attack with might at the <font color=lightblue>$enemyinfo[name]</font> with your <font color=lightgreen>$wepyname</font> for <font color=lightblue>$dmg</font> damage! ($p2hp left) "; if($criticalhit == "33") { echo "$showcrit"; } echo "<br>";
}
elseif($wep[type_id] > 49 && $wep[type_id] < 54){ //Myth weps
echo "<b>$clock:</b> Your soul releases anger upon the <font color=lightblue>$enemyinfo[name]</font>, your <font color=lightgreen>$wepyname</font> harnesses it and deals <font color=lightblue>$dmg</font> damage! ($p2hp left) "; if($criticalhit == "33") { echo "$showcrit"; } echo "<br>";
}
elseif($wep[type_id] == 0){ //No weapon
echo "<b>$clock:</b> You attacked the <font color=lightblue>$enemyinfo[name]</font> with your <font color=lightgreen>Fists</font> for <font color=lightblue>$dmg</font> damage! ($p2hp left) "; if($criticalhit == "33") { echo "$showcrit"; } echo "<br>";
}
if($p2hp <= 0)
{
$exp = rand($enemyinfo[exp],$enemyinfo[exp2]);
if($info[level] > 0 && $info[level] < 100){
$exp = $exp * 0.99;
}
if($info[level] > 99 && $info[level] < 200){
$exp = $exp * 0.8;
}
if($info[level] > 199){
$exp = $exp * 0.7;
}
$exp = ceil($exp);
$gold = rand($enemyinfo[gold],$enemyinfo[gold2]);
if(!$wep){}else{
if( $wep[exp] > -100){$wepexpmod = $wep[exp];}else{$wepexpmod = -100;}
if( $wep[gold] > -100){$wepgoldmod = $wep[gold];}else{$wepgoldmod = -100;}
}
$exp5 = ($exp / 100) * $wepexpmod;
$exp2 = ceil($exp5);
$gold5 = ($gold / 100) * $wepgoldmod;
$gold2 = ceil($gold5);
$gold4 = $gold2 + $gold + $info[gold];
$exp4 = $exp2 + $exp + $info[exp];
$clanexp = $exp + $exp2;
if($info[clan] !== "0")
{
$clanres3 = mysql_query("SELECT * FROM clans WHERE id='$info[clan]'");
$clanss = mysql_fetch_array($clanres3);
$newclanexp = $clanss[exp] + $clanexp;
$clanexpupdate5 = mysql_query("update clans set exp='$newclanexp' where id='$info[clan]'");
$clandonupd = mysql_query("update users set clan_exp=clan_exp+$clanexp where id='$info[id]'");
if($newclanexp >= "$clanss[exp_lvl]")
{
$newlvl2 = $clanss[level] + 1;
$newexp2 = $newlvl2 * $newlvl2 * 1000;
$updateclannews = mysql_query("Insert into usernews (id,user,text,time) values ('','C$info[clan]','<b>$time</b> Clan leveled up! Now level $newlvl2. (<a href=view.php?id=$info[id]>$info[username]</a>)','$realtime')");
if($clanss[levelreward] <= "$clanss[gold]") {
$richmore = $info[gold]+$clanss[levelreward];
mysql_query("update users set gold='$richmore' where id='$info[id]'");
$reget = mysql_query("Select * from users where id='$info[id]'");
$info = mysql_fetch_array($reget);
$updateclan55 = mysql_query("update clans set level='$newlvl2', exp='0', exp_lvl='$newexp2', gold=gold-$clanss[levelreward] where id=$info[clan]");
$clanchanger1 = mysql_query("update clans set power=power+1000 where id='$info[clan]'");
$guychanger1 = mysql_query("update users set clan_infl=clan_infl+1000 where id='$info[id]'");
echo "<br><font color=orange>You gained your clan a level! (+1000 influence) You have been rewarded $clanss[levelreward] gold!</font>";
}else{
$reget = mysql_query("Select * from users where id='$info[id]'");
$info = mysql_fetch_array($reget);
$clanchanger1 = mysql_query("update clans set power=power+1000 where id='$info[clan]'");
$guychanger1 = mysql_query("update users set clan_infl=clan_infl+1000 where id='$info[id]'");
$updateclan55 = mysql_query("update clans set level='$newlvl2', exp='0', exp_lvl='$newexp2' where id=$info[clan]");
echo "<br><font color=orange>You gained your clan a level! (+1000 influence) You should have been rewarded $clanss[levelreward] gold but they dont have enough clan funds!</font>";
}
}
}
$newgold = $info[gold] + $gold;
$newexp = $info[exp] + $exp;
$batwon = $info[battleswon] + 1;
$eleft = $enemyinfo[enemiesleft] - 1;
$fights = $info[energy] - 2;
$updatedm = mysql_query("update enemies set enemiesleft='$eleft' where id='$id'");
$updatedbstats = mysql_query("update users set energy='$fights', exp='$exp4', gold='$gold4', battleswon='$batwon' where id='$info[id]'");
echo "<br>You have killed the <font color=lightblue>$enemyinfo[name]</font>!<br>You gained <font color=silver>$exp</font> experience and <font color=gold>$gold</font> gold!<br>";
echo "The magic from your weapon earned you an extra <font color=silver>$exp2</font> experience and <font color=gold>$gold2</font> gold!<br>";
$randex= rand(1,50);
$randex2 = rand(1,30);
if($enemyinfo[name] == "Shaman") {
$emblem = rand(1,5000);
if($emblem == 5000) {
echo "You found a <font color=red>Shamans Emblem</font> on the Shaman's corpse!!!<br>";
$insert_emblem = mysql_query("update users set emblems=emblems+1 where id='$info[id]'");
}
}
if($randex2 == "23")
{
echo "You managed to find a <font color=yellow>key</font> on your enemies corpse!<br>";
$insert_key = mysql_query("update users set pkeys=pkeys+1 where id='$info[id]'");
}
$chckdraw = mysql_query("select * from gemdb where id = '$info[id]'");
$drawstring = mysql_fetch_array($chckdraw);
if($drawstring){ $getgem = 1;} else { $getgem = 0; }
if($randex2 == "20")
{
echo "You managed to find an <font color=green>Emerald</font> on your enemies corpse!<br>";
if($getgem = 1){
$insert_key = mysql_query("update gemdb set emeralds=emeralds+1 where id='$info[id]'");
}else{echo "but you have nothing to hold it with! So you leave it there...<br>";}
}
if($randex == "1")
{
if($enemyinfo[enemytype] == "special")
{
echo "You managed to find 3 <font color=aqua>crystals</font> on the enemies corpse!";
$crys = $drawstring[crystals] + 3;
if($getgem = 1){
$insert_crystal = mysql_query("update gemdb set crystals='$crys' where id='$info[id]'");
}else{echo "but you have nothing to hold it with! So you leave it there...<br>";}
}
}
elseif($randex > "35")
{
echo "You managed to find a <font color=aqua>crystal</font> on your enemies corpse!";
$crys = $drawstring[crystals] + 1;
if($getgem = 1){
$insert_crystal = mysql_query("update gemdb set crystals='$crys' where id='$info[id]'");
}else{echo "but you have nothing to hold it with! So you leave it there...<br>";}
}
elseif($randex == "3")
{
echo "You managed to find a <font color=pink>diamond</font> on your enemies corpse!";
if($getgem = 1){
$crys = $drawstring[diamonds] + 1;
$insert_crystal = mysql_query("update gemdb set diamonds='$crys' where id='$info[id]'");
}else{echo "but you have nothing to hold it with! So you leave it there...<br>";}
}
else
{
echo "After searching the corpse, you found nothing to pick up!";
}
break;
}
}
}
if ($oturn>$pturn){$pturn=$pturn+$pturnmod;$clock++;
$criticalhit2 = rand(0,100);
$armoreff2 = rand(0,$armor);
if($criticalhit2 == "66")
{
$dmg2 = round(rand($enemyinfo[weaponeff],$enemyinfo[weaponeff2]) * 3 + $enemyinfo[strength] - $armoreff2);
}
else
{
$dmg2 = round(rand($enemyinfo[weaponeff],$enemyinfo[weaponeff2]) + $enemyinfo[strength] - $armoreff2);
}
if($dmg2 <= "0")
{
echo "<b>$clock:</b> The <font color=lightblue>$enemyinfo[name]</font> swung at you, but missed! ($p1hp left)<br>";
}
else
{
$p1hp -= $dmg2;
if($p1hp < "0")
{
$p1hp = 0;
}
echo "<b>$clock:</b> The <font color=lightblue>$enemyinfo[name]</font> attacked you with its $enemyinfo[weaponname] for <font color=lightblue>$dmg2</font> damage! ($p1hp left)<br>";
if($p1hp <= 0)
{
echo "<font color=Red>You have been killed by the </font><font color=lightblue>$enemyinfo[name]</font><font color=red>!</font>";
$batlost = $info[battleslost] + 1;
$fights = $info[energy] - 2;
$updatedbstats2 = mysql_query("update users set energy='$fights', battleslost='$batlost' where id='$info[id]'");
break;
}
}
}
if ($oturn==$pturn)
{$clock++;
echo "<b>$clock:</b> Both characters rest<br>";
$pturn=$pturn+$pturnmod;
$oturn=$oturn+$oturnmod;
}
if ($clock>99)
{
echo "Battle timed out.";
$update = mysql_query("update users set energy=energy-2 where id='$info[id]'");
exit;
}
} while($p1hp or $p2hp > 0 && $clock<100);
echo "<p>[<a href=fight.php?action=attack&id=$id>Fight Again</a>]";
if($exp4 >= "$info[exp_lvl]")
{
$newlvl = $info[level] + 1;
if ($newlevel > 100 && $newlevel < 200){ // EXPERIANCES GETS HARDER AS YOU LEVEL
$newexp = $newlvl * $newlvl * 200;} // If under 100, then x 150
elseif($newlevel > 199 && $newlevel < 300){ // If over 100 then x 200
$newexp = $newlvl * $newlvl * 300;} // If over 200 then x 300
else{$newexp = $newlvl * $newlvl * 150;} // over 300 not added as yet.
$newhp1 = $newlvl * 2;
$newhp = $newhp = $info[hp] + $newhp1;
$newstr = $info[strength] + 1;
$newdef = $info[agility] + 1;
$updatedbstats3 = mysql_query("update users set hp='$newhp', hp_left='$newhp', strength='$newstr', agility='$newdef', level='$newlvl', exp='0', exp_lvl='$newexp' where id='$info[id]'");
echo "<br><font color=lightgreen>You gained a level!</font>";
}
}
}
}
}
}
include("bottom.php");
}
?>