Jump to content
MakeWebGames

attack.php prob


DELETE-ME-NOW-

Recommended Posts

I got a attack script here, but its got an error in it that i cannot reapair :( Tried quite a few different things

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home2/mafiakil/public_html/attack.php on line 124

 

<?php

$atkpage=1;
$menuhide=1;
@include_once(DIRNAME(__FILE__) .'/globals.php');
$_GET['ID'] = (isset($_GET['ID']) && !empty($_GET['ID']) && is_numeric($_GET['ID'])) ? abs(@intval($_GET['ID'])) : id_error(); //i used a function for simplicity
function id_error() {
global $h;
echo'You havent selected who to attack.';
exit($h->endpage());
}
//Start some checks
if($_GET['ID'] == $userid) {
echo'Why attack yourself?';
exit($h->endpage());
}
if($ir['maxhp'] < 10) {
echo'You cant attack with no health.';
exit($h->endpage());
}
$enperc = abs(@intval($ir['energy']/$ir['maxenergy']*100));
if($enperc < 25) {
echo'You need atleast 25% of your energy to attack.';
exit($h->endpage());
}
if($ir['jail']) {
echo'You cannot attack someone while in jail.';
exit($h->endpage());
}
if($ir['hospital']) {
echo'You cannot attack someone while in the hospital.';
exit($h->endpage());
}
$them = $db->fetch_row($db->query("SELECT u.*,us.* ".
"FROM `users` AS u ".
"LEFT JOIN `userstats` AS us ON (u.`userid` = us.`userid`) ".
"WHERE (u.`userid` = ". $_GET['ID'] .");"));
if(!$them['userid']) {
echo'This user isnt real.';
exit($h->endpage());
}
if($them['jail']) {
echo'You cant attack someone whose in jail.';
exit($h->endpage());
}
if($them['hospital']) {
echo'You cant attack someone whose in the hospital.';
exit($h->endpage());
}
if($ir['location'] != $them['location']) {
echo'You can\'t attack someone whose in another location.';
exit($h->endpage());
}
//Take away the energy
if($ir['energy'] >= $ir['maxenergy']/4) {
$ir['energy']-=floor($ir['maxenergy']/4);
$myenergy = floor($ir['maxenergy']/4);
$db->query("UPDATE `users` SET `energy` = `energy` -  ". $myenergy ." WHERE (`userid` = ". $userid .");");
$_SESSION['attacklog']='';
$_SESSION['attackdmg']=0;
}
//Get weapons
$pri = $db->query("SELECT * FROM `items` WHERE (`itmid` = ". $ir['equip_primary'] .");"); // $user_class1 & $q0
$sec = $db->query("SELECT * FROM `items` WHERE (`itmid` = ". $ir['equip_armor'] .");"); // $user_class2 & $q1
$sec = $db->fetch_row($sec);
if(!$db->num_rows($pri)) {
$pri = array();
$weapon = "Fists";
$pri['weapon'] = 10;
}
else {
$pri = $db->fetch_row($pri);
$weapon = $pri['itmname'];
}
$tpri = $db->query("SELECT * FROM `items` WHERE (`itmid` IN(". $them['equip_primary'] ."));");
if(!$db->num_rows($tpri)) {
$wep = 'Fists';
}	else {	
$cnt = 0;
while($r = $db->fetch_row($tpri)) {
$enweps[] = $r;
	$cnt++;
}
$weptouse = rand(0, $cnt-1);
$wep = $enweps[$weptouse]['itmname'];
}
//HP stuff
$my = $ir['hp'];
$u = $them['hp'];
$stre = number_format($ir['strength']);
$weps = $pri['weapon'];
$dam = $stre*($weps*100);
echo'<center><big>Fighting '.$them['username'].'</big></center>

You are in a fight with '.$them['username'].'

You come in with your '.$weapon.'. With a strength of '.$dam.' (+'.$weps.'%)
';
//Start the attacks
$shalli = ($ir['agility'] > $them['agility']) ? 1 : 0;
$pri2 = $db->fetch_row($db->query("SELECT * FROM `items` WHERE (`itmid` IN (". $them['equip_primary'] ."));"));
while($my > 0 && $u > 0) {
$damage = (($pri['weapon']*$ir['strength']/($them['guard']/1.5))*(rand(8000,12000)/10000));
$theirdamage = (($enweps[$weptouse]['weapon']*$them['strength']/($ir['guard']/1.5))*(rand(8000,12000)/10000));
$damage = ($damage < 1) ? 1 : $damage;
	$theirdamage = ($theirdamage < 1) ? 1 : $theirdamage;
if($wait == 0) {
$my = $my-$theirdamage;
	echo'<span style="color: red;">'.$them['username'].' Takes their turn to swing at you!</span>
';
		echo $them['username'].' hit you using thier '.$wep.'. It did '. number_format($theirdamage) .' damage. 
';
}	else {
	$wait = 0;
}
if($my > 0) {
			$u = $u-$damage;
				echo '<span style="color: green;">You take a swing at them!</span>
You hit '.$them['username'] .' using your '.$weapon.'. It did '. number_format($damage) .' damage.
';
}
}

if($u <= 0) { 
$loser = $them['userid'];
	$u = 0;
		$_SESSION['attackwon'] = $loser;
			$db->query("UPDATE `users` SET `hp`=0 WHERE (`userid` = ". $loser .");");	
				echo'<hr />
					<span style="font-weight: bold;">What shall you do with '. $them['username'] .' now?</span>

						<form action="attackwon.php?ID=['userid']'. $loser .' method="post"><input type="submit" value="Mug them">

						<form action="attackbeat.php?ID=['userid']'. $loser .' method="post"><input type="submit" value="Hospitalize them">

						<form action="attacktake.php?ID=['userid']'. $loser .' method="post"><input type="submit" value="Leave them">

				';
}
if($my <= 0) {
$winner = $them['userid'];
	$my = 0;
		$_SESSION['attacklost'] = 1;
			$db->query("UPDATE `users` SET `hp`=0 WHERE (`userid` = ". $userid .");");
				echo'<hr /><span style="font-weight: bold;">You lost the fight. In 3 seconds, you will be re-directed. Hold on! <meta http-equiv="refresh" content="3;url=attacklost.php?ID='. $winner .'" />';
}
echo $ennd.$gangs.$bot;
$h->endpage();
?>
Link to comment
Share on other sites

Well i changed something, the 3 lines are now:

 

<form action="attackwon.php?ID=$loser"'. $loser .' method="post"><input type="submit" value="Mug them">

						<form action="attackbeat.php?ID=$loser"'. $loser .' method="post"><input type="submit" value="Hospitalize them">

						<form action="attacktake.php?ID=$loser"'. $loser .' method="post"><input type="submit" value="Leave them">

 

But the URL seems to be going: ...attackwon.php?ID=$loser

Link to comment
Share on other sites

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