darkmeistersp Posted November 22, 2011 Posted November 22, 2011 With this modification you will have a new chat, like @main for another purposes. In this example I use @trading as an example. 1 -> Open src/map/atcommand.c and find: if(sd->state.mainchat) clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>. else clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>. } return 0; } Add below it: /*=================================== * Trading chat chat [darkmeistersp] * Usage: @trading <on|off|message> *-----------------------------------*/ ACMD_FUNC(trading) { if( message[0] ) { if(strcmpi(message, "on") == 0) { if(!sd->state.tradingchat) { sd->state.tradingchat = 1; clif_displaymessage(fd, msg_txt(950)); // trading chat has been activated. } else { clif_displaymessage(fd, msg_txt(951)); // trading chat already activated. } } else if(strcmpi(message, "off") == 0) { if(sd->state.tradingchat) { sd->state.tradingchat = 0; clif_displaymessage(fd, msg_txt(952)); // trading chat has been disabled. } else { clif_displaymessage(fd, msg_txt(953)); // trading chat already disabled. } } else { if(!sd->state.tradingchat) { sd->state.tradingchat = 1; clif_displaymessage(fd, msg_txt(950)); // trading chat has been activated. } if (sd->sc.data[sC_NOCHAT] && sd->sc.data[sC_NOCHAT]->val1&MANNER_NOCHAT) { clif_displaymessage(fd, msg_txt(957)); return -1; } sprintf(atcmd_output, msg_txt(956), sd->status.name, message); // I use 0xFE000000 color for signalizing that this message is // trading chat message. 0xFE000000 is invalid color, same using // 0xFF000000 for simple (not colored) GM messages. [LuzZza] intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0, 0, 0, 0); } } else { if(sd->state.tradingchat) clif_displaymessage(fd, msg_txt(954)); // trading chat currently enabled. Usage: @trading <on|off>, @trading <message>. else clif_displaymessage(fd, msg_txt(955)); // trading chat currently disabled. Usage: @trading <on|off>, @trading <message>. } return 0; } Then you need to find this: { "font", 1,1, atcommand_font }, And add below it: { "trading", 1,1, atcommand_trading }, //[darkmeistersp] Save this file. 2-> Open src/map/clif.c and find: case CHAT_MAINCHAT: //[LuzZza] iter = mapit_getallusers(); while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL ) { if( tsd->state.mainchat && tsd->chatID == 0 && packet_db[tsd->packet_ver][RBUFW(buf,0)].len ) { // packet must exist for the client version WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); WFIFOSET(tsd->fd,len); } } mapit_free(iter); break; Add below it: case CHAT_TRADINGCHAT: //[darkmeistersp] iter = mapit_getallusers(); while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL ) { if( tsd->state.tradingchat && tsd->chatID == 0 && packet_db[tsd->packet_ver][RBUFW(buf,0)].len ) { // packet must exist for the client version WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); WFIFOSET(tsd->fd,len); } } mapit_free(iter); break; Now find this in the same file: WBUFW(buf,0)=0x8d; WBUFW(buf,2)=len+8; WBUFL(buf,4)=0; safestrncpy((char *) WBUFP(buf,8),message,len); clif_send(buf,WBUFW(buf,2),NULL,CHAT_MAINCHAT); } And add below it: /*========================================== * Send trading chat message [darkmeistersp] *------------------------------------------*/ void clif_TradingChatMessage(const char* message) { char buf[200]; int len; if(!message) return; len = strlen(message)+1; if (len+8 > sizeof(buf)) { ShowDebug("clif_TradingChatMessage: Received message too long (len %d): %sn", len, message); len = sizeof(buf)-8; } WBUFW(buf,0)=0x8d; WBUFW(buf,2)=len+8; WBUFL(buf,4)=0; strncpy((char *) WBUFP(buf,8),message,len); clif_send((unsigned char *) buf,WBUFW(buf,2),NULL,CHAT_TRADINGCHAT); } Now find the next code: // Chat logging type 'M' / Main Chat if( log_config.chat&1 || (log_config.chat&32 && !((agit_flag || agit2_flag) && log_config.chat&64)) ) log_chat("M", 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message); return; } And add below it: // Trading chat [darkmeistersp] if(strcmpi(target, trading_chat_nick) == 0) { if(!sd->state.tradingchat) clif_displaymessage(fd, msg_txt(958)); // You should enable trading chat with "@trading on" command. else { char output[256]; snprintf(output, ARRAYLENGTH(output), msg_txt(956), sd->status.name, message); intif_broadcast2(output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0); } } Save this file. 3-> Open src/map/clif.h and find this: CHAT_MAINCHAT, // everyone on main chat Add below it: CHAT_TRADINGCHAT, //[darkmeistersp] In the same file find this line: void clif_MainChatMessage(const char* message); //luzza And add below it: void clif_TradingChatMessage(const char* message); //[darkmeistersp] Save this file. 4-> Open src/map/map.c and find this: char main_chat_nick[16] = "Main"; Add below this: char trading_chat_nick[16] = "Trading"; //[darkmeistersp] In the same file find: if(strcmpi(w1, "main_chat_nick")==0) safestrncpy(main_chat_nick, w2, sizeof(main_chat_nick)); And add below it: if(strcmpi(w1, "trading_chat_nick")==0) //[darkmeistersp] safestrncpy(trading_chat_nick, w2, sizeof(trading_chat_nick)); Save this file. 5 -> Now open src/map/map.h and find: extern char main_chat_nick[16]; Add below it: extern char trading_chat_nick[16]; //[darkmeistersp] Save this file 6 -> Open src/map/pc.h and find: unsigned int mainchat :1; //[LuzZza] And add below it: unsigned int tradingchat :1; //[darkmeistersp] Save this file. 7 -> Open src/char/char.c and find: // check for reserved names if( strcmpi(name, main_chat_nick) == 0 || strcmpi(name, wisp_server_name) == 0 ) return -1; // nick reserved for internal server messages Replace it with: // check for reserved names if( strcmpi(name, main_chat_nick) == 0 || strcmpi(name, wisp_server_name) == 0 || strcmpi(name, trading_chat_nick) == 0) //[darkmeistersp] return -1; // nick reserved for internal server messages Save this file. 8-> Open src/char/inter.c and find: char main_chat_nick[16] = "Main"; Add below it: char trading_chat_nick[16] = "Trading"; //[darkmeistersp] Now find this in the same file: } else if(strcmpi(w1, "main_chat_nick")==0){ // Main chat nick [LuzZza] safestrncpy(main_chat_nick, w2, sizeof(main_chat_nick)); And add below it: } else if(strcmpi(w1, "trading_chat_nick")==0){ // trading chat nick [darkmeistersp] safestrncpy(trading_chat_nick, w2, sizeof(trading_chat_nick)); Save this file. 9-> Open src/char/inter.h and find: extern char main_chat_nick[16]; Add below it: extern char trading_chat_nick[16]; //[darkmeistersp] Save this file. 10-> Repeat the steps 7, 8 and 9 with the files char.c, inter.c and inter.h that are located in src/char_sql/ 11-> Open conf/msg_athena.conf and add at the end of the file: 950: Trading chat has been activated. 951: Trading chat already activated. 952: Trading chat has been disabled. 953: Trading chat already disabled. 954: Trading chat is currently enabled. Usage: @trading <on|off>, @trading <message>. 955: Trading chat is currently disabled. Usage: @trading <on|off>, @trading <message>. 956: %s :Trading: %s 957: You cannot use Trading chat while muted. 958: You should enable trading chat with "@trading on" command. Save this file. 12 -> Open conf/inter_athena.conf and find this: // Nick for sending mainchat // messages like whisper main_chat_nick: Main Add below it: // Nick trading chat [darkmeisterp] sell_chat_nick: trading Save this file. 13 -> Open conf/atcommand_athena.conf and add at the end of the file: //Trading chat trading: 1,1 That´s all. Now you must compile your server and your new chat is ready! Here you have the diff for this mod. Enjoy it! newchat.patch 5 Quote
WishBone Posted November 22, 2011 Posted November 22, 2011 (edited) Sounds interesting. Can we get screenshots or a video of how it looks like in game? Edited November 22, 2011 by WishBone Quote
darkmeistersp Posted November 22, 2011 Author Posted November 22, 2011 Sure, I´m uploading a screenshot right now. Quote
randell1993 Posted November 22, 2011 Posted November 22, 2011 so this means anything you type will be sent as like that? Quote
darkmeistersp Posted November 22, 2011 Author Posted November 22, 2011 Yes, is the same as @main but @trading. I used this for creating a chat for selling/buying items. Quote
randell1993 Posted November 22, 2011 Posted November 22, 2011 uhm is there a way to modify this so that only ppl with fid=1 ( sql column on login table ) can only read the msg and if they're not on the same fid they cannot use it thnx again Quote
darkmeistersp Posted November 22, 2011 Author Posted November 22, 2011 I updated the guide with one more step. uhm is there a way to modify this so that only ppl with fid=1 ( sql column on login table ) can only read the msg and if they're not on the same fid they cannot use it thnx again Why don´t you simply change the GM level for the command in atcommand_athena to a level you want and give this GM level to the players? Quote
randell1993 Posted November 22, 2011 Posted November 22, 2011 (edited) lol thnx anyways ill try to figure out myself since i need this for my faction system Edited November 22, 2011 by randell1993 Quote
Sneaky Posted November 22, 2011 Posted November 22, 2011 This is an extraordinary feat. Is there anyway to make it display different, like... [#Trading] - [CharName: message_here] Good Job though ! Quote
darkmeistersp Posted November 22, 2011 Author Posted November 22, 2011 This is an extraordinary feat. Is there anyway to make it display different, like... [#Trading] - [CharName: message_here] Good Job though ! Try changing this in msg_athena.conf: 956: %s :Trading: %s Replace to: 956: Trading - %s : %s Quote
Sneaky Posted November 22, 2011 Posted November 22, 2011 Try changing this in msg_athena.conf: 956: %s :Trading: %s Replace to: 956: Trading - %s : %s That's not really what I meant, what I meant was that in the CHAT it appears like this: [#Trading] - [CharName: message_here] [#Trading] - [lolete: hi eAthena!!!] Instead of: lolete: Trading: hi eAthena!!! Quote
darkmeistersp Posted November 22, 2011 Author Posted November 22, 2011 You want this right? Change the msg in msg_athena.conf 956: Trading - %s : %s for 956: [#Trading] - [%s: %s] Quote
Sneaky Posted November 23, 2011 Posted November 23, 2011 That's what I meant, thanks a lot, will definitely be using this feat. Quote
jTynne Posted November 23, 2011 Posted November 23, 2011 VERY awesome modification! Thanks for releasing this to the public! Quote
darkmeistersp Posted November 24, 2011 Author Posted November 24, 2011 *UPDATED: I´ve added the diff for the mod. Enjoy it! Quote
Mystery Posted November 26, 2011 Posted November 26, 2011 Hm, very cool mod. I'll be using this in the future. Thanks for the release ;D Quote
Diconfrost VaNz Posted November 26, 2011 Posted November 26, 2011 i love this mod... how can i put some delay on it? for example, before you can use it you must wait for 1minute just like a broadcaster(just for anti-flooding purposes) Quote
KeiKun Posted November 26, 2011 Posted November 26, 2011 @ TS nice released already tried once i thought another Snippet with No diff file since i hate manually adding~ Quote
jTynne Posted November 27, 2011 Posted November 27, 2011 This would be a wonderful addition to the emulator as many servers that I've played recently have opted to go this route. Five stars for this mate! Quote
Sneaky Posted November 27, 2011 Posted November 27, 2011 Actually I just tested this yesterday and turned out that I had to turn @main on first in order to use @trading. Not sure if you guys are getting the same problem. I even checked the codes 3 times, everything seem'd to be fine. Quote
jTynne Posted November 27, 2011 Posted November 27, 2011 Hmm, yeah, I see I'm also having the same issue. Are you able to PM "Trading", as I'm unable to do so. That'd be a nice addition to this. Messages to @trading are displaying on @main for whatever reason. No compilation errors, however. Quote
darkmeistersp Posted November 27, 2011 Author Posted November 27, 2011 I´m going to revise the code. Quote
Mirage Posted December 4, 2011 Posted December 4, 2011 Love it!! Question... Would the code stop working if I replace the "trade" related works with "market" ? ..or am I not allowed to revise the code Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.