Jump to content
  • 0
Sign in to follow this  
Zirius

Where are the messages Hercules outputs in Logs and how to change color?

Question

Hello! If we allow to show exp gained/zeny gain in exp.conf
 
Hercules succesfully displays it, but how can I modify the message and the color? Green is lame I think. LOL.

 

UPDATE. How to change the color of "clif_disp_onlyself" output by src/map/pc.c?

 

	if(sd->state.showexp) {		char output[256];		sprintf(output,			"Experience Gained Base:%u (%.2f%%) Job:%u (%.2f%%)",base_exp,nextbp*(float)100,job_exp,nextjp*(float)100);		clif_disp_onlyself(sd,output,strlen(output));	}
Edited by Zirius

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

unfortunately ... hercules' clif->colormes is badly coded

if you really need it, you have to create another one ==> 'clif->colormes2'

 src/map/clif.c | 15 +++++++++++++++ src/map/clif.h |  1 + 2 files changed, 16 insertions(+)diff --git a/src/map/clif.c b/src/map/clif.cindex d9acf07..146e7a3 100644--- a/src/map/clif.c+++ b/src/map/clif.c@@ -8385,6 +8385,20 @@ int clif_colormes(int fd, enum clif_colors color, const char* msg) { 	return 0; } +int clif_colormes2(int fd, unsigned int color, const char* msg) {+	size_t msg_len = strlen(msg) + 1;++	WFIFOHEAD(fd,msg_len + 12);+	WFIFOW(fd,0) = 0x2C1;+	WFIFOW(fd,2) = msg_len + 12;+	WFIFOL(fd,4) = 0;+	WFIFOL(fd,8) = (color & 0x0000FF) << 16 | (color & 0x00FF00) | (color & 0xFF0000) >> 16;;+	safestrncpy((char*)WFIFOP(fd,12), msg, msg_len);+	WFIFOSET(fd, msg_len + 12);++	return 0;+}+ /// Monster/NPC color chat [SnakeDrak] (ZC_NPC_CHAT). /// 02c1 <packet len>.W <id>.L <color>.L <message>.?B void clif_messagecolor(struct block_list* bl, unsigned int color, const char* msg) {@@ -18835,6 +18849,7 @@ void clif_defaults(void) { 	clif->messageln = clif_displaymessage2; 	clif->messages = clif_displaymessage_sprintf; 	clif->colormes = clif_colormes;+	clif->colormes2 = clif_colormes2; 	clif->process_message = clif_process_message; 	clif->wisexin = clif_wisexin; 	clif->wisall = clif_wisall;diff --git a/src/map/clif.h b/src/map/clif.hindex e4de51a..291997d 100644--- a/src/map/clif.h+++ b/src/map/clif.h@@ -817,6 +817,7 @@ struct clif_interface { 	/* message+s(printf) */ 	void (*messages) (const int fd, const char *mes, ...) __attribute__((format(printf, 2, 3))); 	int (*colormes) (int fd, enum clif_colors color, const char* msg);+	int (*colormes2) (int fd, unsigned int color, const char* msg); 	bool (*process_message) (struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_); 	void (*wisexin) (struct map_session_data *sd,int type,int flag); 	void (*wisall) (struct map_session_data *sd,int type,int flag);
then you can do as the format
clif->colormes2( sd->fd, <color code>, "<message>" );
example like
clif->colormes2( sd->fd, 0xFF0000, "Red Light" );
Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

 

unfortunately ... hercules' clif->colormes is badly coded

if you really need it, you have to create another one ==> 'clif->colormes2'

 src/map/clif.c | 15 +++++++++++++++ src/map/clif.h |  1 + 2 files changed, 16 insertions(+)diff --git a/src/map/clif.c b/src/map/clif.cindex d9acf07..146e7a3 100644--- a/src/map/clif.c+++ b/src/map/clif.c@@ -8385,6 +8385,20 @@ int clif_colormes(int fd, enum clif_colors color, const char* msg) { 	return 0; } +int clif_colormes2(int fd, unsigned int color, const char* msg) {+	size_t msg_len = strlen(msg) + 1;++	WFIFOHEAD(fd,msg_len + 12);+	WFIFOW(fd,0) = 0x2C1;+	WFIFOW(fd,2) = msg_len + 12;+	WFIFOL(fd,4) = 0;+	WFIFOL(fd,8) = (color & 0x0000FF) << 16 | (color & 0x00FF00) | (color & 0xFF0000) >> 16;;+	safestrncpy((char*)WFIFOP(fd,12), msg, msg_len);+	WFIFOSET(fd, msg_len + 12);++	return 0;+}+ /// Monster/NPC color chat [SnakeDrak] (ZC_NPC_CHAT). /// 02c1 <packet len>.W <id>.L <color>.L <message>.?B void clif_messagecolor(struct block_list* bl, unsigned int color, const char* msg) {@@ -18835,6 +18849,7 @@ void clif_defaults(void) { 	clif->messageln = clif_displaymessage2; 	clif->messages = clif_displaymessage_sprintf; 	clif->colormes = clif_colormes;+	clif->colormes2 = clif_colormes2; 	clif->process_message = clif_process_message; 	clif->wisexin = clif_wisexin; 	clif->wisall = clif_wisall;diff --git a/src/map/clif.h b/src/map/clif.hindex e4de51a..291997d 100644--- a/src/map/clif.h+++ b/src/map/clif.h@@ -817,6 +817,7 @@ struct clif_interface { 	/* message+s(printf) */ 	void (*messages) (const int fd, const char *mes, ...) __attribute__((format(printf, 2, 3))); 	int (*colormes) (int fd, enum clif_colors color, const char* msg);+	int (*colormes2) (int fd, unsigned int color, const char* msg); 	bool (*process_message) (struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_); 	void (*wisexin) (struct map_session_data *sd,int type,int flag); 	void (*wisall) (struct map_session_data *sd,int type,int flag);
then you can do as the format
clif->colormes2( sd->fd, <color code>, "<message>" );
example like
clif->colormes2( sd->fd, 0xFF0000, "Red Light" );

 

Finally made it worked. (mam, your src are far too different from mine? Is that latest GIT?)

 

Just for precaution mam, the original says: 

 

clif_disp_onlyself()

does colormes2() will make sure it behaves as clif_disp_onlyself() ?

 

Thanks mam!

post-6720-0-69224400-1410202700_thumb.jpg

Share this post


Link to post
Share on other sites
  • 0

clif_disp_onlyself is actually clif->disp_message

https://github.com/HerculesWS/Hercules/blob/master/src/map/clif.h#L50

clif->disp_message is using guild-chat color to send message to the target

https://github.com/HerculesWS/Hercules/blob/master/src/map/clif.c#L8115

the packet starts with 0x17f

 

clif->colormes ... however, using different kind of packet

the packet starts with 0x2C1

and on the 4th field of the packet allows color coding, which clif->disp_message couldn't do

 

so no ... depends on how you deprecate it

they are doing the same thing, which display a message on player's chat box

just clif->colormes allows color code, but clif->disp_message couldn't

while they are actually using different types of packets

Share this post


Link to post
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
Answer this question...

×   Pasted as rich text.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.