Equium Posted April 15, 2014 Share Posted April 15, 2014 Hi basically i run a only text based mafia game After you commit a GTA it says you need to wait 2 mins but loads the time you have to wait like this: You need to lay low for a little while.00:03:56 and stays like that i would like it to actually count down while your on the page not have to keep refreshing. How would i go about doing this here is the code for that snippet: <?phpif($rank >= "2"){if(time() <= $gta_information[0]){if(!$_POST['Commit']){ echo "You need to lay low for a little while.<br />".date( "00:i:s", $gta_information[0] - time() ); } Quote Link to comment Share on other sites More sharing options...
Equium Posted April 15, 2014 Author Share Posted April 15, 2014 hmm why is my topic not showing up Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted April 15, 2014 Share Posted April 15, 2014 (edited) This cant be done with PHP alone. The countdown will have be handled by javascipt. You'd only use PHP to initiate the timer hmm why is my topic not showing up What do you mean? It is listed in the PHP Coding Help forum Edited April 15, 2014 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
Equium Posted April 15, 2014 Author Share Posted April 15, 2014 sorry we being blind new user and would this be easy to do with java i have no experience with java... Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted April 15, 2014 Share Posted April 15, 2014 First java and javascript are two complete different languages. There are many javascript timer scripts out there. Find one, download it, and play with it so you understand how it works then try and get it to work with your PHP. Quote Link to comment Share on other sites More sharing options...
alphamoment Posted April 15, 2014 Share Posted April 15, 2014 (edited) <head> <meta http-equiv="REFRESH" content="5;url=http://www.google.com" target="_self"> </head><body oncontextmenu="return false;"> <p>You'll be automatically redirected in <span id="count">5</span> seconds...</p> <script type="text/javascript"> window.onload = function(){ (function(){ var counter = 5; setInterval(function() { counter--; if (counter >= 0) { span = document.getElementById("count"); span.innerHTML = counter; } if (counter === 0) { alert('BYE'); clearInterval(counter); } }, 1000); })(); } </script> Try this, works like a charm for me I use it as a re-directory. When the timer has finished its 5 seconds, it will re-direct to google.com You can change it to suit your needs though.It's fairly simple Edited April 15, 2014 by alphamoment Quote Link to comment 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.