diff options
author | gumi <git@gumi.ca> | 2020-07-24 15:11:14 -0400 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-08-07 09:31:06 -0300 |
commit | 0902765036bc3fe663317043435b73aabe39677a (patch) | |
tree | 12ee77b64414282c8348e0833d4177e0da76c4a6 /src/emap | |
parent | 0c2be8405c29b8a228306c0da0317cb6d0be9699 (diff) | |
download | evol-hercules-0902765036bc3fe663317043435b73aabe39677a.tar.gz evol-hercules-0902765036bc3fe663317043435b73aabe39677a.tar.bz2 evol-hercules-0902765036bc3fe663317043435b73aabe39677a.tar.xz evol-hercules-0902765036bc3fe663317043435b73aabe39677a.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.
Diffstat (limited to 'src/emap')
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/script_buildins.c | 34 | ||||
-rw-r--r-- | src/emap/script_buildins.h | 1 |
3 files changed, 36 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index 5f662c6..8a401b2 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -217,6 +217,7 @@ HPExport void plugin_init (void) addScriptCommand("setitemoptionbyindex", "iii*", setItemOptionByIndex); addScriptCommand("isinstance", "i", isInstance); addScriptCommand("readbattleparam","ii",readBattleParam); + 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 da9ccf2..4c2ea93 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -2515,6 +2515,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 5c0544b..f753091 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -102,6 +102,7 @@ BUILDIN(getItemOptionParamByIndex); BUILDIN(setItemOptionByIndex); BUILDIN(isInstance); BUILDIN(readBattleParam); +BUILDIN(kick); // TMW2 Build Ins BUILDIN(getguildinfo); |