supanoob Posted May 15, 2007 Share Posted May 15, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/51479-easier-way/ Share on other sites More sharing options...
MadTechie Posted May 15, 2007 Share Posted May 15, 2007 what code do you have so far! also can to re-phrase the question Quote Link to comment https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-253549 Share on other sites More sharing options...
supanoob Posted May 15, 2007 Author Share Posted May 15, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-253566 Share on other sites More sharing options...
MadTechie Posted May 15, 2007 Share Posted May 15, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-253571 Share on other sites More sharing options...
supanoob Posted May 15, 2007 Author Share Posted May 15, 2007 it doesnt really >< the last code thing would help its just i dont wanna have to go through and make 1 long if statement of about 71 things for all the spaces that aren't a path. Quote Link to comment https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-253600 Share on other sites More sharing options...
MadTechie Posted May 15, 2007 Share Posted May 15, 2007 your only add that code once! (well i guess it depends how you set your up) your have to post some code.. Quote Link to comment https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-253608 Share on other sites More sharing options...
supanoob Posted May 15, 2007 Author Share Posted May 15, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-253625 Share on other sites More sharing options...
supanoob Posted May 16, 2007 Author Share Posted May 16, 2007 bump Quote Link to comment https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-254342 Share on other sites More sharing options...
MadTechie Posted May 16, 2007 Share Posted May 16, 2007 how to do know when they are off the path? is it the hardcoded stuff..? Quote Link to comment https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-254364 Share on other sites More sharing options...
supanoob Posted May 16, 2007 Author Share Posted May 16, 2007 i dont know if there off the path thats the problem the only way i can think of doing it is if i have one long if statment asking if the coords are equal to the NON-PATH coords. Quote Link to comment https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-254373 Share on other sites More sharing options...
MadTechie Posted May 16, 2007 Share Posted May 16, 2007 personally i wouldn't hard code the path.. it will create more problems later! Quote Link to comment https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-254408 Share on other sites More sharing options...
supanoob Posted May 16, 2007 Author Share Posted May 16, 2007 so how would you do it? Quote Link to comment https://forums.phpfreaks.com/topic/51479-easier-way/#findComment-254413 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.