Updated: Now loads titles from file and titles can be instantly assigned
These are all the titles Jagex added as Loyalty Rewards - RuneScape - MMORPG - Titles.
You can easily add your own titles too.
Server
In player.java declare this
Code:
public int playerTitle;
Find
Code:
playerProps.writeByte(combatLevel);
Below it you will see something like
Code:
playerProps.writeWord(0);
REPLACE the 0 with playerTitle like this
Code:
playerProps.writeWord(playerTitle);
Ensure that the playerTitle variable is saved upon logout and use this method to give a player a title.
Code:
public void giveTitle(int titleId) {
this.playerTitle = titleId;
this.setAppearanceUpdateRequired(true);
}
Client
Create class Loyalty.java (you will have to change the cache path String)
add
Code:
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Loyalty {
public static String[] title = new String[30];
public static final String CACHE_PATH = "C:/RuneScape/"; //Change this to your cache directory
public static final String TITLE_PATH = CACHE_PATH + "titles.dat";
/**
* Loads the loyalty titles from the cache
*/
public static void loadTitles() {
DataInputStream dataInputStream;
try {
dataInputStream = new DataInputStream(new FileInputStream(
TITLE_PATH));
for (int i = 0; i < title.length; i++) {
title[i] = dataInputStream.readUTF();
}
dataInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Adds a title to the cache
*
* @param the
* loyalty title added
*/
public static void addTitle(String title) {
DataOutputStream dataOutputStream;
try {
dataOutputStream = new DataOutputStream(new FileOutputStream(
TITLE_PATH));
dataOutputStream.writeUTF(title);
dataOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Download the titles.dat file and add it to your cache directory
http://**********/jlg6bmrbrtw4/titles.dat
Now find
Code:
private void buildAtPlayerMenu
You should see something like
Code:
if (player.skill == 0) {
s = player.name
+ combatDiffColor(myPlayer.combatLevel, player.combatLevel)
+ " (level-" + player.combatLevel + ")";
} else {
s = player.name + " (skill-" + player.skill + ")";
}
Replace all that with this
Code:
if (player.skill == 0) {
s = player.name
+ combatDiffColor(myPlayer.combatLevel, player.combatLevel)
+ " (level-" + player.combatLevel + ")";
} else {
s = Loyalty.title[player.skill] + "@whi@ " + player.name
+ combatDiffColor(myPlayer.combatLevel, player.combatLevel)
+ " (level-" + player.combatLevel + ")";
}
Done, you will notice there is also a method in the Loyalty class to add custom titles