Jump to content
MakeWebGames

Recommended Posts

Posted

can anybody help me find whats wrong with this page it had been working fine for weeks but i went in to do some edits and was talking to someone at the same time and was just highlitng and clicking around while talking and i went back to test it and now all it does when i attack someone is say

Attack

You are in a fight with blah blah.

forgot to mention i tried undoing to the point where i first opened the file but it still doesnt work

 

<?php

$atkpage=1;
include "globals.php";
$user_class=$ir;
$q=$db->query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid={$_GET['ID']}");
$attack_person=$db->fetch_row($q);
$qo=$db->query("SELECT i.* FROM items i   WHERE i.itmid={$user_class['equip_primary']}");
$user_class1=$db->fetch_row($qo);
$q1=$db->query("SELECT i.* FROM items i   WHERE i.itmid={$user_class['equip_armor']}");
$user_class2=$db->fetch_row($q1);
$weapon= "{$user_class1['itmname']}";
if(mysql_num_rows($qo) == 0) {
			$weapon="Fists";
			}
$eq=$db->query("SELECT i.* FROM  items i  WHERE i.itmid IN({$attack_person['equip_primary']})");
		if(mysql_num_rows($eq) == 0) {
			$wep="Fists";
			} else {
			$cnt=0;
			while($r=$db->fetch_row($eq)) {
				$enweps[]=$r;
				$cnt++;
			}
			$weptouse=rand(0,$cnt-1);
			$wep=$enweps[$weptouse]['itmname'];
			}
			$enperc=(int) ($ir['energy']/$ir['maxenergy']*100);
			$gq=$db->query("SELECT * FROM gangs WHERE gangID={$attack_person['gang']}");
$ga=$db->fetch_row($gq);
$error = ($enperc < 25) ? "You need to have at least 20% of your energy if you want to attack someone." : $error;
$error = ($user_class['jail'] > 0) ? "You can't attack someone if you are in jail." : $error;
$error = ($user_class['hospital'] > 0) ? "You can't attack someone if you are in the hospital." : $error;
$error = ($_GET['ID'] == "") ? "You didn't choose someone to attack." : $error;
$error = ($_GET['ID'] == $userid) ? "You can't attack yourself." : $error;
$error = ($attack_person['location'] != $user_class['location']) ? "You must be in the same city as the person you are attacking." : $error;
$error = ($attack_person['username'] == "") ? "That person doesn't exist." : $error;
$error = ($attack_person['hospital'] > 0) ? "You can't attack someone that is in the hospital." : $error;
$error = ($attack_person['jail'] > 0) ? "You can't attack someone that is in jail." : $error;


?><div id="main " style="a"><center><?PHP
if (isset($error)){
echo ($error);

$h->endpage();
		exit;
}
if ($user_class['energy'] >= $user_class['maxenergy']/5) {
		$user_class['energy']-= floor($user_class['maxenergy']/5);
		$me=floor($user_class['maxenergy']/5);
		$db->query("UPDATE users SET energy=energy-(maxenergy/5) WHERE userid=$userid");
		$_SESSION['attacklog']="";
		$_SESSION['attackdmg']=0;
	}

$yourhp = $user_class['hp'];
$theirhp = $attack_person['hp'];
$damagestat = number_format($user_class['strength']) ;
$itstat = $user_class1['weapon'];
$damplu = $damagestat * ($itstat*100);
print "<center><h3>Attack</h3>


You are in a fight with  ".$attack_person['username']." </center>";

$wait = ($user_class['speed'] > $attack_person['speed']) ? 1 : 0;
$hospital = 600;
$qo=$db->query("SELECT i.* FROM  items i  WHERE i.itmid IN({$attack_person['equip_primary']})");
$r1=$db->fetch_row($qo);
$qo=$db->query("SELECT i.* FROM  items i  WHERE i.itmid IN({$attack_person['equip_primary']})");
$r2=$db->fetch_row($qo);
$damage = (int) (($user_class1['weapon']*$user_class['strength']/($attack_person['defense']/1.5)));
$theirdamage = (int) (($r1['weapon']*$attack_person['strength']/($user_class['defense']/1.5)));
while($yourhp > 0 && $theirhp > 0){
$damage = ($damage < 1) ? 1 : $damage;
$theirdamage = ($theirdamage < 1) ? 1 : $theirdamage;
if($wait == 0){
	$yourhp = ($yourhp - $theirdamage);
	echo "<font color=#ff0000>" .$attack_person['username'].  " hit you for "  .number_format($theirdamage).  " damage using their ".$wep.". </font>
";
	$db->query("UPDATE users SET hp=hp-$theirdamage WHERE userid={$ir['userid']}",$c);
} else {
	$wait = 0;
}

if($yourhp > 0) {
$damage = (int) (($user_class1['weapon']*$user_class['strength']/($attack_person['defense']/1.5)));
	$damage = ($damage < 1) ? 1 : $damage;
	$theirhp = $theirhp - $damage;
	$ir['atturn']--;
	echo "<font color=#00ff00>You hit " .$attack_person['username'].  " for " . number_format($damage) . " damage using your ".$weapon.". </font>
";
	$db->query("UPDATE users SET hp=hp-$damage WHERE userid={$attack_person['userid']}",$c);
}

if($theirhp <= 0){ // attacker won
	 $winner = $user_class['ID'];
	 $theirhp = 0;
	 $moneywon = floor($attack_person['money'] /10);
	 $expwon = 0-(100 * ($user_class['level'] - $attack_person['level']));
	 $expwon = ($expwon < 0) ? 0 : $expwon;
	 $expwon = ($expwon > 10000) ? 10000 : $expwon;
	 $hosptime=20;

	 $hospreason = "Attacked by {$user_class['username']}.";
	 $newexp = $expwon + $user_class['exp'];
	 $yourhp = $yourhp;
	 $newmoney = $user_class['money'] + $moneywon;
	 $result = $db->query("UPDATE `users` SET `exp` = '".$newexp."', tkills=tkills+1, money = '".$newmoney."' WHERE `userid`='".$user_class['userid']."'");
	 $newmoney = $attack_person['money'] - $moneywon;
	 $result = $db->query("UPDATE `users` SET `hp`= 1, `hospital` ='".$hosptime."', tdeaths=tdeaths+1, `money` = '".$newmoney."', `hospreason` = '".$hospreason."' WHERE `userid`='".$attack_person['userid']."'");
	 $atklog=mysql_escape_string($_SESSION['attacklog']);
$db->query("INSERT INTO attacklogs VALUES('',".$user_class['userid'].",".$attack_person['userid'].",'won',unix_timestamp(),".$moneywon.",'$atklog');");
	 event_add($attack_person['userid'], "".$user_class['username']." beat you up and stole $".$moneywon.". They gained $expwon EXP");
	 $final ="<center>You hospitalized "  .$attack_person['username'].  ".
You gain $expwon exp and stole $".$moneywon." from "  .$attack_person['username'].  ".
</center>";
	$pwnd ="";
$warq=$db->query("SELECT * FROM gangwars WHERE (warDECLARER={$user_class['gang']} AND warDECLARED={$attack_person['gang']}) OR (warDECLARED={$user_class['gang']} AND warDECLARER={$attack_person['gang']})");
if ($db->num_rows($warq) > 0)
{
$war=$db->fetch_row($warq);
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT-2 WHERE gangID={$attack_person['gang']}");
$ga['gangRESPECT']-=2;
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+2 WHERE gangID={$user_class['gang']}");
$pwnd  ="
You earnt 2 respect for your gang!";
	}
	if ($ga['gangRESPECT']<=0 && $attack_person['gang'])
{
$db->query("UPDATE users SET gang=0 WHERE gang={$attack_person['gang']}");

$db->query("DELETE FROM gangs WHERE gangRESPECT<='0'");
$db->query("DELETE FROM gangwars WHERE warDECLARER={$ga['gangID']} or warDECLARED={$ga['gangID']}");
}
$bots=array(96,94,5,97,98,99,142,138,138,140,141,146,143,144,145);//Your Battle Tent Bots
$moneys=array(96 =>5000,94 =>5000,5 => 500,97 => 5000, 98 => 500, 99 => 10000, 142 => 1500,138 =>10000,140 =>10000,141 =>10000,146 =>20000,143 =>15000,144 =>15000,145 =>15000);
if(in_array($attack_person['userid'],$bots))
{
$gain=$moneys[$attack_person['userid']];
$db->query("UPDATE users SET money=money+$gain WHERE userid=$userid",$c);
$finalbot ="";
$finalbot ="

Congrats, for beating the Challenge Bot {$attack_person['username']}, you have earnt \$$gain!";

}
}

if($yourhp <= 0){ // defender won
	 $winner = $attack_person['ID'];
	 $yourhp = 0;
	 $theirhp = $theirhp;
	 $moneywon = floor($user_class['money'] /10);
	 $expwon = 0-(100 * ($attack_person['level'] - $user_class['level']));
	 $expwon = ($expwon < 0) ? 0 : $expwon;
	 $expwon = ($expwon > 10000) ? 10000 : $expwon;
	 $hosplost = "Lost to ".$attack_person['username']."" ;
	 $hosptime=20;
	 $newexp = $expwon + $attack_person['exp'];
	 $newmoney = $attack_person['money'] + $moneywon;
	 $result = $db->query("UPDATE `users` SET `exp` = '".$newexp."', tkills=tkills+1, money = '".$newmoney."' WHERE `userid`='".$attack_person['userid']."'");
	 $newmoney = $user_class['money'] - $moneywon;
	 $result = $db->query("UPDATE `users` SET `hp`= 1,`hospital` ='".$hosptime."' , tdeaths=tdeaths+1, `money` = '".$newmoney."', `hospreason` = '".$hosplost."' WHERE `userid`='".$user_class['userid']."'");
	  $atklog=mysql_escape_string($_SESSION['attacklog']);
$db->query("INSERT INTO attacklogs VALUES('',".$attack_person['userid'].",".$user_class['userid'].",'won',unix_timestamp(),".$moneywon.",'$atklog');");
	 event_add($attack_person['userid'], "".$user_class['username']." attacked you and lost. You stole $".$moneywon.". You gained $expwon EXP!");
	 $final = "$attack_person2 beat you and stole \$$moneywon from you. And gained $expwon EXP!";

$pwnd ="";
$warq=$db->query("SELECT * FROM gangwars WHERE (warDECLARER={$user_class['gang']} AND warDECLARED={$attack_person['gang']}) OR (warDECLARED={$user_class['gang']} AND warDECLARER={$attack_person['gang']})");
if ($db->num_rows($warq) > 0)
{
$war=$db->fetch_row($warq);
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+1 WHERE gangID={$attack_person['gang']}");
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT-1 WHERE gangID={$user_class['gang']}");
$pwnd ="
You lost 1 respect for your gang!";
}
}
}
echo "$final";
echo "$pwnd ";
echo "$finalbot";
$h->endpage();
?></center></div>
Posted
lol..this could be the reason why...

last line :

?></center></div>

 

but i could be wrong..

You should remove what he mentioned... clean the code up a bit.

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.   Paste as plain text instead

  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...