Thread: How to set a timer with eventManager?

Results 1 to 9 of 9
  1. #1 How to set a timer with eventManager? 
    Registered Member 2pro's Avatar
    Join Date
    Aug 2009
    Posts
    774
    Thanks given
    15
    Thanks received
    15
    Rep Power
    66
    I need help creating a timer with the eventManager. I want it to set to a certain amount and run to 0 if it's over 0. Same as a timer in process like this:

    Code:
    if(timer > 0) 
    	timer--;
    Used as a jail timer, if that is even possible. thx, will rep
    Quote Originally Posted by Gator God View Post
    The use of small code like this is what makes a server great.
    Quote Originally Posted by Shoes View Post
    First of all, that's my code. Second of all it is more efficient in many ways, they may not be big but it's the little things that count.
    Quote Originally Posted by Luke132 View Post
    A thread's age doesn't mean anything if the information in the topic is still relevant.
    Why is gravedigging disallowed then?
    Reply With Quote  
     

  2. #2  
    Registered Member 2pro's Avatar
    Join Date
    Aug 2009
    Posts
    774
    Thanks given
    15
    Thanks received
    15
    Rep Power
    66
    bump
    Quote Originally Posted by Gator God View Post
    The use of small code like this is what makes a server great.
    Quote Originally Posted by Shoes View Post
    First of all, that's my code. Second of all it is more efficient in many ways, they may not be big but it's the little things that count.
    Quote Originally Posted by Luke132 View Post
    A thread's age doesn't mean anything if the information in the topic is still relevant.
    Why is gravedigging disallowed then?
    Reply With Quote  
     

  3. #3  
    Registered Member D4NyZ's Avatar
    Join Date
    Sep 2008
    Age
    28
    Posts
    664
    Thanks given
    50
    Thanks received
    10
    Rep Power
    30
    *BUMP*
    I also need this.
    Spoiler for Retard below:

    Quote Originally Posted by dani_gonzales View Post
    dany i know u hate me because i am better then u,,,so stfu noob and stop spaming my posts or i conntact a moderator!

    Reply With Quote  
     

  4. #4  
    Registered Member 2pro's Avatar
    Join Date
    Aug 2009
    Posts
    774
    Thanks given
    15
    Thanks received
    15
    Rep Power
    66
    bump
    Quote Originally Posted by Gator God View Post
    The use of small code like this is what makes a server great.
    Quote Originally Posted by Shoes View Post
    First of all, that's my code. Second of all it is more efficient in many ways, they may not be big but it's the little things that count.
    Quote Originally Posted by Luke132 View Post
    A thread's age doesn't mean anything if the information in the topic is still relevant.
    Why is gravedigging disallowed then?
    Reply With Quote  
     

  5. #5  
    Registered Member D4NyZ's Avatar
    Join Date
    Sep 2008
    Age
    28
    Posts
    664
    Thanks given
    50
    Thanks received
    10
    Rep Power
    30
    Quote Originally Posted by D4NyZ View Post
    *BUMP*
    I also need this.
    C'mon!!!
    Spoiler for Retard below:

    Quote Originally Posted by dani_gonzales View Post
    dany i know u hate me because i am better then u,,,so stfu noob and stop spaming my posts or i conntact a moderator!

    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Jan 2007
    Age
    30
    Posts
    4,417
    Thanks given
    3
    Thanks received
    105
    Rep Power
    0
    Please wait 24 hours before you bump.
    Reply With Quote  
     

  7. #7  
    Registered Member
    PSNB's Avatar
    Join Date
    Aug 2009
    Posts
    885
    Thanks given
    8
    Thanks received
    103
    Rep Power
    590
    Not quite sure what you're asking, but I'll try to answer what I think you're asking.

    Set the delay to how long you want to wait before the event fires, then when it executes, teleport them out of the jail, and stop the event. Like so.

    Code:
    public final class JailEvent extends Event {
    	
            /**
    	 * The sentence time, in milliseconds.
    	 */
    	public static final int JAIL_TIME = 300000;
    	
    	/**
    	 * Creates the JailEvent.
    	 */
    	public JailEvent() {
    		super(0);
    	}
    
    	@Override
    	public void execute() {
    		if(this.getDelay() == 0) {
    			this.setDelay(JAIL_TIME);
    			/*
    			 * Teleport the player into the jail, and set anything
    			 * (such as a 'jailed' boolean) here. 
    			 */
    		} else {
    			/*
    			 * Teleport the player out of the jail, and unset anything
    			 * (such as a 'jailed' boolean) here.
    			 */
    			this.stop();
    		}
    		
    	}
    }
    Reply With Quote  
     

  8. #8  
    Registered Member 2pro's Avatar
    Join Date
    Aug 2009
    Posts
    774
    Thanks given
    15
    Thanks received
    15
    Rep Power
    66
    Finally a super awesome answer, i'll rep you whenever i can m8
    Quote Originally Posted by Gator God View Post
    The use of small code like this is what makes a server great.
    Quote Originally Posted by Shoes View Post
    First of all, that's my code. Second of all it is more efficient in many ways, they may not be big but it's the little things that count.
    Quote Originally Posted by Luke132 View Post
    A thread's age doesn't mean anything if the information in the topic is still relevant.
    Why is gravedigging disallowed then?
    Reply With Quote  
     

  9. #9  
    Registered Member
    PSNB's Avatar
    Join Date
    Aug 2009
    Posts
    885
    Thanks given
    8
    Thanks received
    103
    Rep Power
    590
    Quote Originally Posted by 2pro View Post
    Finally a super awesome answer, i'll rep you whenever i can m8
    No Problem.
    Reply With Quote  
     


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
  •