TheUnKnown
August 8th, 2010, 13:43
This tutorial will show you how to set an interval, and it will run the messages on that interval.
Tested Base: Pali, Pali Neo and now Bulby
Difficulty: 0\10 Mainly For New Players, And Still Useful
Before we start, I'll show you what we're going to make:
Only the registered members can see the link.
It Selects A random color, a random fact, and plays them back in a random order whatever you choose your interval to be. You can change the messages to whatever you want, so here we go!
Step 1: Go To Your Bulby>world folder, and create a file called RandomMessages.java make sure you spell right!
Place This in it (Change the messages to whatever you like):
package Bulby.world;
/*
* Class RandomMessages
*
* Sends Random Message's To Server Players
*
* Created by Time - Converted By TheUnKnown on RuneLocus
*/
import Bulby.players.Player;
import Bulby.util.Misc;
import Bulby.io.*;
public class RandomMessages {
Player p;
public RandomMessages(Player p) {
this.p = p;
}
public int time = 0;
/*
*Set This To The Message Interval, 300 is reasonable
*/
public int interval = 300;
/*
*The Messages ThemSelves You Can Add Or Remove =P
*/
String[] messages = {
"Did You Know If you die and have a freeze condition, you are still frozen for a few seconds.",
"Did You Know That RFacts = Random FACTS?",
"Your Avatar dosen't have any fingers",
"The Duel Arena alone, is larger then the Tree Gnome Village with its maze",
"There are 3 ruins in Wilderness.",
"If you walk five steps north, eleven steps west, and thirteen steps north from the Draynor Village bank first booth, you will find a dock leaf plant.",
"Every items' top is facing north when dropped.",
"There are only 10 magic trees in All And Runescape?.",
"Barrows brothers have Legend capes.",
"Bows and Granite Mauls are held in the wrong hand."
};
String[] getcolors = {
"<shad=0202><col=FFF000>", //YELLOW
"<shad=0202><col=FFFFF0>", //WHITE
"<shad=0202><col=0000FF>", //BLUE
"<shad=0202><col=FF0000>", //RED
"<shad=0202><col=0000>", //BLACK
"<shad=0202><col=00FF00>", //GREEN
};
public void CountDown() {
if(p.time == 0) {
p.time = interval;
}
}
public void CreateMessage() {
if(p.time == 120) {
p.frames.sendMessage(p, getcolors[(int)(Math.random() * getcolors.length)]+"[RFact]"+ messages[(int)(Math.random() * messages.length)]);
Misc.println("[RF]Sent A Message!");
}
}
public void process(Player p) {
if (p == null) {
return;
}
if (p.time > 0) {
p.time--;
}
CountDown();
CreateMessage();
}
}
Step 2: Making It Work, Go To Player.java in Bulby>Players Folder
Add This Import
import Bulby.world.RandomMessages;
Add This Int Under Another Int, Dont forget this:
public int time = 0;
Now Find public void process() { And Add This Right Under
RandomMessages RM = new RandomMessages(this);
RM.process(this);
99% Credits to Timetodothis (Only the registered members can see the link.) - 1% Cred to me for converting it.
Tested Base: Pali, Pali Neo and now Bulby
Difficulty: 0\10 Mainly For New Players, And Still Useful
Before we start, I'll show you what we're going to make:
Only the registered members can see the link.
It Selects A random color, a random fact, and plays them back in a random order whatever you choose your interval to be. You can change the messages to whatever you want, so here we go!
Step 1: Go To Your Bulby>world folder, and create a file called RandomMessages.java make sure you spell right!
Place This in it (Change the messages to whatever you like):
package Bulby.world;
/*
* Class RandomMessages
*
* Sends Random Message's To Server Players
*
* Created by Time - Converted By TheUnKnown on RuneLocus
*/
import Bulby.players.Player;
import Bulby.util.Misc;
import Bulby.io.*;
public class RandomMessages {
Player p;
public RandomMessages(Player p) {
this.p = p;
}
public int time = 0;
/*
*Set This To The Message Interval, 300 is reasonable
*/
public int interval = 300;
/*
*The Messages ThemSelves You Can Add Or Remove =P
*/
String[] messages = {
"Did You Know If you die and have a freeze condition, you are still frozen for a few seconds.",
"Did You Know That RFacts = Random FACTS?",
"Your Avatar dosen't have any fingers",
"The Duel Arena alone, is larger then the Tree Gnome Village with its maze",
"There are 3 ruins in Wilderness.",
"If you walk five steps north, eleven steps west, and thirteen steps north from the Draynor Village bank first booth, you will find a dock leaf plant.",
"Every items' top is facing north when dropped.",
"There are only 10 magic trees in All And Runescape?.",
"Barrows brothers have Legend capes.",
"Bows and Granite Mauls are held in the wrong hand."
};
String[] getcolors = {
"<shad=0202><col=FFF000>", //YELLOW
"<shad=0202><col=FFFFF0>", //WHITE
"<shad=0202><col=0000FF>", //BLUE
"<shad=0202><col=FF0000>", //RED
"<shad=0202><col=0000>", //BLACK
"<shad=0202><col=00FF00>", //GREEN
};
public void CountDown() {
if(p.time == 0) {
p.time = interval;
}
}
public void CreateMessage() {
if(p.time == 120) {
p.frames.sendMessage(p, getcolors[(int)(Math.random() * getcolors.length)]+"[RFact]"+ messages[(int)(Math.random() * messages.length)]);
Misc.println("[RF]Sent A Message!");
}
}
public void process(Player p) {
if (p == null) {
return;
}
if (p.time > 0) {
p.time--;
}
CountDown();
CreateMessage();
}
}
Step 2: Making It Work, Go To Player.java in Bulby>Players Folder
Add This Import
import Bulby.world.RandomMessages;
Add This Int Under Another Int, Dont forget this:
public int time = 0;
Now Find public void process() { And Add This Right Under
RandomMessages RM = new RandomMessages(this);
RM.process(this);
99% Credits to Timetodothis (Only the registered members can see the link.) - 1% Cred to me for converting it.