Jump to content

Automatic update


Worqy

Recommended Posts

Hi!

 

I have a question that I need help with.

I guess almost everyone of us have played a webgame where something happends automaticly.

Some examples:

Attacks, resources in Travian, Tribalwars, Khan Wars ...

 

How are these things done?

Now I'm talking about automatical things that happends every second.

Is there a Cron Job that every second connectes to a database and adds more resources to the player?

 

Regards

Worqy

Link to comment
Share on other sites

Depends on what you are talking about because you didnt give much specifics. Most web based games are developed in flash or java, which would be different from using php to build a game. If you are using php/javascript to build a game then it can vary depending on what you mean. If you mean the game updating while the player is on the page then they are probably using ajax to send requests to update the player info. If you mean updating the players data while they are not on the page then more than likely they are using a cron job that runs that will update the player information while they are not there. I wouldnt run a cron job every second but more likely it will run every 15 mins or so.

Link to comment
Share on other sites

you do not want to run a cron job every second, if there is any way to avoid it. aside from the potential server load, you can't be sure the previous run is complete before the next one, and the next one, and the next one. things like you're talking about are most likely done with database triggers: if x happens, then update y and z.

Link to comment
Share on other sites

I can explain how a example game would work.

 

The player logs in to the account and build a build that gives him 6400 resources every hour.

Then the player logs out.

Now after one minute 1 resource shall be added to the database value.

Now the player logs in again and upgrades the building so it gives him 12800 resources every hour.

And the player logs off.

Now every 30sec the program must add 1 resource to the database.

And lets say that there is 3 players in the game.

One shall have the resources at 00:00:00 (Midnight) another one at 00:0045 and the third one at 00:01:3.

And when there is even more players the resources must be added every second.

Without the player doing nothing. He/She does not even need to be online (logged in).

 

Now I would wan't to know how this system is done?

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.