Jump to content

Recommended Posts

ok lets see if its just taking too long

will only loop 10 times (test)

 

<?php
include('inc/header.php');

$eID = $enemy->ID;
$uID = (int)$_GET['ID'];

if ($uID > 0)
{
#if called from header!
$enemysql = @mysql_query("SELECT * FROM users WHERE ID = '$eID'"); 
$enemy = @mysql_fetch_object($enemysql);
$usersql = @mysql_query("SELECT * FROM users WHERE ID = '$uID'"); 
$user = @mysql_fetch_object($usersql);

echo "$user->display_name"; echo ' VS. ';echo "$enemy->display_name<br>";
}else{
die("error");
}
if ($enemy->ID == $user->ID)
{
echo' You cant attack yourself!';
}
elseif ($user->hp <= 0)
{
echo ' You are in NO condition to do battle';
}
elseif ($enemy->hp == 0)
{
echo ' Your Enemy Is Already Dead!';
}
elseif ($user->energy <= 4)
{
echo ' Not enough energy!';
}
elseif ($user->attack < $enemy->defense)
{
echo ' You look at your opponent, and wet your pants at his/her strength.  You lose the battle.<br><br><br><br><br><br><br><br><br>';
mysql_query("UPDATE `users` SET hp = 0 WHERE ID = '$user->ID'");
}
elseif ($user->defense > $enemy->attack)
{
echo' Your opponent takes one look at you, and dies in fear<br><br><br><br><br><br><br><br><br>';
mysql_query("UPDATE `users` SET hp = 0 WHERE ID = '$enemy->ID'");
}
else
{
echo' Welcome to the Battle Arena.';

echo "User Start HP:".$user->hp;
echo "<br>Enemy Start HP:".$enemy->hp;
$attacker = ($user->agility > $enemy->agility);

$uHP = $user->hp;
$eHP = $enemy->hp;

//temp values
$edmg = 1;
$udmg = 1;
$count = 10;
while ( $uHP > 0 && $eHP > 0 && ($edmg > 0 || $udmg > 0) && $count>0 )
{
$count = $count - 1;
	echo "User  HP:".$uHP;
	echo "<br>Enemy HP:".$eHP;
	$edmg = 0;
	$udmg = 0;

	if($attacker)
	{
		$edmg = (int)($user->attack - $enemy->defense);
		$eHP = (int)($eHP - edmg);
		echo $user->display_name."  has done $edmg damage against ".$enemy->display_name."<br>"; 
	}else{
		$udmg = (int)($enemy->attack - $user->defense);
		$uHP = (int)($uHP - udmg);
		echo $enemy->display_name." has done $udmg damage against ".$user->display_name."<br>";		
	}
	$attacker = !$attacker;
	flush(); //add
}
if( $uHP == 0)
{
	echo $enemy->display_name." Wins";
}else{
	echo $user->display_name." Wins";
}
mysql_query("UPDATE `users` SET hp =($eHP) WHERE ID = $enemy->ID");
mysql_query("UPDATE `users` SET hp =($uHP) WHERE ID = $user->ID");

}
include('inc/footer.php');
?>

  • Replies 82
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

GOD VS. CatNCobra

Welcome to the Battle Arena.User Start HP:100

Enemy Start HP:100User HP:100

Enemy HP:100CatNCobra has done 1890 damage against GOD

User HP:100

Enemy HP:100GOD has done 268 damage against CatNCobra

User HP:100

Enemy HP:100CatNCobra has done 1890 damage against GOD

User HP:100

Enemy HP:100GOD has done 268 damage against CatNCobra

User HP:100

Enemy HP:100CatNCobra has done 1890 damage against GOD

User HP:100

Enemy HP:100GOD has done 268 damage against CatNCobra

User HP:100

Enemy HP:100CatNCobra has done 1890 damage against GOD

User HP:100

Enemy HP:100GOD has done 268 damage against CatNCobra

User HP:100

Enemy HP:100CatNCobra has done 1890 damage against GOD

User HP:100

Enemy HP:100GOD has done 268 damage against CatNCobra

GOD WinsThis page took 0.000061 seconds to load.

 

 

the HP's arent lowering, why?

aahhhh ahah

 

<?php
include('inc/header.php');

$eID = $enemy->ID;
$uID = (int)$_GET['ID'];

if ($uID > 0)
{
#if called from header!
$enemysql = @mysql_query("SELECT * FROM users WHERE ID = '$eID'"); 
$enemy = @mysql_fetch_object($enemysql);
$usersql = @mysql_query("SELECT * FROM users WHERE ID = '$uID'"); 
$user = @mysql_fetch_object($usersql);

echo "$user->display_name"; echo ' VS. ';echo "$enemy->display_name<br>";
}else{
die("error");
}
if ($enemy->ID == $user->ID)
{
echo' You cant attack yourself!';
}
elseif ($user->hp <= 0)
{
echo ' You are in NO condition to do battle';
}
elseif ($enemy->hp == 0)
{
echo ' Your Enemy Is Already Dead!';
}
elseif ($user->energy <= 4)
{
echo ' Not enough energy!';
}
elseif ($user->attack < $enemy->defense)
{
echo ' You look at your opponent, and wet your pants at his/her strength.  You lose the battle.<br><br><br><br><br><br><br><br><br>';
mysql_query("UPDATE `users` SET hp = 0 WHERE ID = '$user->ID'");
}
elseif ($user->defense > $enemy->attack)
{
echo' Your opponent takes one look at you, and dies in fear<br><br><br><br><br><br><br><br><br>';
mysql_query("UPDATE `users` SET hp = 0 WHERE ID = '$enemy->ID'");
}
else
{
echo' Welcome to the Battle Arena.';

echo "User Start HP:".$user->hp;
echo "<br>Enemy Start HP:".$enemy->hp;
$attacker = ($user->agility > $enemy->agility);

$uHP = $user->hp;
$eHP = $enemy->hp;

//temp values
$edmg = 1;
$udmg = 1;
while ( $uHP > 0 && $eHP > 0 && ($edmg > 0 || $udmg > 0) )
{
	echo "User  HP:".$uHP;
	echo "<br>Enemy HP:".$eHP;
	$edmg = 0;
	$udmg = 0;

	if($attacker)
	{
		$edmg = (int)($user->attack - $enemy->defense);
		$eHP = (int)($eHP - $edmg);
		echo $user->display_name."  has done $edmg damage against ".$enemy->display_name."<br>"; 
	}else{
		$udmg = (int)($enemy->attack - $user->defense);
		$uHP = (int)($uHP - $udmg);
		echo $enemy->display_name." has done $udmg damage against ".$user->display_name."<br>";		
	}
	$attacker = !$attacker;
	flush(); //add
}
if( $uHP == 0)
{
	echo $enemy->display_name." Wins";
}else{
	echo $user->display_name." Wins";
}
mysql_query("UPDATE `users` SET hp =($eHP) WHERE ID = $enemy->ID");
mysql_query("UPDATE `users` SET hp =($uHP) WHERE ID = $user->ID");

}
include('inc/footer.php');
?>

update

if( $uHP == 0)
{
	echo $enemy->display_name." Wins";
}else{
	echo $user->display_name." Wins";
}

to

if( $uHP == 0)
{
	echo $enemy->display_name." Wins";
}elseif( $eHP == 0){
	echo $enemy->display_name." Wins";
}else{
	//neither did any damage (stops inf. loop)
	echo "Attack was unsuccesful";
}

 

 

Also PLEASE don't bump your post unless an hour has passed..

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.