summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-01-23 13:50:03 +0100
committerHaru <haru@dotalux.com>2015-01-24 14:37:26 +0100
commitdfe8337d9ddb1a0b356ae86de9955845d280b759 (patch)
treef13976e43362237a697216a09457c1fa0ea41fae /src/map/script.c
parent3cfc6ddac576e236ccad0497d8e2ed2ae827c2bb (diff)
downloadhercules-dfe8337d9ddb1a0b356ae86de9955845d280b759.tar.gz
hercules-dfe8337d9ddb1a0b356ae86de9955845d280b759.tar.bz2
hercules-dfe8337d9ddb1a0b356ae86de9955845d280b759.tar.xz
hercules-dfe8337d9ddb1a0b356ae86de9955845d280b759.zip
Added script command 'channelmes'
Special thanks to Dastgir Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c26
1 files changed, 26 insertions, 0 deletions
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