Jump to content

Recommended Posts

ok so basically i have a 10x10 grid and only 29 of the squares make up my path, now i need a way to make it so they cant wonder off the path. Now i have it so the arrows only show up in the directions they can travel but with the back button and refresh they can get off the path still. All i want to do is if they are not on one of the 29 coors it shows a random event and take them back to the start of the grid.

 

Any advice on how to do this would be greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/51479-easier-way/
Share on other sites

well the code is on several pages so posting it all would be too much but basically this is a simpler question with an example.

 

i have the following table (only bigger)

 

1,1 -

1,2 -

1,3

2,1 -

2,2 -

2,3

3,1 -

3,2 -

3,3

 

ok so say i have a path that goes along 1,1 - 1,2 - 2,2 - 2,3 and i only wanted people to go onto those squares. Is there an easy way to throw an error out of someone somehow managed to get onto one of the other squares?

 

as it stands i have it so if they were on 1,1 they would only be able to go East and if they were on 1,2 They could move West and South, but if they double clicked south they would end up on 3,2 and that is one of the squares i dont want them on.

Link to comment
https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-253566
Share on other sites

i wrote a maze awhile back and had a problem with member double clicking..

 

my work around was .. erm...

 

i think..

 

i set a session and set a hidden field to the same value..

 

ie

$lastcode = get the last hidden field code

$X = randomsomething; \\<-- generated on each page load

if($lastcode != session['code'])

{

//go back to start;

}

session['code'] = $x;

hidden field = $x;

 

 

i hope that makes sence

 

 

Link to comment
https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-253571
Share on other sites

this is the code i have for the main page and the map

 

Main Page

 

<?php

include_once('logged_in_top.php');
if ($_GET['mode'] == 'enter')
{
$sql2="UPDATE accounts SET co_ord_x=1, co_ord_y=5 where account_id=$account_id";
if(mysql_query($sql2));
}

//update needs to be before query so it will echo new location
if ($_GET['action'] == 'west')
{
$sql2="UPDATE accounts SET co_ord_x=co_ord_x-1 where account_id=$account_id";
if(mysql_query($sql2));
}
if ($_GET['action'] == 'east')
{
$sql2="UPDATE accounts SET co_ord_x=co_ord_x+1 where account_id=$account_id";
if(mysql_query($sql2));
}
if ($_GET['action'] == 'north')
{
$sql2="UPDATE accounts SET co_ord_y=co_ord_y-1 where account_id=$account_id";
if(mysql_query($sql2));
}
if ($_GET['action'] == 'south')
{
$sql2="UPDATE accounts SET co_ord_y=co_ord_y+1 where account_id=$account_id";
if(mysql_query($sql2));
}
//end

//query need to be after update because it will echo the new location not the old one.
$query="select co_ord_y, co_ord_x from accounts where account_id=$account_id";
$result=mysql_query($query);
if (!$result)
{
die (mysql_error());
}

$num_rows=mysql_num_rows($result);

$row=mysql_fetch_array($result);
$co_ord_y=($row['co_ord_y']);
$co_ord_x=($row['co_ord_x']);
//end

//make actual coords known and usable further down.
$actual_x=$co_ord_x;
$actual_y=$co_ord_y;
//end actual coords

include_once('check_coords.php');

echo "<table border=\"1\" width=\"100%\" id=\"table1\">
<tr>
	<td width=\"33%\" align=\"center\"><b>Details</b></td>
	<td width=\"33%\" align=\"center\"><b>Map</b></td>
	<td width=\"33%\" align=\"center\"><b>Battle Options</b></td>
</tr>
<tr>
	<td width=\"33%\" valign=\"top\">Currently Located: $co_ord_y,$co_ord_x
	<br>
	Events:";

        echo "</td>
	<td width=\"33%\" valign=\"top\" align=\"center\">";   
    		if ($_GET['area'] == '1')
{
include_once('wood_area_1_links.php');
}

echo "</td>
	<td width=\"33%\" valign=\"top\">Attackable Players:<p>Attackable NPC's:</td>
</tr>
</table>";
include_once('logged_in_bottom.php');
?>

 

Map

if ($_GET['wood'] == '1' && $_GET['area'] == '1')
{
echo "<table border=\"0\" width=\"10\" height=\"10\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
	<td>";
	//Row 1
	 echo "<img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
</tr>";
//end row 1
//row 2
echo "<tr>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '2' && $co_ord_x == '2')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">"; echo "</td>
	<td>";
    if ($co_ord_y == '2' && $co_ord_x == '3')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">"; 
     echo "</td>
	<td>";
    if ($co_ord_y == '2' && $co_ord_x == '4')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td>";
    if ($co_ord_y == '2' && $co_ord_x == '5')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td>";
    if ($co_ord_y == '2' && $co_ord_x == '6')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">"; 
     echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
</tr>";
//end row 2
//row 3
echo "<tr>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '3' && $co_ord_x == '2')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">"; echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '3' && $co_ord_x == '6')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">"; 
     echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
</tr>";
//end row 3
//row 4
echo "<tr>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '4' && $co_ord_x == '2')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
     if ($co_ord_y == '4' && $co_ord_x == '4')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">"; 
     echo "</td>
	<td>";
    if ($co_ord_y == '4' && $co_ord_x == '5')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">"; 
     echo "</td>
	<td>";
    if ($co_ord_y == '4' && $co_ord_x == '6')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '4' && $co_ord_x == '9')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">"; 
     echo"</td>
	<td>";
    if ($co_ord_y == '4' && $co_ord_x == '10')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
</tr>";
//end row 4
//row 5
echo "<tr>
	<td>";

     
     if ($co_ord_y == '5' && $co_ord_x == '1')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">"; echo "</td>
	<td>";		 
     if ($co_ord_y == '5' && $co_ord_x == '2')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">"; echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '5' && $co_ord_x == '4')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '5' && $co_ord_x == '9')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
</tr>";
//end row 5
//row 6
echo "<tr>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '6' && $co_ord_x == '4')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td>";
    if ($co_ord_y == '6' && $co_ord_x == '5')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td>";
    if ($co_ord_y == '6' && $co_ord_x == '6')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td>";
    if ($co_ord_y == '6' && $co_ord_x == '7')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '6' && $co_ord_x == '9')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
</tr>";
//end row 6
//row 7
echo "<tr>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '7' && $co_ord_x == '7')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '7' && $co_ord_x == '9')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
</tr>";
//end row 7
//row 8
echo "<tr>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '8' && $co_ord_x == '7')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '8' && $co_ord_x == '9')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
</tr>";
//end row 8
//row 9
echo "<tr>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td>";
    if ($co_ord_y == '9' && $co_ord_x == '7')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td>";
    if ($co_ord_y == '9' && $co_ord_x == '8')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td>";
    if ($co_ord_y == '9' && $co_ord_x == '9')
     {
     echo "<img border=\"0\" src=\"/images/Icons/woods/player.GIF\" width=\"10\">";
     }
     else
     echo "<img border=\"0\" src=\"/images/Icons/woods/trees.GIF\" width=\"10\">";
     echo "</td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
</tr>";
//end row 9
//row 10
echo "<tr>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
	<td><img border=\"0\" src=\"/images/Icons/woods/path.gif\" width=\"10\"></td>
</tr>
</table>";
}
//end row 10

 

 

told you it was alot of code :P

Link to comment
https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-253625
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.