diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-09-28 22:45:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-09-28 22:45:51 +0300 |
commit | 93dc75d5f5a5fedf9893778604443becd6926a32 (patch) | |
tree | 65f144aa347c64852e8a45b38c35d9f7d4f6d0b6 /src | |
parent | 1cba537b28b4c0fd6edb1f4f30e4457fd441b6c9 (diff) | |
download | evol-hercules-93dc75d5f5a5fedf9893778604443becd6926a32.tar.gz evol-hercules-93dc75d5f5a5fedf9893778604443becd6926a32.tar.bz2 evol-hercules-93dc75d5f5a5fedf9893778604443becd6926a32.tar.xz evol-hercules-93dc75d5f5a5fedf9893778604443becd6926a32.zip |
Add chatjoin script command for join chat room.
Format: chatjoin chat [,user [,password]]
Diffstat (limited to 'src')
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/script.c | 34 | ||||
-rw-r--r-- | src/emap/script.h | 1 |
3 files changed, 36 insertions, 0 deletions
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 |