Jump to content

PHP & real-time effects


apw

Recommended Posts

Hello im working on a script for a web-based game that uses real-time for player building, production, etc. My question is this possible with php or would i need a 3rd party script such as java to do these real-time actions. The times would be hard-coded and not in the datbase

Link to comment
Share on other sites

Hi

 

Probably depends on how close to real time you want it to be.

 

Using regular CRON jobs you could come up with something close to it, along with careful design so that when anything is affected it updates its fields.

 

However I don't believe php supports firing off threads.

 

All the best

 

Keith

Link to comment
Share on other sites

apw,

 

Out of curiosity, why would you not store the dates in a DB and then use php to alter them?  If you keep datetimes in a DB, you'd be able to have countdown timers for when something completes 

 

Keep in mind that you're going to need a whole host of different variables based on the user.  With many users, comes an exponential growth in variables.  Keeping them in a database I think would benefit you, and then you could simply use JS as a timer, grabbing the starting and end times from the DB.

 

Hope this helps.

Link to comment
Share on other sites

The real-time for the game would actually be a countdown timer at differemt times based on the level the player has gained on certin buildings such as level 1 would be 40 seconds then the next would be 1minute-30 and so on ..

Link to comment
Share on other sites

Hi

 

For things like that just use Javascript to count down (it is merely there for display to the user). If you want you can reload the page using Javascript when the timer reaches 0 (and then do required table updates from the php script you call to do the update).

 

All the best

 

Keith

Link to comment
Share on other sites

Geudrik, i wasnt aware that i was able to store simple times such as 40 seconds or 1minute-30 in a database but i do se what your saying about stamping the time then adding an end-time of x-min/sec to this which would work also im just not sure about the js countdown being fed the times through my database yet

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.