apw Posted June 26, 2008 Share Posted June 26, 2008 My question is about .. When player hits the next-turn button the players pfile in the sql-database should stamp the time the player hit the button, which it does however along that line i also need an additional 20-minutes or so added to the stamped time then when the real-time reaches the time that was an additional 20-minutes my script tells player that their army has returned! Is that possible? Quote Link to comment Share on other sites More sharing options...
lemmin Posted June 26, 2008 Share Posted June 26, 2008 You can use the ADDTIME function in mysql (or a similar one if you aren't using mysql) to add to the time when you put it in the db. "UPDATE players SET ArmyBackAt = ADDTIME(NOW(), '00:20:00') WHERE PlayerID = $id"; Then when a player tries a link, check if NOW() is past that time; if it is, their army is back. Quote Link to comment Share on other sites More sharing options...
Wolphie Posted June 26, 2008 Share Posted June 26, 2008 I think you're looking for an offset. Why not just insert the time that the button was clicked into the database, and then check the current time to see if it's been more than 20 minutes since they hit the button. This is the way I would do it, however if people don't refresh the page for 20 minutes then they wouldn't be updated about the status of their army. Unless you had some kind of automated refreshing function. To do this you should either use an HTTP refresh, javascript refresh or use PHP's header() function (not sure if it's possible with header(), I don't see no reason why not). $offset = 20 * 60; // 20 minutes $old_time = 15 * 60 * 60; // 3pm $time = time(); // current time if(($time - $old_time) < $offset) { // refresh page... } Quote Link to comment Share on other sites More sharing options...
apw Posted June 26, 2008 Author Share Posted June 26, 2008 Thanks both for your suggestions im trying to work around the fact that my webhost doesnt offer cron and alot of extra and almost unnecessary work must be done 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.