From 93dc75d5f5a5fedf9893778604443becd6926a32 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 28 Sep 2015 22:45:51 +0300 Subject: Add chatjoin script command for join chat room. Format: chatjoin chat [,user [,password]] --- src/emap/init.c | 1 + src/emap/script.c | 34 ++++++++++++++++++++++++++++++++++ src/emap/script.h | 1 + 3 files changed, 36 insertions(+) diff --git a/src/emap/init.c b/src/emap/init.c index 31e27be..4c9ae8c 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -77,6 +77,7 @@ HPExport void plugin_init (void) addAtcommand("setskill", setSkill); + addScriptCommand("chatjoin", "i*", chatJoin); addScriptCommand("setcamnpc", "*", setCamNpc); addScriptCommand("setcam", "ii", setCam); addScriptCommand("movecam", "ii", moveCam); diff --git a/src/emap/script.c b/src/emap/script.c index 469e9bc..33f5d60 100644 --- a/src/emap/script.c +++ b/src/emap/script.c @@ -14,6 +14,7 @@ #include "common/socket.h" #include "common/strlib.h" #include "common/timer.h" +#include "map/chat.h" #include "map/chrif.h" #include "map/clif.h" #include "map/npc.h" @@ -1689,3 +1690,36 @@ BUILDIN(setBgTeam) data->teamId = teamId; return true; } + +// chatjoin chatId [,char [,password]] +BUILDIN(chatJoin) +{ + int chatId = script_getnum(st, 2); + TBL_PC *sd = NULL; + const char *password = ""; + if (script_hasdata(st, 4)) + { + if (script_isstringtype(st, 3)) + sd = map->nick2sd(script_getstr(st, 3)); + if (script_isstringtype(st, 4)) + password = script_getstr(st, 4); + } + else if (script_hasdata(st, 3)) + { + if (script_isstringtype(st, 3)) + sd = map->nick2sd(script_getstr(st, 3)); + } + else + { + sd = script->rid2sd(st); + } + if (!sd) + { + ShowWarning("player not found\n"); + script->reportsrc(st); + return false; + } + + chat->join(sd, chatId, password); + return true; +} diff --git a/src/emap/script.h b/src/emap/script.h index 6cd9d82..dc65855 100644 --- a/src/emap/script.h +++ b/src/emap/script.h @@ -57,5 +57,6 @@ BUILDIN(npcSit); BUILDIN(npcStand); BUILDIN(npcWalkTo); BUILDIN(setBgTeam); +BUILDIN(chatJoin); #endif // EVOL_MAP_SCRIPT -- cgit v1.2.3-70-g09d2