lukeprice Posted July 14, 2006 Share Posted July 14, 2006 Hi,I am currently attempting to develop an online game. I have so far achieved the results I want using JavaScript but have now been informed it would be easy to cheat because JavaScript is client side. So I have now began attempting to achieve the same results using PHP. Ive started trying to rescript the countdown timer but can't seem to get a satisfactory alternative to setTimeout (in JS). I have tried sleep() and usleep() but i'm either using them incorrectly or they won't do what I need.The link to what the 'game' (in inverted commas because its far from that yet) should be like (in JS) is here: [url=http://www.bibliocommerce.com/test/chop_wood.php]http://www.bibliocommerce.com/test/chop_wood.php[/url] The code for the alternative countdown timer I have been working on is here but it will not work, it keeps reposting the same values. Like I said I tried using sleep(), but then the page doesn't even load! Here is the code: [code]PHP Code:<?phpfunction display(){$milisec = 0;$seconds = 5;$milisec -= 1; if ($milisec <= -1){ $milisec = 9; $seconds -= 1; } do { echo $seconds.".".$milisec; } while ($milisec > 0 && $seconds > 0); }display();?> [/code]And a link to a working version here: [url=http://www.bibliocommerce.com/test/php_function.php]http://www.bibliocommerce.com/test/php_function.php[/url] WARNING: Don't visit the link if you don't want your browser to crash! It might not, but then again...I just need some way to pause the script for a second then execute it again, then pause, then execute and so on... Thank you in advance. Quote Link to comment https://forums.phpfreaks.com/topic/14576-live-countdown-not-date-or-time/ Share on other sites More sharing options...
ShogunWarrior Posted July 14, 2006 Share Posted July 14, 2006 PHP would only be useful for example a crossword where they only had a certain time to complete it. By inserting the time into the page when they start you can check the time taken at the end, avoiding cheating.However, PHP cannot be used in the context of live client-side interaction, except for making calls to PHP from Javascript to check the time, which could be foiled too. Quote Link to comment https://forums.phpfreaks.com/topic/14576-live-countdown-not-date-or-time/#findComment-57848 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.