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:
Originally Posted by Im Da Baws
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:
Originally Posted by iVariable
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.
Very nice even tho it was released numerous times.
Listen children don't become this guy.
Originally Posted by Owner Spikey
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?
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. ]
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.