Location Question!

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
Andrew
Posts: 16
Joined: Mon Aug 15, 2011 12:57 pm

Location Question!

Post by Andrew »

Hey, I'm just wondering how I can do the locations req. a level. I mean like this: You need to be level 1 for the first place, level 10 for the second etc., but how can I do the system to not allow players below lvl 10 to get access to travel to that location since they are't level 10 yeat.

Hope you understand what I mean.

here's my code so far:

Code: Select all

<?php
include_once 'connect.php';
session_start();

include_once 'logo.php';
?> 
<link href="style.css" rel="stylesheet" type="text/css" />
<div id="login2" div align="center">
<title>Zonthiz</title>


<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
?>
</div>

<?php
 $bypass =0; 
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
include_once 'statpanel.php';

$id = $playerinfo3['id'];
 ?>
 <div id ="locations">
 <?php

$playersm = $playerinfo3['stamina'];
if ($playersm < 1)
{
  echo "You are dead!" ;
  echo "<br><a href='useitem.php>Use an Item";
  exit;
}
  
  
  ////// $playerinfo="SELECT * from players WHERE id='$id' AND name = '$playerinfo3[name]'";
    $playerinfo2=mysql_query($playerinfo) or die("Could not get player level at this time!.");
    $playerinfo3=mysql_fetch_array( $playerinfo2);


if(isset($_GET['map']))
{
$bypass=1;
echo "Level 1-10<br>" ;
echo "<a href='index.php?mapchange=1&mapname=Forgotten Forest'>Forgotten Forest</a><br><br><br>";
echo "Level 9-18<br>" ;
echo "<a href='index.php?mapchange=1&mapname=Herry Mountains'>Herry Mountains</a><br><br><br>";
echo "Level 18-27<br>" ;
echo "<a href='index.php?mapchange=1&mapname=Deep Lake'>Deep Lake</a><br><br>";
echo "Level 27-36<br>" ;
echo "<a href='index.php?mapchange=1&mapname=The Forbidden Zone'>The Forbidden Zone</a><br><br><br>";
echo "Level 36-45<br>" ;
echo "<a href='index.php?mapchange=1&mapname=Burnt Forest'>Burnt Forest</a><br><br><br>";
echo "Level 45-50<br>" ;
echo "<a href='index.php?mapchange=1&mapname=Dark Cave'>Dark Cave</a><br><br><br>";
}

if(isset($_GET['mapchange']))
{
$bypass=1;
$mapname = $_GET['mapname'];

$updateplayer="update players set location='$mapname' where name='$playerinfo3[name]'";
  mysql_query($updateplayer) or die("Could not update player");
  
echo "You have traveled to " . $mapname . ".<br>";
echo "<a href='index.php'>To location</a><br>";
}

if($bypass != 1)
{
echo "<b><big><u>" . $playerinfo3['location'] . "</u></big></b><br>";
echo "<a href='store.php'>Visit Store</a><br>";
echo "<a href='weaponshop.php'>Visit Weapon Shop</a><br>";
echo "<a href='armorshop.php'>Visit Armor Shop</a><br>";
echo "<a href='inn.php'>Visit Inn</a><br>";
echo "<a href='spelltrainer.php'>Visit Spell Trainer</a><br>";
echo "<a href='battle.php'>Go Battle!</a><br><br>";
echo "<a href='index.php?map=1'>Go to Map</a><br>";
}

 ?>
 </div>
<div id="logout">
<?php
echo "<br><a href='logout.php'><img src='images/logout.gif'></a>";
?>
</div>

At the "//////" I've started something that I think is right" don't know.

Thanks,

Andrew
Tim
Posts: 37
Joined: Fri Jun 10, 2011 12:49 am

Re: Location Question!

Post by Tim »

You could do an if statement on the page where the user has a choice to travel.

Code: Select all

if ($user_level > 5)
{
   echo "click here to go to the noob map.";
}

if ($user_level > 10)
{
   echo "click here to go to the intermediate map.";
}

if ($user_level > 15)
{
   echo "click here to go to the advanced map.";
}

User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Location Question!

Post by Torniquet »

pretty much like tim said.

I have a video awaiting upload to youtube which covers locations it should be up by tomorrow night when i get access to some proper internet lol.
New Site Coming Soon! Stay tuned :D
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Location Question!

Post by Jackolantern »

You could do it that way, but you would need to make those > into < ;)
The indelible lord of tl;dr
Andrew
Posts: 16
Joined: Mon Aug 15, 2011 12:57 pm

Re: [solved]Location Question!

Post by Andrew »

Hey again, I just found out what was wrong with my code, Thank you :D


Have a good day!,

Andrew
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Location Question!

Post by Jackolantern »

Out of curiosity (and for others who may find this post later with the same problem), what did you do to get it working?
The indelible lord of tl;dr
Post Reply

Return to “Advanced Help and Support”