summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/script.c34
-rw-r--r--src/emap/script.h1
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