Thread: Timed Server Announcements [EVENTS]

Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1 Timed Server Announcements [EVENTS] 
    RuneFatality

    Join Date
    May 2009
    Age
    24
    Posts
    2,355
    Thanks given
    1,099
    Thanks received
    388
    Rep Power
    531
    For this tutorial you'll be needing EventManager. To get EventManager, click here: [Only registered and activated users can see links. ]

    Credits: MrFaranCool & Graham.
    Difficulty: 0.5
    Time to do: 2 mins


    Step 1.

    Add this void:

    Code:
    public void timedAnnouncer() { /*Method name*/
    			EventManager.getSingleton().addEvent(
    		new Event() { /*Starting the event thread*/
    			public void execute(EventContainer c) {
    		sM("[SERVER] - *MESSAGE HERE*");	
    		sM("[SERVER] - *MESSAGE HERE*");
    		sM("[SERVER] - *MESSAGE HERE*");
    				}
    		}, 50000); // Time between each announcement
    	};
    under:

    Code:
    public class client extends Player implements Runnable {

    Step 2

    Search for:

    Code:
    Case 121:
    Now add this code under or on top of replaceDoors();.

    Code:
    //Starts Announcer Event
    			timedAnnouncer();
    If you don't have replaceDoors();, just stick it in there, it doesn't really matter where it is tbh.

    Sorry for the indentation, Notepad++ fucked it up. If you're not using Delta, you'll get errors with the sM. Simply change that method according to your base. You can change the time between each announcement near the bottom of the snippet.


    You now have simple news announcements without using process();

    Rep is appreciated





    I'm Da Baws' Version:

    Quote Originally Posted by Im Da Baws View Post
    Improved:

    In the Server Class add

    Code:
    
    public void startTimedAnnouncer() { /*Method name*/
    			EventManager.getSingleton().addEvent(
    		new Event() { /*Starting the event thread*/
    			public void execute(EventContainer c) {
                                (Player p : PlayerHandler.players) {
                                          Client person = (Client) p;
               						if (p != null) { 
    		p.sM("[SERVER] - *MESSAGE HERE*");	
    		p.sM("[SERVER] - *MESSAGE HERE*");
    		p.sM("[SERVER] - *MESSAGE HERE*");
                                            }
    }
    				}
    		}, 50000); // Time between each announcement
    	};
    And under public static void main(java.lang.String args[]), initialise
    startTimedAnnouncer();

    There you go.


    iVariable's Version:

    Quote Originally Posted by iVariable View Post
    Code:
    public static void WorldTimer() {
    	EventManager.getSingleton().addEvent(new Event() {
    		public void execute(EventContainer c) {
    			PlayerHandler.yell("text here");
    		}
    	}, 600000);
    }
    Saves you looping =] could add gc() too


    It's up to you which one you use, all of them are simple and effective.
    Reply With Quote  
     

  2. #2  
    Super Donator


    Join Date
    Mar 2009
    Age
    25
    Posts
    1,393
    Thanks given
    316
    Thanks received
    408
    Rep Power
    608
    Improved:

    In the Server Class add

    Code:
    
    public void startTimedAnnouncer() { /*Method name*/
    			EventManager.getSingleton().addEvent(
    		new Event() { /*Starting the event thread*/
    			public void execute(EventContainer c) {
                                (Player p : PlayerHandler.players) {
                                          Client person = (Client) p;
               						if (p != null) { 
    		p.sM("[SERVER] - *MESSAGE HERE*");	
    		p.sM("[SERVER] - *MESSAGE HERE*");
    		p.sM("[SERVER] - *MESSAGE HERE*");
                                            }
    }
    				}
    		}, 50000); // Time between each announcement
    	};
    And under public static void main(java.lang.String args[]), initialise
    startTimedAnnouncer();

    There you go.
    Reply With Quote  
     

  3. #3  
    RuneFatality

    Join Date
    May 2009
    Age
    24
    Posts
    2,355
    Thanks given
    1,099
    Thanks received
    388
    Rep Power
    531
    I'll add to the the thread now.
    Reply With Quote  
     

  4. #4  
    RuneFatality

    Join Date
    May 2009
    Age
    24
    Posts
    2,355
    Thanks given
    1,099
    Thanks received
    388
    Rep Power
    531
    there
    Reply With Quote  
     

  5. #5  
    Respected Member

    Join Date
    Jan 2009
    Posts
    5,682
    Thanks given
    1,093
    Thanks received
    3,494
    Discord
    View profile
    Rep Power
    5000
    Code:
    public static void WorldTimer() {
    	EventManager.getSingleton().addEvent(new Event() {
    		public void execute(EventContainer c) {
    			PlayerHandler.yell("text here");
    		}
    	}, 600000);
    }
    Saves you looping =] could add gc() too
    Reply With Quote  
     

  6. #6  
    RuneFatality

    Join Date
    May 2009
    Age
    24
    Posts
    2,355
    Thanks given
    1,099
    Thanks received
    388
    Rep Power
    531
    Lol i'll add that too
    Reply With Quote  
     

  7. #7  
    Officially Retired

    Huey's Avatar
    Join Date
    Jan 2008
    Age
    19
    Posts
    16,489
    Thanks given
    3,387
    Thanks received
    7,726
    Rep Power
    5000
    Very nice even tho it was released numerous times.

    Listen children don't become this guy.
    Quote Originally Posted by Owner Spikey View Post
    Why can I attack lower level npc's in a matter of a mouse hover but for a higher level npc the only choice to attack is by right clicking option attack?

    Reply With Quote  
     

  8. #8  
    Registered Member
    Kelvin's Avatar
    Join Date
    Jun 2007
    Posts
    1,433
    Thanks given
    48
    Thanks received
    33
    Rep Power
    269
    Quote Originally Posted by iVariable View Post
    Code:
    public static void WorldTimer() {
    	EventManager.getSingleton().addEvent(new Event() {
    		public void execute(EventContainer c) {
    			PlayerHandler.yell("text here");
    		}
    	}, 600000);
    }
    Saves you looping =] could add gc() too
    not really
    look in the yell method, it will loop players there...

    you could also do random messages like this

    Code:
    	public Random r = new Random();
    	public void randomizeMessages() { /*Method name*/
    		final String[] messages = {"mesage 1", "message 2"};
    			EventManager.getSingleton().addEvent(
    		new Event() { /*Starting the event thread*/
    			public void execute(EventContainer c) {
    			        int offset = r.nextInt(messages.length);
                            	for(Player player : World.getWorld().getPlayers() {
    					player.getActionSender().sendMessage(messages[offset]);
    				}
    			}
    		}, 50000); // Time between each announcement
    	};
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  9. #9  
    Banned

    Join Date
    Jan 2009
    Age
    28
    Posts
    2,662
    Thanks given
    66
    Thanks received
    207
    Rep Power
    0
    Use the 2 minute timer that rune-server uses for checking status of server.
    Reply With Quote  
     

  10. #10  
    RuneFatality

    Join Date
    May 2009
    Age
    24
    Posts
    2,355
    Thanks given
    1,099
    Thanks received
    388
    Rep Power
    531
    Quote Originally Posted by digistr View Post
    Use the 2 minute timer that rune-server uses for checking status of server.
    People can change it as i stated in the tutorial.

    If you're not using Delta, you'll get errors with the sM. Simply change that method according to your base. You can change the time between each announcement near the bottom of the snippet.
    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
  •