The richest man is not the one who has the most but the one who needs the least.
Join Date
Oct 2012
Gender
Posts
1,706
Reputation
166
Thanks
3,627
My Mood
[Tutorial] RealmRelay - Basics and Scripting
Hello babies!
Today I'm going to show you guys how to start doing your own Realm Relay scripts!
CHAPTER 1 : THE WORDS
Code:
What's Realm Relay?
A completely open RotMG proxy utility for those who cannot be bothered to figure out how to decrypt, parse, and re-encrypt packets.
(W8, WUUUT??)
Code:
What is a client?
The client is your client.swf. (The thing you use to play the game, duh!). It is also what comunicate with the server! (Look below).
Code:
What is a server?
The server is the thing that communicate with your client (PFFT). It is andled by the RotMG HQ.
Code:
What is a Proxy?
This is where it becomes interesting.
The proxy is like a middleman between your client and your server!
It can block and send packets!
Code:
What is a Packet?
Packets are little bits of data that the server and the client exchange.
Each Packets have an ID. Since they change kinda often, Realm Relay allow us to use a command to find the current ID. (More info about that when we will actually start to learn)
It goes like :
<Server> : Hey Mr. Client! What is your position?
<Client> : Braaap! Sir Server, my position is x : 8237 and y : 1823!
<Server> : Alright!
That was a 3 packet conversation !
CHAPTER 2 : JAVASCRIPT
Another thing that is awesome about Realm Relay : it use JavaScript. (.js)
JavaScript, with his abbreviation "JS", not to be confounded with the other language "Java", is an object oriented programming language.
For direct examples, it has been used a lot in MuleDump.
It allows us, the mortal fools, to code things easily!
Please understand that this tutorial is not totally made for you if you know NOTHING about JavaScript. There's a lot of tools that can teach you a lot easily than me. Such as CodeAcademy, that I myself used
(FYI, I started to learn JavaScript with Code Academy 25 days ago, and also finished 25 days ago.).
CHAPTER 3 : JAVASCRIPT AND REALM RELAY
To learn Realm Relay scripting, the best thing to do is to study the already made code.
PS: Use Notepadd++, bruh! (It's free)
For this, we are going to use DeVoidCoder's spamfilter code! (Because it is simple and easy to understand.)
Code:
// spamfilter.js
var ID_TEXT = $.findPacketId("TEXT");
var keywords = [
".info",
".net",
".org",
".us",
"% off",
"24/7",
"cheap",
"client",
"customer",
"del|very",
"delivery",
"dellvery",
"pric", // pricing/prices/price
"prize",
"satis", // satisfaction/satisfactory/satisfied
"service",
"stock",
"www"
];
function onServerPacket(event) {
// get the packet involved in this event
var packet = event.getPacket();
// if this event's packet is a TEXT packet...
if (packet.id() == ID_TEXT) {
// make text lowercase to match the keyword list
var text = packet.text.toLowerCase();
// loop through every keyword for testing
for (var i = 0; i < keywords.length; i++) {
// if keyword exists in the text...
if (text.indexOf(keywords[i]) != -1) {
// cancel the event to stop the packet from being sent to the client
event.cancel();
// break the loop because we already know the packet is spam
break;
}
}
}
}
Let's start by the beginning.
Code:
// spamfilter.js
Is just a comment. It means the program doesn't give a sh?t about it. If you didnt knew this, you should ABANDON THE THREAD! (Or go here.)
Code:
var ID_TEXT = $.findPacketId("TEXT");
We create a var named ID_TEXT, and this variable will hold the current ID of the "TEXT" packet using $.findPacketId("TEXT");.
(PS: We could say var TEXT = 83 but since the packet ids change often, Realm Relay will use a xml given by the server to update them automatically!
Q. It's cool and all, but what does the "TEXT" packet have inside it?
A. We will see it later!
(PS: For more info about the packet and what they contain, look at the script_help.txt included in the Realm Relay file.)
Now that we have imported the only packet that we will use in this script, we can set a variable containing all the terms we want to filter from the text and then remove the text packet before it sends to the client (more information below).
And now, the fun part!
Code:
function onServerPacket(event) {
// get the packet involved in this event
var packet = event.getPacket();
// if this event's packet is a TEXT packet...
if (packet.id() == ID_TEXT) {
// make text lowercase to match the keyword list
var text = packet.text.toLowerCase();
// loop through every keyword for testing
for (var i = 0; i < keywords.length; i++) {
// if keyword exists in the text...
if (text.indexOf(keywords[i]) != -1) {
// cancel the event to stop the packet from being sent to the client
event.cancel();
// break the loop because we already know the packet is spam
break;
}
}
}
}
Please note that this script have some comments (//thats a comment) to help you understand it, since I wont go trought it all.
No worries, it's pretty simple.
Code:
function onServerPacket(event) {
//Here, we handle all the packets we receive from the server
}
With this line of code we know we are going to handle all the packets inside the "{" and the other "}".
Also, note you can do the same thing with the client ;
Code:
function onClientPacket(event) {
//Here, we handle all the packets we sent to the server
}
To filter the packets, because we receive a lot of them at the same time, we are going to do this :
Code:
if (packet.id() == ID_TEXT){
//Everything we do when we get a text packet from the server
}
Now, to know what is the text inside the textpacket, we are going to create a variable named "text" with all the text inside it.
var text = packet.text.toLowerCase();
(PS: The "toLowerCase()" set every capital letters to lowercases one. EX: ("LoL" will now be "lol").
Just for fun, we are going to check everything else that the packet have inside it!
To do that, we are going to use the script_help.txt and try to find the "TEXT" information.
Here it is! :
TEXT
string name
int objectId
int numStars
int bubbleTime
string recipient
string text
string cleanText
We can see right there that theres a lot of thing! Such as, the name of the player, it objectId, the number of stars he have, etc. etc.!
And now, the rest of the code ;
Code:
// loop through every keyword for testing
for (var i = 0; i < keywords.length; i++) {
// if keyword exists in the text...
if (text.indexOf(keywords[i]) != -1) {
// cancel the event to stop the packet from being sent to the client
event.cancel();
// break the loop because we already know the packet is spam
break;
}
}
The loop (for (var i = 0; i < keywords.length; i++)) is something that is not really simple to understand if you're just a beginner.
Click here if you wish to understand it :
for (var i = 0; i < keywords.length; i++)
We create a variable named i that is equal to zero. If i is smaller than the number of keywords (Here, it's 18), we do
Bref, we do the loop (what is for (var i = 0; i < keywords.length; i++){ //HERE } ) until we verified if all the keywords.
Now, the rest.
Code:
if (text.indexOf(keywords[i]) != -1) {
// cancel the event to stop the packet from being sent to the client
event.cancel();
// break the loop because we already know the packet is spam
break;
}
(text.indexOf(keywords[i]) != -1){}
If there is one keywords (or more) inside the "text" from the text packet, we continue.
PS: != is "not equal".
Code:
event.cancel(); //We cancel the packet from being shown in the client.
break; // Stop trying to find keywords inside the text, since we already know its a spam!