From 72fe4cd51591b917e9ae6654879b9275c405188c Mon Sep 17 00:00:00 2001 From: Jeybla Date: Thu, 6 Apr 2017 23:55:58 +0200 Subject: [PATCH] Adds chatmes (scriptcommand). (#1924) * Adds chatmes script command. * chatmes writes a given message to the waitingroom of the NPC. --- doc/script_commands.txt | 12 ++++++++++++ src/map/script.c | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 1f526ed40a..9d5920a5d2 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -6121,6 +6121,18 @@ the attached NPC will display the message. --------------------------------------- +*chatmes ""{,""}; + +This command will display a message in the waitingroom (chat) of the NPC. +If the option is given, then that NPC will display the message, else +the attached NPC will display the message. +If the NPC is not in a waitingroom, nothing happens. + + // Everyone in the waitingroom will see this message: + chatmes "Waiting 5 minutes until the next match will start"; + +--------------------------------------- + *setnpcdisplay("", "", , ) *setnpcdisplay("", "", ) *setnpcdisplay("", "") diff --git a/src/map/script.c b/src/map/script.c index f53b799c7c..82c50b2099 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -14539,6 +14539,29 @@ BUILDIN_FUNC(npctalk) return SCRIPT_CMD_SUCCESS; } +/** + * Sends a message to the waitingroom of the invoking NPC. + * chatmes ""{,""}; + * @author Jey + */ +BUILDIN_FUNC(chatmes) +{ + struct npc_data* nd = NULL; + const char* str = script_getstr(st,2); + + if (script_hasdata(st, 3)) + nd = npc_name2id(script_getstr(st, 3)); + else + nd = (struct npc_data *)map_id2bl(st->oid); + + if (nd != NULL && nd->chat_id) { + char message[256]; + safesnprintf(message, sizeof(message), "%s", str); + clif_GlobalMessage(map_id2bl(nd->chat_id), message, CHAT_WOS); + } + return SCRIPT_CMD_SUCCESS; +} + // change npc walkspeed [Valaris] BUILDIN_FUNC(npcspeed) { @@ -22550,6 +22573,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(movenpc,"sii?"), // [MouseJstr] BUILDIN_DEF(message,"ss"), // [MouseJstr] BUILDIN_DEF(npctalk,"s?"), // [Valaris] + BUILDIN_DEF(chatmes,"s?"), // [Jey] BUILDIN_DEF(mobcount,"ss"), BUILDIN_DEF(getlook,"i?"), BUILDIN_DEF(getsavepoint,"i?"),