Jump to content

Timer for MMO


jofolk

Recommended Posts

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

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

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

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.