Jump to content

[SRC] Adding a new Chat


darkmeistersp

Recommended Posts


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  70
  • Reputation:   12
  • Joined:  11/18/11
  • Last Seen:  

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

screenDualRO041.jpg

That´s all. Now you must compile your server and your new chat is ready! /oh

Here you have the diff for this mod. Enjoy it!

newchat.patch

  • Upvote 5
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   7
  • Joined:  11/21/11
  • Last Seen:  

Sounds interesting. Can we get screenshots or a video of how it looks like in game?

Edited by WishBone
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  70
  • Reputation:   12
  • Joined:  11/18/11
  • Last Seen:  

Sure, I´m uploading a screenshot right now.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  148
  • Reputation:   8
  • Joined:  11/20/11
  • Last Seen:  

wow thanks for the share

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  26
  • Topics Per Day:  0.01
  • Content Count:  2244
  • Reputation:   182
  • Joined:  11/19/11
  • Last Seen:  

wow nice!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  76
  • Reputation:   4
  • Joined:  11/15/11
  • Last Seen:  

so this means anything you type will be sent as like that?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  70
  • Reputation:   12
  • Joined:  11/18/11
  • Last Seen:  

Yes, is the same as @main but @trading. I used this for creating a chat for selling/buying items.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  76
  • Reputation:   4
  • Joined:  11/15/11
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  70
  • Reputation:   12
  • Joined:  11/18/11
  • Last Seen:  

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?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  76
  • Reputation:   4
  • Joined:  11/15/11
  • Last Seen:  

lol thnx anyways ill try to figure out myself

since i need this for my faction system

Edited by randell1993
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  392
  • Reputation:   47
  • Joined:  11/18/11
  • Last Seen:  

This is an extraordinary feat. Is there anyway to make it display different, like...

[#Trading] - [CharName: message_here]

Good Job though /oh!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  70
  • Reputation:   12
  • Joined:  11/18/11
  • Last Seen:  

This is an extraordinary feat. Is there anyway to make it display different, like...

[#Trading] - [CharName: message_here]

Good Job though /oh!

Try changing this in msg_athena.conf:

956: %s :Trading: %s

Replace to:

956: Trading - %s : %s

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  392
  • Reputation:   47
  • Joined:  11/18/11
  • Last Seen:  

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!!!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  70
  • Reputation:   12
  • Joined:  11/18/11
  • Last Seen:  

screenDualRO042.jpg

You want this right?

Change the msg in msg_athena.conf

956: Trading - %s : %s

for

956: [#Trading] - [%s: %s]

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  392
  • Reputation:   47
  • Joined:  11/18/11
  • Last Seen:  

That's what I meant, thanks a lot, will definitely be using this feat.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  399
  • Reputation:   198
  • Joined:  11/09/11
  • Last Seen:  

VERY awesome modification! Thanks for releasing this to the public!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  70
  • Reputation:   12
  • Joined:  11/18/11
  • Last Seen:  

*UPDATED: I´ve added the diff for the mod. Enjoy it!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

Hm, very cool mod. I'll be using this in the future. Thanks for the release ;D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  974
  • Reputation:   41
  • Joined:  11/13/11
  • Last Seen:  

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)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  967
  • Reputation:   53
  • Joined:  11/13/11
  • Last Seen:  

@ TS

nice released

already tried

once i thought another Snippet with No diff file

since i hate manually adding~

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  399
  • Reputation:   198
  • Joined:  11/09/11
  • Last Seen:  

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! :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  392
  • Reputation:   47
  • Joined:  11/18/11
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  399
  • Reputation:   198
  • Joined:  11/09/11
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  217
  • Reputation:   18
  • Joined:  11/20/11
  • Last Seen:  

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...