Jump to content

help


oldspicelong

Recommended Posts

I need help editing a script i created months ago so that when playerA attacks playerB and PlayerB's 'rank' variable is equal to 'Kage' and the variable 'village' is the same for both players that if playerA defeats PlayerB then playerA's 'rank' variable is then set to 'Kage' and playerB's 'rank' variable is set to 'Academy student'

here is my current script that im using

 


<?

$username = $_COOKIE['ID_my_site']; 
mysql_query("UPDATE `users` SET `location` = 'Forest Of Death' WHERE username = '$username'") or die(mysql_error());
echo "<center>You have entered the Forest of Death. death lurks around every corner, every tree, every face... " . "</center>";




if(!isset($_GET['user']))
{
echo "You have not selected a user to fight!<br><br>";
$NPCS = mysql_query("SELECT * FROM `users` WHERE location='Forest Of Death'");
while($Show = mysql_fetch_array($NPCS))
  {
  echo "<a href=\"AttackPlayer.php? Action=Attack&user=" . $Show['username'] . "\">" . $Show['username'] . "</a><br>";
  }
exit();
}
$NPC = mysql_escape_string($_GET['user']);
$username = $_COOKIE['ID_my_site'];
if($_GET[Action] = Attack)
{
if($username == $NPC){echo "You cannot fight yourself! <br><br>"; exit();}
$UserS = mysql_query("SELECT * FROM `users` WHERE username='$username'");
$UserS = mysql_fetch_array($UserS);
$UserH = $UserS['health'];
if($UserH == '0'){echo "You have no health you cannot fight! <br><br>"; exit();}
$UserA = $UserS['skill'];
$UserK = $UserS['kills'] +1;

$UserSkill = $UserS['skill'];
$UserA *= .1;
$NPCS = mysql_query("SELECT * FROM `users` WHERE username='$NPC'");
$NPCS = mysql_fetch_array($NPCS);
$NPCH = $NPCS['health'];
if($NPCH == '0'){echo "You cannot attack someone that has no health! <br><br>"; exit();}
$NPCA = $NPCS['skill'];
$NPCSkill = $NPCS['skill'];
$NPCA *= .1;


$run = 1;
While($run > 0){
$NPCH -= $UserA;
if($NPCH <= 0)
  {
  $xp = $NPCSkill * .020;
  echo "You win and have gained " . $xp . " skill from " . $NPC . "";
  $UserA = $UserSkill + $xp;
  mysql_query("UPDATE `users`
  SET '$NPC'=username,skill='$UserA', health='$UserH', kills='$UserK'
  WHERE username='$username'");

  $NPCA = $NPCSkill * .97;
  mysql_query("UPDATE `users`
  SET skill='$NPCA', health='0'
  WHERE username='$NPC'");

  exit();
  }

$UserH -= $NPCA;
if($UserH <= 0)
  {
  echo "You wake up a few hours later and realized that you have lost the battle and that all of your gold is missing";
  $xp = $UserSkill * .030;
  $UserA = $NPCSkill + $xp;
  mysql_query("UPDATE `users`
  SET skill='$UserA', health='$UserH', kill='kill +1'
  WHERE username='$NPC'");

  $UserA = $UserSkill * .97;
  mysql_query("UPDATE `users`
  SET skill='$UserA', health='0', gold='0'
  WHERE username='$username'");

  exit();
  }
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/171870-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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