Jump to content

[SOLVED] php how to add a countdown script till something is updated


Danny620

Recommended Posts

OK heres what i am planing to do

 

i want to build a game where the user logins and he has is own town thing then he clicks on the HQ

and there he can upgrade his buildings by clicking on like "upgrade to level x" then this would start the contruction that's where the countdown comes in say he upgrades to level 2 hes building takes 34Min's to construct that's where i want it to count down 34Min's then run the script that updates the db to say hes level 2.

Why don't you have a table in your database called construction. When a user clicks 'upgrade to level x' a row is added to the table with the end time (current timestamp plus {60*34} for 34 mins), the users id and a reference to the building. On page load check that table for results, if it's empty nothing is being built, if it has results check the end time against the current time. If it has passed delete the row from the construction table and update the necessary hq level.

thats what i had in mined e.g set a future date and time in db and then everytime the page is reloaded check to see if the time now is greater then the one in db if it is update level to 2. does that sound good to u.

but does the date(); function go off the users time and date of so how do i make it go off the servers date beacuse the user could change his date and time to 30mins in frount then he would not have to wait am i right?

ha ha lol i no why i was so confused lol it was because of my localhost test server when i changed the time on windows it was obusly going to change the time of my Apache server that's why i came up with that idea above

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.