Make A Clan Chat!
Purpose: How to add a ClanChat on your server as a command code.
Description: This allows you to make a code that makes you join a user's clan and talk in that user's clan only. Perfect for Castle Wars or other team activities.
Difficulty: 3/10 (If you really get stuck, that is the problem)
Source used: Void-Pkz (:D)
Files Modified: Client.java
Step 1.
Look for this specific code:
Code:
public String specbar;
Now under that, add this:
Code:
public String clan = null; // Clan Chat by xx v0ider xx
Step 2:
After that code was added, all you have to do is do the command for the joining the clan
Go look for this code:
Code:
if (command.equalsIgnoreCase("god") && playerRights >= 2) {
(Some servers may not have this code, so I recommend to the people that do not have this to look for:
Code:
if (command.equalsIgnoreCase("
As a beginning command code)
Now under that TYPE of coding, add in:
Code:
}
if (command.toLowerCase().startsWith("joinclan")) {
try {
clan = command.substring(8);
sendMessage("You have joined the clan chat "+clan);
for(int i = 0; i < 50; i++) {
client p2 = (client) server.playerHandler.players[i];
if(p2.clan.equalsIgnoreCase(clan) && !p2.playerName.equals(playerName) && p2 != null) {
p2.sendMessage(playerName+" has joined the clan chat."); // by xx v0ider xx
}
}
} catch(Exception e) {
}
So this is the code to join a clan of a friend on the server you know. An example to use this is ::joinclan xx v0ider xx. And it should say
Code:
" xx v0ider xx has joined the clan chat."
Easy so far?
Ok now how to talk on in the clan chat. Under the code you just added, add this code to talk now:
Code:
}
if (command.startsWith("clan")) {
try {
for (int i = 0; i < server.playerHandler.maxPlayers; i++) {
client toClan = (client) server.playerHandler.players[i];
if (toClan != null && toClan.clan.equalsIgnoreCase(clan) && clan != null) {
toClan.sendMessage("["+clan+"] " +playerName+": "+command.substring(5)+""); // by xx v0ider xx
}
}
} catch(Exception e) {
}
}
Ok now for this, the way to this is, you do the code ::clan "type your message", like ::clan hi. This will turn up as
Code:
[Clan Name] xx v0ider xx: Hi.
Step 3:
Now that you know how to use your clan chat, other people on the server need to have a guide of how to use it. So this is how you are going to do it.
Ok to place this code, put it under the region to make it simpler. Or you can use your welcome screen menu and put the code under that because the text is going to be the same as that.
After you done finding that, add this:
Code:
}
public void ClanHelpMenu() {
//misc interface
clearQuestInterface();
sendQuest("Close Window", 18447);//Close Text//By 0wner v0id
sendQuest("Clan Help", 18450);//Title
sendQuest("", 18451);//Sub Title
sendQuest("1. Do ::join + Usersname clan name u wanna join", 18439);//Line 1
sendQuest("", 18440);//Line 2
sendQuest("2. ::clan [Say] ", 18441);//Line 3
sendQuest("To tell your clan what you wanna say", 18442);//Line 4
sendQuest("", 18443);//Line 5
sendQuest("Sorry for being basic, but atleast we have one X[)", 18446);//Line 6
sendQuest("Enjoy!", 18445);//Line 7
sendQuest("", 18444);//Line 8
showInterface(18436);
flushOutStream(); // by xx v0ider xx
}
Ok now, we are going to need to put this guide as a code so when someone types in the command code, this guide pops up.
Look for this:
Code:
} else if (command.equalsIgnoreCase("home")) {
Under that add this:
Code:
} else if (command.equalsIgnoreCase("clanhelp")) {
ClanHelpMenu(); //by xx v0ider xx
You are basically done, Save & Compile. :)
Here are some pictures for example:
Joining the ClanChat

Talking in the Chat

Clan Chat Help Menu

Credits
Me