jofolk Posted May 24, 2007 Share Posted May 24, 2007 I am trying to make a game much like Tribalwars. I am noob to PHP and got many of the functions to work but I am having a problem finding a resource on how to do something and I was hoping to get some help. I would like to make a script where the user select a link, which starts a timer, and then when the timer runs out it executes another script. (i.e. User would like to upgrade a building and it takes 2 hours to upgrade. Once the 2 hours is over their building is upgraded.) Like I said I am really new to PHP and programming in general. Can this function be created in PHP or does this need to be a server side script that is executed when the link is activated? Also, is there a site or a book that anyone would recommend I visit/read that would help me create my game. Thank you in advance. Link to comment https://forums.phpfreaks.com/topic/52771-timer-for-mmo/ Share on other sites More sharing options...
redarrow Posted May 24, 2007 Share Posted May 24, 2007 you need really to use a database to get this concept of your's idear to work. your need to understand the following php statemaents to acheve your goal. date statement/timestamp cron when a user press the link a date is entered in the database of the current date/time via a timestamp then using the mktime statement set two hours on you then would exicute another php page via a cron job that page would then enter the correct information for your current user's buildings. links. dates http://uk3.php.net/date cron http://www.modwest.com/help/kb5-125.html Link to comment https://forums.phpfreaks.com/topic/52771-timer-for-mmo/#findComment-260566 Share on other sites More sharing options...
MasterACE14 Posted May 24, 2007 Share Posted May 24, 2007 Online PHP Tutorials http://www.w3schools.com/php/default.asp http://www.tizag.com/phpT/ PHP Books PHP 5 in Easy Steps http://www.ineasysteps.com/ SAMs - PHP 5 UNLEASHED Regards ACE Link to comment https://forums.phpfreaks.com/topic/52771-timer-for-mmo/#findComment-260577 Share on other sites More sharing options...
jofolk Posted May 25, 2007 Author Share Posted May 25, 2007 Thank you for your feedback. I looked into the cron and I got it to run a script. I am trying to figure out how to make it work. Could you please let me if my logic is correct. Player select links for upgrading building. ->Database updates with time the building with be complete (building_finish_time, building_qued_type, building_qued_new_level). Cron is set to run action.php every minute. for(ALL of the Rows) If (building_finish_time < NOW){ UPDATE building database SET building_type = building_type + building_qued_new_level WHERE building_type = building_qued_type; building_finish_time = 1 Jan 2050; } I think that will work, but I am wrong running the Cron every minute. Will that cause a problem if I have a ton of people playing the game. Any feedback will be greatly appreciated. Thank you, Link to comment https://forums.phpfreaks.com/topic/52771-timer-for-mmo/#findComment-261391 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.