Page 1 of 1

inn.php fixed error

Posted: Sun Mar 13, 2011 9:03 pm
by 62896dude
Hey there everybody,

Just a heads up, unless something went wrong with my script, halls only included healing hpoints in his inn.php (nothing against you halls, i wouldn't have figured this out without you)

so, if you want your inn.php to heal the player's spoints as well, here is the updated source code, a few very simple additions to the script:

inn.php

Code: Select all

<?php
include_once 'connect.php';
 session_start();
   include_once 'logo.php';
   ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$pllocation=$playerinfo3['location'];
$maxhp = $playerinfo3['maxhp'];
$maxsp = $playerinfo3['maxspoints'];
include_once 'statpanel.php';
?>
</div>
<div id="table">
 <?php 
if (isset($_POST['price']))
{
  $price = $_POST['price'];
   $exitgreet = $_POST['exitgreet'];
if ($playerinfo3['gold'] < $price)
{
 echo "You do not have enough Gold to stay at this inn!";
  echo "<center><a href='index.php'>Go Back</center>";
  exit;
}
echo "<center>" . $exitgreet . "<br><br>";
echo "<A href='index.php'>Leave Inn</a></center>";

$updateplayerhp="update players set hpoints='$maxhp' where name='$player'";
 mysql_query($updateplayerhp) or die("Could not update player");
$updateplayersp="update players set spoints='$maxsp' where name='$player'";
 mysql_query($updateplayersp) or die("Could not update player again");
exit;
}
else
{

 $inninfo="SELECT * from locations where location='$pllocation' AND type='inn'";
$inninfo2=mysql_query($inninfo) or die("could not get player stats!");
$inninfo3=mysql_fetch_array($inninfo2);
 
 echo "<center>" . $inninfo3['greeting'] . "<br>";
 echo "Would you like to stay?<br></center>";
 }
  ?>
  <center>
  <form method ="post" action="inn.php">
  <input type="submit" value="Yes"><br /><br />
  <input type="hidden" name="price" value="<?php echo $inninfo3['price'];?>"  />
   <input type="hidden" name="exitgreet" value="<?php echo $inninfo3['exitgreet'];?>" />
   </form>
   <form action="index.php">
  <input type="submit" value="No">
  </form></center>
  </div>
Please let me know if this helped!

Re: inn.php fixed error

Posted: Mon Mar 14, 2011 7:20 pm
by hallsofvallhalla
thanks for adding this. This will help people. I think my initial idea was to have a separate place like baths where players have to gain spoints back.

Re: inn.php fixed error

Posted: Mon Mar 14, 2011 9:52 pm
by 62896dude
No problem! And I think thats a goid idea to have a seperate sp points healing place, it's really a matter of preference

Re: inn.php fixed error

Posted: Tue Mar 15, 2011 8:56 pm
by Huezzer
Hey, Thanks for this post. I've just got some wonderings about it, Is it possbile to add that peoples can't go into the Inn to often? I mean if you lose a battle you have to use your inventory things to make you on feets again. Hope you know what I mean.

Like 20 minutes until next time you can visit the inkeeper, or atleast get full hp and spoints. :P
Like any time counter( how to add?)

-Thank you!

Huezzer.

Re: inn.php fixed error

Posted: Tue Mar 15, 2011 10:11 pm
by 62896dude
I know what you are talking about, but unfortunately i dont know the code for that :/ ask halls though, he knows a lot more than i do :p

Re: inn.php fixed error

Posted: Fri Mar 18, 2011 8:52 pm
by hallsofvallhalla
use timer or a date function, when a user enters the inn it stamps the time in a feild. Then if current time - timestamp < 20 minutes, echo you cannot enter the inn.

Re: inn.php fixed error

Posted: Fri Mar 18, 2011 11:52 pm
by 62896dude
There you have it! Psh, i like how in the first video halls, you said that you "weren't very good at PHP coding"... LIES