   [web] build completion time
  Hi,I was wondering where to look to make a timer that checks the build time of a building or item, set that amount when the user builds something and then update the database after the build time. even if the user changes from a page or logs off. I'm using &#106avascript, php, mysql and ajax.I need this for my players that research and create items. Those items would not appear instant but each need a specific amount of time. I might also use this for traveling time, so a calculation on the distance / speed and wait that much amount of time till the user arrives. But in the meantime the user can still see different pages so he does not get bored when traveling long distances.Also a que would be nice to have so people can put in multiple orders at the same time.This is pretty standart for every browser game that involves building but i can't seem to find any info on it. So any tutorials you know of or a little direction on what i should use is very welcome.[Edited by - menyo on June 7, 2010 11:41:41 AM]
  Why update the database when a user is logged off? Simply check what needs to be done next time he is active. I would simply put all the items in a queue of some sort, ordered by when they are supposed to be done (ascending of course). When a user is active (i.e. page load or whatever) simply shift items from the front of the queue and process them until you get an item whose expiration time hasn't come yet. Just a plain FIFO queue.   ;  So what i should do is make an extra table with the user ID, "object" to make/craft and a time when it's completed. Then do continuous AJAX checks on that table to see if the time condition is met?I did some lookup on FIFO queing but i can't see how that helps me. Afaik, if done right it produces an array wich would get lost if the player logs off or changes a page.   ;  You don't need to do continuous checks; you can read the table of pending stuff in time order and the first item will be the next to be completed -- your query should run just after that time in the future.If the user schedules another task, you can simply requery the table to make sure your pause is the right length in case this item has gone on the front.;  Offcourse.....I should do a query every time a page loads that needs the information. Then get the time left and display that or make a count down timer for more fancyness. Can't believe i didn't think of that, it seems a very stupid question now.   