Jump to content

Recommended Posts

is this look good? its supposed to stop another script on the same page if both variables dont match

 

$UserSL = $UserS['location']
$NPCL = $NPC['location']
if($NPCL = Home) {echo "User is at thier house! <br><br>";
exit();
}
if($UserSL = Home) {echo "You must be in the city to fight! <br><br>";
exit();
}

Link to comment
https://forums.phpfreaks.com/topic/140691-is-this-done-right/
Share on other sites

$UserSL = $UserS['location']; // syntax error need sem-colon
$NPCL = $NPC['location']; // syntax error need sem-colon
if($NPCL == "Home") {echo "User is at thier house! <br><br>";
exit();
}
if($UserSL == "Home") {echo "You must be in the city to fight! <br><br>";
exit();
}

echo "Begin the fight!";

 

Should at least echo begin the fight.

Link to comment
https://forums.phpfreaks.com/topic/140691-is-this-done-right/#findComment-736495
Share on other sites

the script is working but its not doing what i need it to do. im trying to get it to verifiy that both variables for both players are both equal to "Forest Of Death" and if either players location variable is not set to "Forest Of Death" i dont want the rest of the script to run here is the whole code

 

$UserSL = $UserS['location']; // syntax error need sem-colon
$NPCL = $NPC['location']; // syntax error need sem-colon
if($NPCL == "Home") {echo "User is at thier house! <br><br>";
exit();
}
if($UserSL == "Home") {echo "You must be in the city to fight! <br><br>";
exit();
}

echo "Begin the fight!";

if(!isset($_GET['user']))
{
echo "You have not selected a user to fight!<br><br>";
$NPCS = mysql_query("SELECT * FROM `users`");
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 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 have lost";
  $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'
  WHERE username='$username'");

  exit();
  }
}
}

?>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/140691-is-this-done-right/#findComment-736511
Share on other sites

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.