diff --git a/src/map/clif.c b/src/map/clif.c index a79b0bff14..afec7f7a82 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8652,11 +8652,32 @@ void clif_messagecolor(struct block_list* bl, unsigned long color, const char* m WBUFW(buf,2) = msg_len + 12; WBUFL(buf,4) = bl->id; WBUFL(buf,8) = color; - memcpy(WBUFP(buf,12), msg, msg_len); + memcpy((char*)WBUFP(buf,12), msg, msg_len); clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC); } +void clif_messagecolor2(struct map_session_data *sd, unsigned long color, const char* msg) +{ + int fd; + unsigned short msg_len = strlen(msg) + 1; + + nullpo_retv(sd); + + if(msg_len > 0) { + color = (color & 0x0000FF) << 16 | (color & 0x00FF00) | (color & 0xFF0000) >> 16; // RGB to BGR + + fd = sd->fd; + WFIFOHEAD(fd, msg_len+12); + WFIFOW(fd,0) = 0x2C1; + WFIFOW(fd,2) = msg_len+12; + WFIFOL(fd,4) = 0; + WFIFOL(fd,8) = color; + safestrncpy((char*)WFIFOP(fd,12), msg, msg_len); + WFIFOSET(fd, WFIFOW(fd,2)); + } +} + /** * Notifies the client that the storage window is still open * diff --git a/src/map/clif.h b/src/map/clif.h index 096ec67826..07f4bdad7a 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -700,6 +700,7 @@ void clif_weather(int16 m); // [Valaris] void clif_specialeffect(struct block_list* bl, int type, enum send_target target); // special effects [Valaris] void clif_specialeffect_single(struct block_list* bl, int type, int fd); void clif_messagecolor(struct block_list* bl, unsigned long color, const char* msg); // Mob/Npc color talk [SnakeDrak] +void clif_messagecolor2(struct map_session_data *sd, unsigned long color, const char* msg); // Use for dispcolor [Napster] void clif_specialeffect_value(struct block_list* bl, int effect_id, int num, send_target target); void clif_GM_kickack(struct map_session_data *sd, int id); diff --git a/src/map/script.c b/src/map/script.c index f8767eafc0..5ad72717e1 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -19110,6 +19110,34 @@ BUILDIN_FUNC(countspiritball) { return SCRIPT_CMD_SUCCESS; } +/** Send message with color to player +* displaymessage(""{,{,}}) +* @param message +* @param color Hex color default (Green) +* @param account_id Target player (Optional) +* @author [Napster] +*/ +BUILDIN_FUNC(displaymessage) +{ + TBL_PC *sd; + int color; + const char *mes = script_getstr(st,2); + + if (script_hasdata(st,3)) + color = script_getnum(st,3); // + else + color = 0xFFFFFF; // Default color + + if (script_hasdata(st,4)) + sd = map_id2sd(script_getnum(st,4)); // + else + sd = script_rid2sd(st); // Attached player + + if (sd) + clif_messagecolor2(sd, color, mes); + return SCRIPT_CMD_SUCCESS; +} + #include "../custom/script.inc" // declarations that were supposed to be exported from npc_chat.c @@ -19653,6 +19681,8 @@ struct script_function buildin_func[] = { BUILDIN_DEF(addspiritball,"ii?"), BUILDIN_DEF(delspiritball,"i?"), BUILDIN_DEF(countspiritball,"?"), + BUILDIN_DEF(displaymessage,"s??"), + BUILDIN_DEF2(displaymessage,"dispcolor","s??"), #include "../custom/script_def.inc"