Thread: updateTime

Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1 updateTime 
    Registered Member
    Join Date
    Mar 2010
    Posts
    152
    Thanks given
    1
    Thanks received
    3
    Rep Power
    1
    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?
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Jan 2009
    Age
    31
    Posts
    2,661
    Thanks given
    66
    Thanks received
    207
    Rep Power
    0
    can you maybe post your code?
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Mar 2010
    Posts
    152
    Thanks given
    1
    Thanks received
    3
    Rep Power
    1
    The event in the Player Assistant class:

    Code:
    	public static void updateTime() {
    		EventManager.getSingleton().addEvent(new Event() {
    		public void execute(EventContainer c) {
    			getTime();
    		}
    		}, 60000);
    	}
    The getTime() code in the Player Assistant class:

    Code:
    	public static String getTime() {
    			DateFormat dateFormat = new SimpleDateFormat("HH:mm");
    			Date date = new Date();
    			return dateFormat.format(date);
    
    	}
    The frame Im trying to send in the Player Assistant class:

    Code:
    sendFrame126("@or1@Time: @gre@" + c.updateTime(), 6300);
    Reply With Quote  
     

  4. #4  
    Registered Member
    Its paris's Avatar
    Join Date
    Apr 2009
    Posts
    1,141
    Thanks given
    56
    Thanks received
    234
    Rep Power
    689
    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();
    Code:
    String time = getTime();
    The order should be like this:
    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.
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Mar 2010
    Posts
    152
    Thanks given
    1
    Thanks received
    3
    Rep Power
    1
    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.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Whired's Avatar
    Join Date
    Aug 2007
    Posts
    2,126
    Thanks given
    238
    Thanks received
    500
    Rep Power
    822
    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);
    }
    Reply With Quote  
     

  7. #7  
    Registered Member
    Its paris's Avatar
    Join Date
    Apr 2009
    Posts
    1,141
    Thanks given
    56
    Thanks received
    234
    Rep Power
    689
    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.
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Mar 2010
    Posts
    152
    Thanks given
    1
    Thanks received
    3
    Rep Power
    1
    Yea, how would I make it return a string?
    Reply With Quote  
     

  9. #9  
    Registered Member
    Its paris's Avatar
    Join Date
    Apr 2009
    Posts
    1,141
    Thanks given
    56
    Thanks received
    234
    Rep Power
    689
    Code:
    public static String getTime() {
    	DateFormat dateFormat = new SimpleDateFormat("HH:mm");
    	Date date = new Date();
    	return dateFormat.format(date);
    }
    Reply With Quote  
     

  10. #10  
    Registered Member
    Join Date
    Mar 2010
    Posts
    152
    Thanks given
    1
    Thanks received
    3
    Rep Power
    1
    No, the updateTime one.

    Ahh I just want it to update without using process, witch Im doing right now because I cant solve this.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •