Prevent going back [SOLVED]

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
User avatar
62896dude
Posts: 516
Joined: Thu Jan 20, 2011 2:39 am

Prevent going back [SOLVED]

Post by 62896dude »

Hey there everyone

So I have a question that I am sure someone here has the answer to, but no matter how hard I look online, there doesn't seem to be a complete answer as to how to accomplish what I need it to. So I was wondering, how exactly do I prevent the user from going back a page? Let's say that they fight a monster, die, and are shown the screen that says for example "You died n00b, <a href="whatever.php"go back to the index page with less money and half health</a>" (I only included the <a href> tag to show where the link would be. Well my problem is, the user could just say "heh, silly game, I shall now press the back button and try again" and so they do, and nothing is stopping them. So how do I prevent them from doing this? And if I can't deny them from going back a page, how can I make it so that if they try to go back, it just keeps them on the same page they were on before?

Thanks everyone!
Last edited by 62896dude on Sat Jul 09, 2011 7:59 pm, edited 2 times in total.
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Prevent going back

Post by Torniquet »

When i was dealing with fighting etc on my first game i started, i had a flag in the database which indicated whether i was in a fight or not. When a player ran or died, the flag would turn off, and if they tried to go back and do something, they would be sent to another page or a message would display saying they weren't in a fight.

so right at the top of the page you want to run a check to see if this flag is set to on or off, if on then the fight continues, if off then throw them from the page.

I would handle the death consequences the moment they are killed as well so they cant log off and log back on without anything happening.
New Site Coming Soon! Stay tuned :D
User avatar
62896dude
Posts: 516
Joined: Thu Jan 20, 2011 2:39 am

Re: Prevent going back

Post by 62896dude »

That is a very good idea! I will likely use that in my battles. However, would I just have to do the same thing in every other page? Because I don't think I want the back button used at all
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Prevent going back

Post by Torniquet »

i dont quite understand what you mean. I dont think there is anyway of disabling the back button, but you can formulate alot of restrictions using that method.

setting up flags (or a single field which indicates the players current status, such as in battle, cooking, flying etc) can force people to various pages and stopping them from making certain actions while these flags are set.
New Site Coming Soon! Stay tuned :D
User avatar
62896dude
Posts: 516
Joined: Thu Jan 20, 2011 2:39 am

Re: Prevent going back

Post by 62896dude »

Okay, I'll just make it work with the way you showed me then, thanks for the help! :)
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Post Reply

Return to “Advanced Help and Support”