PDA

View Full Version : [508]Creating A Random Fact System - Bulby![508]



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.

Dodge'
September 28th, 2010, 22:49
will cause huge lag to your server, if your on bulby.

Fly
September 28th, 2010, 22:57
Ha, I found this funny. Good release though.

apache ah64
October 12th, 2010, 17:21
nice im starting a 508 project i will use it;)

Cjay0091
October 12th, 2010, 17:31
Proccess = fail. It will create more lag..

Scar
October 25th, 2010, 08:00
Its Nice N alll But Surely It Will Savagly Lagg Your Server If Your Useing Bulby (Which Im Not)

dds ledg
December 19th, 2010, 10:59
This doesnt even put any random messages...

Mister Multi
December 21st, 2010, 12:29
will cause huge lag to your server, if your on bulby.

Nah. Just clean the packets and use EventManager instead of process. :)

Mister Multi
December 21st, 2010, 12:29
Proccess = fail. It will create more lag..

You are so clever..

P.S. Sorry double-post. :/


nice im starting a 508 project i will use it;)

Remember to use EventManager instead of process or just use SB508 as the base. ;)

P.S. I am using Bulby myself, but I have cleant the packets and I use EventManager instead of process. :)

Tricky
December 28th, 2010, 13:48
Tbh I Like It. Might Add A Bit Later :P