summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-06-06 15:13:56 -0300
committerJesusaves <cpntb1@ymail.com>2021-06-06 15:13:56 -0300
commita93d1ecbc5995fd5431b69f8d3c368665c5196ef (patch)
treeff5cd7af99b63aa96e2e4bf5aec5a617043845e3
parent655301284da462c2b4aa77ad38e9d98b7cc6ef79 (diff)
downloadevol-hercules-a93d1ecbc5995fd5431b69f8d3c368665c5196ef.tar.gz
evol-hercules-a93d1ecbc5995fd5431b69f8d3c368665c5196ef.tar.bz2
evol-hercules-a93d1ecbc5995fd5431b69f8d3c368665c5196ef.tar.xz
evol-hercules-a93d1ecbc5995fd5431b69f8d3c368665c5196ef.zip
add a script command to kick players offline
Author: gumi <git@gumi.ca> Date: Fri Jul 24 15:11:14 2020 -0400 You are currently cherry-picking commit 6d131f8. This reverts commit a22e3af8232b2e72e2c610339b3fd4fc9a0693e9.
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/script_buildins.c34
-rw-r--r--src/emap/script_buildins.h1
3 files changed, 36 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index 40e7c47..1e750c8 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -219,6 +219,7 @@ HPExport void plugin_init (void)
addScriptCommand("isinstance", "i", isInstance);
addScriptCommand("readbattleparam","ii",readBattleParam);
addScriptCommand("getnpcsubtype", "?", getNpcSubtype);
+ addScriptCommand("kick", "v?", kick);
// TMW2 Custom Script Commands
addScriptCommand("getguildinfo","i",getguildinfo);
diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c
index b189f0a..d61811c 100644
--- a/src/emap/script_buildins.c
+++ b/src/emap/script_buildins.c
@@ -2605,6 +2605,40 @@ BUILDIN(readBattleParam)
return true;
}
+BUILDIN(kick)
+{
+ struct map_session_data *tsd = NULL;
+
+ if (script_isstringtype(st, 2)) {
+ tsd = map->nick2sd(script_getstr(st, 2), false);
+ } else {
+ tsd = map->id2sd(script_getnum(st, 2));
+ }
+
+ if (tsd == NULL) {
+ // silently fail
+ script_pushint(st, 0);
+ return true;
+ }
+
+ // clif_authfail_fd reason
+ // see https://github.com/ManaPlus/ManaPlus/blob/master/src/net/eathena/generalrecv.cpp#L48
+ int reason = 15; // default: 15 - disconnection forced by a GM
+
+ if (script_hasdata(st, 3)) {
+ reason = script_getnum(st, 3);
+ }
+
+ if (tsd->fd > 0) {
+ clif->authfail_fd(tsd->fd, reason);
+ } else {
+ map->quit(tsd);
+ }
+
+ script_pushint(st, 1);
+ return true;
+}
+
///////////////////////////////////////////////////////////////////////////////
// TMW2 Custom Commands
diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h
index d17c1f6..98812bd 100644
--- a/src/emap/script_buildins.h
+++ b/src/emap/script_buildins.h
@@ -104,6 +104,7 @@ BUILDIN(isInstance);
BUILDIN(readBattleParam);
BUILDIN(getNpcSubtype);
BUILDIN(getCraftRecipe);
+BUILDIN(kick);
// TMW2 Build Ins
BUILDIN(getguildinfo);