After doing this tutorial, you will be able to easily add more crowns/icons without the need of editing a lot of client code.
This also removes a lot of code in your client.
I made this quite a long time ago, so if there's anything wrong, please post so I can change the code and fix it. I want this to be working correctly for everyone
First add these in Client.java:
Code:
public Sprite getIcon(int rights)
{
if (rights > 0)
return modIcons[rights - 1];
return null;
}
public String getNameWithoutRights(String text)
{
if (text.length() > 0)
return text.substring(6);
return text;
}
public String getIconCode(int rights)
{
switch (rights)
{
case 1:
return "@mod1@";
case 2:
return "@mod2@";
case 3:
return "@adm1@";
default:
return "";
}
}
public byte getPlayerRights(String s)
{
if (s == null)
return 0;
if (s.startsWith("@mod1@"))
return 1;
if (s.startsWith("@mod2@"))
return 2;
if (s.startsWith("@adm1@"))
return 3;
return 0;
}
Search "String s1 = chatNames[k];" and replace something like this:
Code:
byte playerRights = getPlayerRights(s1);
f (s1 != null && s1.startsWith("@cr1@")) {
s1 = s1.substring(5);
playerRights = 1;
} else if (s1 != null && s1.startsWith("@cr2@")) {
s1 = s1.substring(5);
playerRights = 2;
}
with this:
Code:
byte playerRights = getPlayerRights(s1);
if(playerRights > 0)
s1 = s1.substring(6);
Now search for, it's a little bit down, "(chatType == 1 || chatType == 2)" or "(l == 1 || l == 2)" and replace the whole part with "modIcons[#].drawSprite" (all of those)
with this:
Code:
Sprite icon = getIcon(playerRights);
if(icon != null)
{
icon.drawSprite(xPos + 1, yPos - 12);
xPos += 14;
}
Scroll a bit down to "(chatType == 3 || chatType == 7)" or "(l == 3 || l == 7)" and replace the same modIcons stuff with this:
Code:
Sprite icon = getIcon(playerRights);
if (icon != null)
{
icon.drawSprite(xPos + 1, yPos - 12);
xPos += 14;
}
Now search "(publicChatMode == 2)" and above there you'll see something like
Code:
if (myPrivilege == 2)
pushMessage(myPlayer.textSpoken, 2, "@cr2@" + myPlayer.name);
else if (myPrivilege == 1)
pushMessage(myPlayer.textSpoken, 2, "@cr1@" + myPlayer.name);
else
pushMessage(myPlayer.textSpoken, 2, myPlayer.name);
Replace all that with this:
Code:
pushMessage(myPlayer.textSpoken, 2, getIconCode(myPrivilege) + myPlayer.name);
Search for "pushMessage(s, 2, " in method73 and replace the whole shit
with the following:
Code:
if (j2 > 0)
pushMessage(s, 1, getIconCode(j2) + player.name);
else
pushMessage(s, 2, player.name);
Find "pushMessage(s9, 3, " and again, replace all the pushMessage with:
Code:
if (l21 > 0)
pushMessage(s9, 7, getIconCode(l21) + TextClass.fixName(TextClass.nameForLong(l5)));
else
pushMessage(s9, 3, TextClass.fixName(TextClass.nameForLong(l5)));
Got to void drawSplitPrivateChat(), replace
with
Code:
byte playerRights = getPlayerRights(s);
s = getNameWithoutRights(s);
Still in there, replace
Code:
if (byte1 == 1) {
modIcons[0].drawBackground(k1, l - 12);
k1 += 14;
}
if (byte1 == 2) {
modIcons[1].drawBackground(k1, l - 12);
k1 += 14;
}
with this:
Code:
Sprite icon = getIcon(playerRights);
if (icon != null)
{
icon.drawSprite(k1 + 1, l - 12);
k1 += 14;
}
Got to "buildPublicChat" or "buildChatAreaMenu" and replace
Code:
flag = false;
if (s != null && s.startsWith("@cr1@")) {
s = s.substring(5);
flag1 = true;
}
if (s != null && s.startsWith("@cr2@")) {
s = s.substring(5);
byte0 = 2;
}
with:
Code:
s = getNameWithoutRights(s);
do the same at "buildFriendChat" or "buildSplitPrivateChatMenu", and also at "buildDuelorTrade".
If you can't find it, search for "@cr1@" and everytime you find it, there you need to replace it.
Compile and run. Test if it works. If not please say what's wrong so I can attempt to fix it (or fix it yourself, I'm NOT gonna help u if there's something like "cannot find s9", look trough your code and fix it urself)
Look in the post below how to add more crowns.
CREDITS:
99% me for the code.
1% JageX for the client and code we ripped from them.