gamesmstr Posted October 15, 2008 Share Posted October 15, 2008 I have a bit of a problem I had asked for help on a few days ago and while the solution suggested works to an extent, it causes a unsightly white flash from the page load. I have a game module that allows players to move about on quests and they are randomly attacked by creatures. The problem is that when people with slower connections click really fast, the can get to their destinations without being attacked at all. Here is the code for the link that keeps getting abused. echo "<p><table border=0 align=center><tr><td></td><td>"; if ($questrecord[uy] > 0){ echo "<center><a href=outlands.php?action=up>North</a></center>"; } else{ echo "<center>Up</center>"; } echo "</td><td></td></tr><tr><td>"; if ($questrecord[ux] > 0){ echo "<center><a href=outlands.php?action=left>West</a></center>"; } else{ echo "<center>Left</center>"; } echo "</td><td>"; echo "</td><td>"; if ($questrecord[ux] < 1000){ echo "<center><a href=outlands.php?action=right>East</a></center>"; } else{ echo "<center>Right</center>"; } echo "</td></tr><tr><td></td><td>"; if ($questrecord[uy] < 1000){ echo "<center><a href=outlands.php?action=down>South</a></center>"; } else{ echo "<center>Down</center>"; } echo "</td><td></td></tr></table>"; And here is the code it calls: // moving page if ($action == "up"){ //Chance of monster $mrand=rand(1,100); if ($mrand<=25){ questattack($playerinfo); } else{ mysql_query("Update outland_user_data set uy=uy-1 where id='$playerinfo[id]'"); } } if ($action == "down"){ //Chance of monster $mrand=rand(1,100); if ($mrand<=25){ questattack($playerinfo); } else{ mysql_query("Update outland_user_data set uy=uy+1 where id='$playerinfo[id]'"); } } if ($action == "left"){ //Chance of monster $mrand=rand(1,100); if ($mrand<=25){ questattack($playerinfo); } else{ mysql_query("Update outland_user_data set ux=ux-1 where id='$playerinfo[id]'"); } } if ($action == "right"){ //Chance of monster $mrand=rand(1,100); if ($mrand<=25){ questattack($playerinfo); } else{ mysql_query("Update outland_user_data set ux=ux+1 where id='$playerinfo[id]'"); } } So. Why is the movement getting called but not the attack? Quote Link to comment https://forums.phpfreaks.com/topic/128590-solved-fast-clicking-bypassing-functions/ Share on other sites More sharing options...
prexep Posted October 15, 2008 Share Posted October 15, 2008 People with slower connections probably don't load the whole php script in time and then they click on and they skip the attack. Example: Click north Get Attacked Loading...Loading some but not the whole page yet, but movement shows. Lets click it. Skipped the Attack because it went on. Without loading the rest of the page. Safe Player. Quote Link to comment https://forums.phpfreaks.com/topic/128590-solved-fast-clicking-bypassing-functions/#findComment-666424 Share on other sites More sharing options...
gamesmstr Posted October 15, 2008 Author Share Posted October 15, 2008 I figured out the problem and the solution. Say I am at coordinates 0,0 when I begin my clicking East. The page was still loading every time I clicked so the x cord just incremented each time but the source was the page with 0,0. By the time the page got a full load in, x could be 500. So, knowing the source link is the same every click, I had it compute the new value of x BEFORE the link and added a &step=$newx to the end of the link. I then had the user data updated with the step value instead. That way the static data in the link gets passed no matter how many times the link is clicked. Quote Link to comment https://forums.phpfreaks.com/topic/128590-solved-fast-clicking-bypassing-functions/#findComment-666447 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.