Jump to content
  • 0

GameTimeTaskManager aCis


l2jkain

Question

Hello I'm creating an .info I wanted by an option to show how many hours the server is online but it is not working correctly the code is thus :

 

aCis

    public static String getServerRunTime()
    {
        int timeSeconds = (GameTimeTaskManager.getInstance().getGameTime());
        String timeResult = "";
        if (timeSeconds >= 86400)
            timeResult = Integer.toString(timeSeconds / 86400) + " Days " + Integer.toString((timeSeconds % 86400) / 3600) + " hours";
        else
            timeResult = Integer.toString(timeSeconds / 3600) + " Hours " + Integer.toString((timeSeconds % 3600) / 60) + " mins";
        return timeResult;
    }
	
    original part jServer H5
	
	public static String getServerRunTime()
    {
        int timeSeconds = (GameTimeController.getGameTicks() - 36000) / 10;
        String timeResult = "";
        if (timeSeconds >= 86400)
            timeResult = Integer.toString(timeSeconds / 86400) + " Days " + Integer.toString((timeSeconds % 86400) / 3600) + " hours";
        else
            timeResult = Integer.toString(timeSeconds / 3600) + " Hours " + Integer.toString((timeSeconds % 3600) / 60) + " mins";
        return timeResult;
    }
       

 

 

It does not refresh every 60 seconds and I've tried the methods responsible for calculating the minutes to hours getGameTime, getGameDay, getGameHour, getGameMinute and did not work what I'm doing wrong?

Edited by l2jkain
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

You have to use internally _time, one tick being 10sec.

Or you simply store a damn long with current time on server start on ServerMemo.

Edited by Tryskell
Link to comment
Share on other sites

  • 0

using it did not work correctly

int timeSeconds = (GameTimeController.getGameTime() - 36000) / 10;

or would I rather create a new get for seconds? like that


    /**
     * Returns game segunds (0-59).
     * @return int : Game minute.
     */
    public final int getGameSegunds()
    {
        return _time % 10;
    }
    

Link to comment
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

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

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock