mike1313 Posted March 24, 2007 Share Posted March 24, 2007 I have map for our users in our online MMORPG. We have a section, where you walk around starting at 0,0 thats x,y coords each time you click a direction it updates their coord in the db, but the way the x,y are displayed everytime they move, the number is always 1 behind is there anyway to display the output as a change everytime they click? so if they are at 1,1 they go north itll still display 1,1 until they click again I want them to be able to click once and itll show 1,2 is this at any way possible? Link to comment https://forums.phpfreaks.com/topic/44077-i-dont-know-if-this-is-at-all-possible/ Share on other sites More sharing options...
JasonLewis Posted March 24, 2007 Share Posted March 24, 2007 just refresh the page again, so update then re-direct. or am i a tad off track? Link to comment https://forums.phpfreaks.com/topic/44077-i-dont-know-if-this-is-at-all-possible/#findComment-214014 Share on other sites More sharing options...
mike1313 Posted March 24, 2007 Author Share Posted March 24, 2007 Yeah, tried that it worked, using meta refresh, but we had rand() on the page making it run twice. Link to comment https://forums.phpfreaks.com/topic/44077-i-dont-know-if-this-is-at-all-possible/#findComment-214016 Share on other sites More sharing options...
JasonLewis Posted March 24, 2007 Share Posted March 24, 2007 use the header() tag instead. its instant, before the page loads. Link to comment https://forums.phpfreaks.com/topic/44077-i-dont-know-if-this-is-at-all-possible/#findComment-214018 Share on other sites More sharing options...
mike1313 Posted March 24, 2007 Author Share Posted March 24, 2007 How would I use it header location, I tried using srand it updated part of the page but not what I needed. Link to comment https://forums.phpfreaks.com/topic/44077-i-dont-know-if-this-is-at-all-possible/#findComment-214028 Share on other sites More sharing options...
Barand Posted March 24, 2007 Share Posted March 24, 2007 This just uses a simple text file x=0 y=0 but pos is shown immediately <?php $dx = isset($_GET['dx']) ? $_GET['dx'] : 0; $dy = isset($_GET['dy']) ? $_GET['dy'] : 0; if (($coords = @parse_ini_file('pos.txt'))==false) $coords = array(); $coords['x'] += $dx; $coords['y'] += $dy; /** * check limits */ if ($coords['x'] < 0) $coords['x'] = 0; if ($coords['x'] > 9) $coords['x'] = 9; if ($coords['y'] < 0) $coords['y'] = 0; if ($coords['y'] > 9) $coords['y'] = 9; /** * update pos.txt */ $f = fopen('pos.txt', 'w'); foreach ($coords as $k=>$v) fwrite($f, "$k=$v\r\n"); fclose($f); echo "East: {$coords['x']} North: {$coords['y']}<br>"; ?> <a href="?dy=1">Up</a><br> <a href="?dx=-1">Left</a> <a href="?dx=1">Right</a><br> <a href="?dy=-1">Down</a><br> Link to comment https://forums.phpfreaks.com/topic/44077-i-dont-know-if-this-is-at-all-possible/#findComment-214152 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.