add new scriptcommand
- dispcolor or displaymessage
displaymessage("<message>"{,<color>{,<Account ID>}})
now you can send message with color to player
Hex color see more : http://www.colorschemer.com/online.html
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -19110,6 +19110,34 @@ BUILDIN_FUNC(countspiritball) {
|
||||
return SCRIPT_CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/** Send message with color to player
|
||||
* displaymessage("<message>"{,<color>{,<Account ID>}})
|
||||
* @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); // <color>
|
||||
else
|
||||
color = 0xFFFFFF; // Default color
|
||||
|
||||
if (script_hasdata(st,4))
|
||||
sd = map_id2sd(script_getnum(st,4)); // <Account ID>
|
||||
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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user