DEVILofDARKNESS Posted September 10, 2009 Share Posted September 10, 2009 Okay so I'm building a game, (it's almost finished), but a friend of me said it would be better that if you bought a building or Weapon (on the game) that instead of having the item direct a counter should appear. this one should countdown from a certain time in minutes or houres till zero and you should be possible to see it count down, if you quit the browser the counter actually should go on, so that if you come back it could be build Only one problem: I really have NO idea how I should do this. :s Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted September 10, 2009 Share Posted September 10, 2009 One approach would be to store the time of the purchase, and calculate the time it will be "ready" and store that... then, when they were to go to use it, you would check that ready time first to see if it is available for use. You could use javascript to build a countdown timer... and feed it the value of the ready time to countdown to... then if they closed and left, it would just get the ready time from the database and continue counting down upon their return. Hope that helps Quote Link to comment Share on other sites More sharing options...
DEVILofDARKNESS Posted September 10, 2009 Author Share Posted September 10, 2009 Okay, so I would determine when it should be finished, by doing the current time + the ammount of minutes needed and store this value in a database. Okay I got that, but I don't know anything about javascript (except the alert function ) so how should I do this? Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted September 10, 2009 Share Posted September 10, 2009 You should be able to google around for a script that would do the countdown, then modify it to accept your data. Quote Link to comment Share on other sites More sharing options...
DEVILofDARKNESS Posted September 11, 2009 Author Share Posted September 11, 2009 Okay I found this javascript <script language="JavaScript"> TargetDate = "12/31/2020 5:00 AM"; BackColor = "palegreen"; ForeColor = "navy"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; FinishMessage = "It is finally here!"; </script> but how can I pass hte value of php to javascript TargetDate = <?php echo $targetdate; ?> ??? 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.