From dfe8337d9ddb1a0b356ae86de9955845d280b759 Mon Sep 17 00:00:00 2001 From: Haru Date: Fri, 23 Jan 2015 13:50:03 +0100 Subject: Added script command 'channelmes' Special thanks to Dastgir Signed-off-by: Haru --- src/map/script.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/map/script.c') diff --git a/src/map/script.c b/src/map/script.c index a2ea86ac6..f50e56d2d 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -16,6 +16,7 @@ #include "atcommand.h" #include "battle.h" #include "battleground.h" +#include "channel.h" #include "chat.h" #include "chrif.h" #include "clif.h" @@ -19012,6 +19013,29 @@ BUILDIN(shopcount) { return true; } +/** + * @call channelmes("#channel", "message"); + * + * Sends a message through the specified chat channel. + * + */ +BUILDIN(channelmes) +{ + struct map_session_data *sd = script->rid2sd(st); + const char *channelname = script_getstr(st, 2); + struct channel_data *chan = channel->search(channelname, sd); + + if (!chan) { + script_pushint(st, 0); + return true; + } + + channel->send(chan, NULL, script_getstr(st, 3)); + + script_pushint(st, 1); + return true; +} + // declarations that were supposed to be exported from npc_chat.c #ifdef PCRE_SUPPORT BUILDIN(defpattern); @@ -19637,6 +19661,8 @@ void script_parse_builtin(void) { BUILDIN_DEF(tradertype,"i"), BUILDIN_DEF(purchaseok,""), BUILDIN_DEF(shopcount, "i"), + + BUILDIN_DEF(channelmes, "ss"), }; int i, len = ARRAYLENGTH(BUILDIN); RECREATE(script->buildin, char *, script->buildin_count + len); // Pre-alloc to speed up -- cgit v1.2.3-70-g09d2