can you maybe post your code?
|
I made a void using event manager to update the time of my server, but apparently I cant call a void in the sendFrame126 method. Any ideas of what I should do?
can you maybe post your code?
The event in the Player Assistant class:
The getTime() code in the Player Assistant class:Code:public static void updateTime() { EventManager.getSingleton().addEvent(new Event() { public void execute(EventContainer c) { getTime(); } }, 60000); }
The frame Im trying to send in the Player Assistant class:Code:public static String getTime() { DateFormat dateFormat = new SimpleDateFormat("HH:mm"); Date date = new Date(); return dateFormat.format(date); }
Code:sendFrame126("@or1@Time: @gre@" + c.updateTime(), 6300);
Your structure is wrong. What it now does is once you call sendFrame126(String, int) (to be more exact: every time you call sendFrame126(String, int), is start up an event that will forever repeat itself ever 60 seconds (for each time it's started). This method itself does not have a returntype (void). It's the method called by the event that has a returnType (String), but this isn't stored anywhere:
Code:getTime();The order should be like this:Code:String time = getTime();
You call the event (maximum once for every player, don't forget an if statement so it can stop).
The event calls sendFrame126(String, int).
In the sendFrame126(String, int), one of the substrings should be getTime instead of c.updateTime().
And there you go.
Wait, what? getTime is already a string, and if my sub string was getTime, it would be doing the same thing and still wouldn't be updating.
I don't know what this event manager thing is or the rules it is bound by, but this shouldn't be breaking any of them:
Code:public void getTime() { DateFormat dateFormat = new SimpleDateFormat("HH:mm"); Date date = new Date(); sendFrame126("@or1@Time: @gre@" + dateFormat.format(date), 6300); }
Substring, part of a string.
Your c.updateTime() is a substring of "@or1@Time: @gre@" + c.updateTime().
If it were to be c.updateTime() returned a string (which isn't the case).
The sollution proposed by Illuminate would work to.
Yea, how would I make it return a string?
Code:public static String getTime() { DateFormat dateFormat = new SimpleDateFormat("HH:mm"); Date date = new Date(); return dateFormat.format(date); }
No, the updateTime one.
Ahh I just want it to update without using process, witch Im doing right now because I cant solve this.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |