-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
can you comment out #die("end test"); //***************************<---their also make sure the last lines are mysql_query("UPDATE `users` SET hp =({$eHP}) WHERE ID = $enemy->ID"); mysql_query("UPDATE `users` SET hp =({$uHP}) WHERE ID = $user->ID");
-
<?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; while ($uHP > 0 && $eHP > 0) { echo "User HP:".$uHP; echo "<br>Enemy HP:".$eHP; if($attacker) { $dmg = (int)($user->attack - $enemy->defense); $eHP = (int)($eHP - dmg); echo $user->display_name." has done $dmg damage against ".$enemy->display_name."<br>"; }else{ $dmg = (int)($enemy->attack - $user->defense); $uHP = (int)($uHP - dmg); echo $enemy->display_name." has done $dmg damage against ".$user->display_name."<br>"; } $attacker = !$attacker; die("end test"); //***************************<---their 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'); ?> UPDATED
-
quick test while ($uHP > 0 && $eHP > 0) { die("END"); if that works move die("END"); to die("END"); flush(); //add }
-
total guess but i think i cant set the object so i revised it.. <?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; while ($uHP > 0 && $eHP > 0) { echo "User HP:".$uHP; echo "<br>Enemy HP:".$eHP; if($attacker) { $dmg = (int)($user->attack - $enemy->defense); $eHP = (int)($eHP - dmg); echo $user->display_name." has done $dmg damage against ".$enemy->display_name."<br>"; }else{ $dmg = (int)($enemy->attack - $user->defense); $uHP = (int)($uHP - dmg); echo $enemy->display_name." has done $dmg 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'); ?>
-
can't see the problem try full code <?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); while ($user->hp > 0 && $enemy->hp > 0) { echo "User HP:".$user->hp; echo "<br>Enemy HP:".$enemy->hp; if($attacker) { $dmg = (int)($user->attack - $enemy->defense); $enemy->hp = (int)($enemy->hp - dmg); echo $user->display_name." has done $dmg damage against ".$enemy->display_name."<br>"; }else{ $dmg = (int)($enemy->attack - $user->defense); $user->hp = (int)($user->hp - dmg); echo $enemy->display_name." has done $dmg damage against ".$user->display_name."<br>"; } $attacker = !$attacker; flush(); //add } if( $user->hp == 0) { echo $enemy->display_name." Wins"; }else{ echo $user->display_name." Wins"; } mysql_query("UPDATE `users` SET hp =({$enemy->hp}) WHERE ID = $enemy->ID"); mysql_query("UPDATE `users` SET hp =({$user->hp}) WHERE ID = $user->ID"); } include('inc/footer.php'); ?>
-
my boss has a walk around the departments and bugs everyone, i can't be seen on a forum when his around
-
OK, last one (i hope) this is less stress on the server and should display clearly 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); while ($user->hp > 0 && $enemy->hp > 0) { echo "User HP:".$user->hp; echo "<br>Enemy HP:".$enemy->hp; if($attacker) { $dmg = (int)($user->attack - $enemy->defense); $enemy->hp = (int)($enemy->hp - dmg); echo $user->display_name." has done $dmg damage against ".$enemy->display_name."<br>"; }else{ $dmg = (int)($enemy->attack - $user->defense); $user->hp = (int)($user->hp - dmg); echo $enemy->display_name." has done $dmg damage against ".$user->display_name."<br>"; } $attacker = !$attacker; flush(); //add } if( $user->hp == 0) { echo $enemy->display_name." Wins"; }else{ echo $user->display_name." Wins"; } mysql_query("UPDATE `users` SET hp =({$enemy->hp}) WHERE ID = $enemy->ID"); mysql_query("UPDATE `users` SET hp =({$user->hp}) WHERE ID = $user->ID"); } include('inc/footer.php'); ?>
-
that should run so theirs only one winner (isn't possible to tie)
-
Problem with mass mailing (I am not spaming!Honest)
MadTechie replied to oceans's topic in PHP Coding Help
probably why not try it -
indeed forgot a } while ($user->hp > 0 && $enemy->hp > 0) { echo "attack<br>"; //add echo "User HP:".$user->hp; echo "<br>Enemy HP:".$enemy->hp; flush(); //add if($attacker) { $dmg = (int)($user->attack - $enemy->defense); $HPLeft = (int)($enemy->hp - dmg); mysql_query("UPDATE `users` SET hp = ($HPLeft) WHERE ID = $enemy->ID"); echo "$user->display_name has done $dmg damage against $enemy->display_name"; }else{ $dmg = (int)($enemy->attack - $user->defense); $HPLeft = (int)($user->hp - dmg); mysql_query("UPDATE `users` SET hp =($HPLeft) WHERE ID = $user->ID"); echo "$enemy->display_name has done $dmg damage against $user->display_name"; } //added <-**** $attacker = !$attacker; //get new values $enemysql = @mysql_query("SELECT * FROM users WHERE ID = '$uID'"); $enemy = @mysql_fetch_object($enemysql); $usersql = @mysql_query("SELECT * FROM users WHERE ID = '$eID'"); $user = @mysql_fetch_object($usersql); } this is much easier when you have it on your own server and don't have your boss walking around the office
-
404 Not Found, wait a minute and upload the file again.. check the FTP logs it may of failed (had that before)
-
humm sounds like a messed up path, delete the whole line and retype
-
ok i have re-written the while section echo "User Start HP:".$user->hp; echo "<br>Enemy Start HP:".$enemy->hp; $attacker = ($user->agility > $enemy->agility); while ($user->hp > 0 && $enemy->hp > 0) { echo "attack<br>"; //add echo "User HP:".$user->hp; echo "<br>Enemy HP:".$enemy->hp; flush(); //add if($attacker) { $dmg = (int)($user->attack - $enemy->defense); $HPLeft = (int)($enemy->hp - dmg); mysql_query("UPDATE `users` SET hp = ($HPLeft) WHERE ID = $enemy->ID"); echo "$user->display_name has done $dmg damage against $enemy->display_name"; }else{ $dmg = (int)($enemy->attack - $user->defense); $HPLeft = (int)($user->hp - dmg); mysql_query("UPDATE `users` SET hp =($HPLeft) WHERE ID = $user->ID"); echo "$enemy->display_name has done $dmg damage against $user->display_name"; $attacker = !$attacker; //get new values $enemysql = @mysql_query("SELECT * FROM users WHERE ID = '$uID'"); $enemy = @mysql_fetch_object($enemysql); $usersql = @mysql_query("SELECT * FROM users WHERE ID = '$eID'"); $user = @mysql_fetch_object($usersql); } }
-
use code tags please
-
i assume you set the HP's back to a "normal" value please note that the $dmg is set to the HP left and not the amount taken (just want to check its running ok) while update echo "User Start HP:".$user->hp; echo "<br>Enemy Start HP:".$enemy->hp; while ($user->hp > 0 || $enemy->hp > 0) { echo "attack<br>"; //add echo "User HP:".$user->hp; echo "<br>Enemy HP:".$enemy->hp; flush(); //add if ($firstattack == 1) { $dmg = $enemy->hp - ($user->attack - $enemy->defense); mysql_query("UPDATE `users` SET hp = hp-($dmg) WHERE ID = $enemy->ID"); echo "$user->display_name"; echo' has done '; echo "$dmg"; echo ' damage against '; echo "$enemy->display_name"; } if ($firstattack == 2) { $dmg = $user->hp - ($enemy->attack - $user->defense); mysql_query("UPDATE `users` SET hp =($dmg) WHERE ID = $user->ID"); echo "$enemy->display_name"; echo' has done '; echo "$dmg"; echo ' damage against '; echo "$user->display_name"; } if ($firstattack != 1) { $dmg = $enemy->hp - ($user->attack) - ($enemy->defense); mysql_query("UPDATE `users` SET hp = ($dmg) WHERE ID = $enemy->ID"); echo "$user->display_name"; echo' has done '; echo "$dmg"; echo ' damage against '; echo "$enemy->display_name"; } if ($firstattack != 2) { $dmg = $user->hp - ($enemy->attack) - ($user->defense); mysql_query("UPDATE `users` SET hp = ($dmg) WHERE ID = $user->ID"); echo "$enemy->display_name"; echo' has done '; echo "$dmg"; echo ' damage against '; echo "$user->display_name"; } //get new values $enemysql = @mysql_query("SELECT * FROM users WHERE ID = '$uID'"); $enemy = @mysql_fetch_object($enemysql); $usersql = @mysql_query("SELECT * FROM users WHERE ID = '$eID'"); $user = @mysql_fetch_object($usersql); }
-
yep, attach until both were dead,, code has be updated to attack until one dies (their a few updates use the full code above)
-
full updated code <?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.'; if ( $user->agility > $enemy->agility) { $firstattack = '1'; }else{ $firstattack = '2'; } echo "User HP:".$user->hp; echo "<br>Enemy HP:".$enemy->hp; while ($user->hp > 0 || $enemy->hp > 0) { echo "attack<br>"; //add flush(); //add if ($firstattack == 1) { $dmg = ($user->attack) - ($enemy->defense); mysql_query("UPDATE `users` SET hp = hp-($dmg) WHERE ID = $enemy->ID"); echo "$user->display_name"; echo' has done '; echo "$dmg"; echo ' damage against '; echo "$enemy->display_name"; } if ($firstattack == 2) { $dmg = ($enemy->attack) - ($user->defense); mysql_query("UPDATE `users` SET hp = hp-($dmg) WHERE ID = $user->ID"); echo "$enemy->display_name"; echo' has done '; echo "$dmg"; echo ' damage against '; echo "$user->display_name"; } if ($firstattack != 1) { $dmg = ($user->attack) - ($enemy->defense); mysql_query("UPDATE `users` SET hp = hp-($dmg) WHERE ID = $enemy->ID"); echo "$user->display_name"; echo' has done '; echo "$dmg"; echo ' damage against '; echo "$enemy->display_name"; } if ($firstattack != 2) { $dmg = ($enemy->attack) - ($user->defense); mysql_query("UPDATE `users` SET hp = hp-($dmg) WHERE ID = $user->ID"); echo "$enemy->display_name"; echo' has done '; echo "$dmg"; echo ' damage against '; echo "$user->display_name"; } //get new values $enemysql = @mysql_query("SELECT * FROM users WHERE ID = '$uID'"); $enemy = @mysql_fetch_object($enemysql); $usersql = @mysql_query("SELECT * FROM users WHERE ID = '$eID'"); $user = @mysql_fetch_object($usersql); } } include('inc/footer.php'); ?>
-
OK change while ($user->hp > 0 && $enemy->hp > 0) to while ($user->hp > 0 || $enemy->hp > 0)
-
quick update change elseif ($enemy->hp = 0) to elseif ($enemy->hp == 0)
-
unction COPY_RECURSIVE_DIRS($dirsource, $dirdest) { // recursive function to copy // all subdirectories and contents: if(is_dir($dirsource))$dir_handle=opendir($dirsource); mkdir($dirdest."/".$dirsource, 0750); while($file=readdir($dir_handle)) { if($file!="." && $file!="..") { if(!is_dir($dirsource."/".$file)) copy ($dirsource."/".$file, $dirdest."/".$dirsource."/".$file); else COPY_RECURSIVE_DIRS($dirsource."/".$file, $dirdest); } } closedir($dir_handle); return true; }
-
OK lets check for errors in the SQL Part #commented out if called from header! $usersql = @mysql_query("SELECT * FROM users WHERE ID = '$uID'"); $user = @mysql_fetch_object($usersql) or die(mysql_error()); $enemysql = @mysql_query("SELECT * FROM users WHERE ID = '$eID'"); $enemy = @mysql_fetch_object($enemysql) or die(mysql_error()); print_r($enemy);
-
how about we uncomment that code #$usersql = @mysql_query("SELECT * FROM users WHERE ID = '$uID'"); #$user = @mysql_fetch_object($usersql);
-
you sure your looking at the correct user ? (i have to ask)
-
OK <?php include('inc/header.php'); $eID = (int)$_GET['ID']; $uID = $user->ID; if ($uID > 0) { #commented out if called from header! #$usersql = @mysql_query("SELECT * FROM users WHERE ID = '$uID'"); #$user = @mysql_fetch_object($usersql); $enemysql = @mysql_query("SELECT * FROM users WHERE ID = '$eID'"); $enemy = @mysql_fetch_object($enemysql); 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.'; if ( $user->agility > $enemy->agility) { $firstattack = '1'; }else{ $firstattack = '2'; } echo "User HP:".$user->hp; echo "<br>Enemy HP:".$enemy->hp; while ($user->hp > 0 && $enemy->hp > 0) { echo "attack<br>"; //add flush(); //add if ($firstattack == 1) { $dmg = ($user->attack) - ($enemy->defense); mysql_query("UPDATE `users` SET hp = hp-($dmg) WHERE ID = $user->ID"); echo "$user->display_name"; echo' has done '; echo "$dmg"; echo ' damage against '; echo "$enemy->display_name"; } if ($firstattack == 2) { $dmg = ($enemy->attack) - ($user->defense); mysql_query("UPDATE `users` SET hp = hp-($dmg) WHERE ID = $enemy->ID"); echo "$enemy->display_name"; echo' has done '; echo "$dmg"; echo ' damage against '; echo "$user->display_name"; } if ($firstattack != 1) { $dmg = ($user->attack) - ($enemy->defense); mysql_query("UPDATE `users` SET hp = hp-($dmg) WHERE ID = $user->ID"); echo "$user->display_name"; echo' has done '; echo "$dmg"; echo ' damage against '; echo "$enemy->display_name"; } if ($firstattack != 2) { $dmg = ($enemy->attack) - ($user->defense); mysql_query("UPDATE `users` SET hp = hp-($dmg) WHERE ID = $enemy->ID"); echo "$enemy->display_name"; echo' has done '; echo "$dmg"; echo ' damage against '; echo "$user->display_name"; } //get new values $enemysql = @mysql_query("SELECT * FROM users WHERE ID = '$uID'"); $enemy = @mysql_fetch_object($enemysql); $usersql = @mysql_query("SELECT * FROM users WHERE ID = '$eID'"); $user = @mysql_fetch_object($usersql); } } include('inc/footer.php'); ?>