I'm making a little RPG multiplayer game where each player can travel long distances. Traveling from point A to B can take up to 10 minutes and – once initiated – is an automatic process. Now, I am not quite sure how to go about this on the server-side, the server has to be the one telling the clients that the traveling player has arrived or not.

Do I have to run some sort of timer where I check every X seconds/milliseconds if all the traveling players have reached their destination in order to update the DB? (the characters are saved on the server to prevent cheating).

The way I imagined it was simply to capture the timestamp at the start of travel, then use the distance to calculate what the time should be when the player will arrive, and then run some sort of timer that checks each traveling players "start time" , "actual time" and "destination time", but since I have never done this before I'm not sure if this is a good way of doing it?

  • \$\begingroup\$ It's not clear what your actual problem is. What role does the database play in stopping cheating? Where is the player considered to be while they are travelling? Do you have no other ongoing actions in your game that take place over time? \$\endgroup\$
    – Kylotan
    Aug 10, 2011 at 10:24

1 Answer 1


You only need to update the database in two cases:

  • the user performs an action or requests information from the server
  • another player wants to interact with said user

Periodically checking if the database needs to be updated would put a lot of strain on your servers. Instead, information should be updated only when it is needed. In other words, you don't need to update the travel-status in the database from 'travelling' to 'not-travelling' unless a user requests that information or wants to perform an action that is affected by that information.

For example, let's assume that the player cannot do anything while traveling and that once he has arrived at his destination, he can be attacked by another player. Once the player starts moving, you could update the database with the following information:

  • the user's position will be set to his final destination (even though he's not there yet)
  • a travel timestamp will show when he'll get there

Let's now consider another user present at the same location. He's looking for someone to attack and will ask the server for a list of people in the area. The server will look for players who are both at that location AND have an expired timestamp.

If the second user decides to attack the first, or the first user logs in and requests his character data, before sending any information to the players check if any of them have an expired travel timestamp. If they do, update their records (maybe the player that did the traveling is tired and has a penalty applied to his attributes) and only then perform the actual action.

If you want your server to notify the users that they've reached their destination, do it the other way around: when the user logs in, tell them when traveling should end and start a timer on their machine. When the timer hits zero, make the client ask for an update from the server. Requesting character data should lead to the server noticing that the travel timestamp has expired and thus updating all of the data.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .