[Need Help] MMORPG [Java]

Discussion in 'Game Development (Technical)' started by Zanctarian, Sep 11, 2016.

  1. Zanctarian

    Zanctarian New Member

    Joined:
    Aug 28, 2016
    Messages:
    5
    Likes Received:
    0
    Hello, I need help figuring out something for a MMO.

    Let's say I have a server running data for stuff like time. How exactly would I store the time? I also need it to update a minute a second. The game is gonna be on servers but each server needs to have its own time. Please help me figure out how to make updating time on servers so everyone on the same server will have the same time.
     
  2. bantamcitygames

    Administrator Original Member Indie Author Greenlit

    Joined:
    Jul 27, 2004
    Messages:
    1,737
    Likes Received:
    79
    Are you referring to in-game virtual time or real time? If it is in-game time then you would store it the same way you would any persistent variable on the server. In java you could store it as a Date or Calendar object either of which is pretty easy to do math with to add a minute per second. If you have more specific questions let me know. My MMO server it's written in java and I'm a java developer by profession.
     
  3. Zanctarian

    Zanctarian New Member

    Joined:
    Aug 28, 2016
    Messages:
    5
    Likes Received:
    0
    The thing is, I am unaware how that system works. Also, in-game virtual. @bantamcitygames
     
  4. bantamcitygames

    Administrator Original Member Indie Author Greenlit

    Joined:
    Jul 27, 2004
    Messages:
    1,737
    Likes Received:
    79
    @Zanctarian Can you post more details about your project and specifically what you are trying to do? I'll try to help as best I can.
     
  5. Zanctarian

    Zanctarian New Member

    Joined:
    Aug 28, 2016
    Messages:
    5
    Likes Received:
    0
    @bantamcitygames In my MMORPG, I will have different server (VPS). What I want to do is (1min = 1 sec btw) have a clock running through the server as the server game time. I want to get the time from the server and have the time set for the player in the game. I don't mind having to use MySQL or something else. For example, with minecraft servers. Each server has its own time. I want to have the servers have its own time (I don't care if all servers are set to one time also).
     
  6. bantamcitygames

    Administrator Original Member Indie Author Greenlit

    Joined:
    Jul 27, 2004
    Messages:
    1,737
    Likes Received:
    79
    When your server application starts up, you can do the following:
    Code:
    // This will get the server start date/time
    Date serverStartDate = new Date();
    
    Each time you want to send the time from the server to the client, you can do something like:
    Code:
    // This will get the current date/time
    Date currentDate = new Date();
    
    // This will get the difference in ms from start time to the current time in ms
    long runTime = currentDate.getTime() - serverStartDate.getTime();
    
    // Convert the run time (1 min = 1 sec)
    long fastRunTime = runTime * 60;
    Date fastRunDate = new Date(serverStartDate.getTime() + fastRunTime);
    
    // Now do what you want with this new Date (e.g. output or send to client, etc)
    sendDateToClient(fastRunDate);
    
     
  7. kaufenpreis

    kaufenpreis New Member

    Joined:
    Aug 1, 2014
    Messages:
    104
    Likes Received:
    4
    Please post more details about your project and specifically what you are trying to do?
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer