Where are you adding this timer?
Most proper place would be in the initialize void in client.java
|
Okay, I'm creating time played on server by my self. I am having an issue making the timer start. Some reason when you log on the timer don't start and it doesn't sendMessage like it should. If someone could maybe teamviewer me and maybe help me with this issue?
Where are you adding this timer?
Most proper place would be in the initialize void in client.java
I alright have it placed in there. The issue is the timer is not starting for some reason. I have this placed in "initialize":
getPA().loadTimer();
and in playerassistant:
public void loadTimer()
{
c.timePlayed = (System.currentTimeMillis() - c.timePlayed) / 1000;
if (c.timePlayed >= 60000) {// if at least 60 seconds have passed
c.timePlayed -= 60000;
c.timePlayedmin += 1;
c.timePlayed = System.currentTimeMillis();
}
if (c.timePlayedmin >= 60) {
c.timePlayedmin -= 60;
c.timePlayedhrs += 1;
}
}
That might not be correct but it was set so if it was at "0" timer it would start counting up. The issue is the timer dont start up like it should have.
Here's a better way to do it in my opinion: (on my phone so I will abbreviate)
Have just two variables, c.timePlayed and c.thisSession.
In initialize() add a c.thisSession = Sys.currentTime
In destruct add c.timePlayed += Sys.time - c.thisSession
No need to save thisSession.
If you want you can change the savePlayer method to also update this number (be sure to reset thisSession to the time of the save then)
For minutes and hours and stuff, just have a method that returns an int array after calculating those values.
I actually never thought of doing it that way, I would just save the first join date and count the days. Thanks might use in the future.
Anyway, OT: I suggest you don't put it in process or make a timer like that at all.. As it will cause alot of lag (depending on your player base). Use what Ronbo posted
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |