-
Occupation Chat?
Hey guys , can i know how do i add like [occupation Name] Infront of the character name in default ? Like for example my occupation name is LazyMaster
Then when i talk to people my name will be [LazyMaster]RongYuan : blablabla Instead of just RongYuan :blablabla .
I wanna make for a few occupation . Please tell me how , i can't figure it out .
-
Re: Occupation Chat?
Generalchathandler.java
After
PHP Code:
if (!CommandProcessor.processCommand(c, text) && c.getPlayer().getCanTalk()) {
add something like
PHP Code:
if (c.getPlayer().getOccupation() != 0) { //if the player has any occupation (change this accordingly)
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.getChatText(c.getPlayer().getId(), "["+c.getPlayer().getOccupation()+"] " + c.getPlayer().getName() + ": " + text , c.getPlayer().getGMChat(), slea.readByte())); //don't blindly trust this part tho, read underneath
}
Just change the above. It's a general, untested, example of how it could be done. Could be different for your server. The idea behind it is to go to your generalchathandler, look for the part where it allows you to chat and it should have the broadcastMessage method there somewhere. Change the text variable (the part you typed) to what you want (in this case [occupationname] playername: text).
-
Re: Occupation Chat?
Oh okay . i got a problem , when i am done , it give me like : John : [Noob] John : hi ._.
-
Re: Occupation Chat?
If u copied what the guy said, it shoulda worked properly o.o
-
Re: Occupation Chat?
My script is below , I just have a problem , like i talk , it will go in John : [noob]John : blablabl .
But my occupation is BankaiRailer.
PHP Code:
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
String text = slea.readMapleAsciiString();
try {
try {
if (!CommandProcessor.processCommand(c, text) && c.getPlayer().getCanTalk()) {
if (c.getPlayer().getOccupation() != (MapleOccupations.BankaiRailer)) { //if the player has any occupation (change this accordingly)
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.getChatText(c.getPlayer().getId(),"[BankaiRailer]" + c.getPlayer().getName() + ": " + text , c.getPlayer().getGMChat(), slea.readByte())); //don't blindly trust this part tho, read underneath
ChatLog.getInstance().add("["+ChatLog.getInstance().generateTime()+"]" + " [All] " + c.getPlayer().getName() + ": " + text);
if (ChatLog.getInstance().getChat().size() >= 0) ChatLog.getInstance().makeLog(); //change 500 to w/e
}
if (!c.getPlayer().getCheatTracker().Spam(300, 1)) {
if (c.getPlayer().isDonor()) {
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.sendYellowTip("" + c.getPlayer().getName() + ": " + text));
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.getChatText(c.getPlayer().getId(), text, false, 1));
ChatLog.getInstance().add("["+ChatLog.getInstance().generateTime()+"]" + " [All] " + c.getPlayer().getName() + ": " + text);
if (ChatLog.getInstance().getChat().size() >= 0) ChatLog.getInstance().makeLog(); //change 500 to w/e
} else {
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.getChatText(c.getPlayer().getId(), text, c.getPlayer().getGMChat(), slea.readByte()));
ChatLog.getInstance().add("["+ChatLog.getInstance().generateTime()+"]" + " [All] " + c.getPlayer().getName() + ": " + text);
if (ChatLog.getInstance().getChat().size() >= 0) ChatLog.getInstance().makeLog(); //change 500 to w/e
}
}
}
} catch (RemoteException ex) {
Logger.getLogger(GeneralchatHandler.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalCommandSyntaxException ex) {
Logger.getLogger(GeneralchatHandler.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (SQLException ex) {
Logger.getLogger(GeneralchatHandler.class.getName()).log(Level.SEVERE, null, ex);
}
if (c.getPlayer().getWatcher() != null) {
c.getPlayer().getWatcher().dropMessage("[" + c.getPlayer().getName() + " All] : " + text);
}
}
}
Please tell me how to fix it .
-
Re: Occupation Chat?
-
Re: Occupation Chat?
Meh, there's something like the sendYellowTip method. Which makes it send a yellow message without your own name at the beginning. Don't quote me on this but I think there was one for normal text too. Find that one and use the same logic.
-
Re: Occupation Chat?
From what I see, the code u posted should work properly o.o
I don't see anything wrong with it. It should say [bankairailer] ign: text
-
Re: Occupation Chat?
I think broadcastMessage sends [ign] : text, which indeed results into ign [occ] ign. It was the idea behind it. He can play around with it.