diff options
author | gumi <git@gumi.ca> | 2020-07-24 15:11:14 -0400 |
---|---|---|
committer | gumi <git@gumi.ca> | 2020-07-24 15:11:14 -0400 |
commit | 6d131f828e155ab0ed56d582cee1130291ab4a60 (patch) | |
tree | 352caf80e7f61a2859583716764aa135dec65343 /src/emap | |
parent | 4cf52a75e983abd5bda18da87fe1498e382fef23 (diff) | |
download | plugin-6d131f828e155ab0ed56d582cee1130291ab4a60.tar.gz plugin-6d131f828e155ab0ed56d582cee1130291ab4a60.tar.bz2 plugin-6d131f828e155ab0ed56d582cee1130291ab4a60.tar.xz plugin-6d131f828e155ab0ed56d582cee1130291ab4a60.zip |
add a script command to kick players offline
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 dc2976c..05ba6fa 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -218,6 +218,7 @@ HPExport void plugin_init (void) addScriptCommand("instanceowner", "i", InstanceOwner); addScriptCommand("aggravate", "i", aggravate); addScriptCommand("getnpcsubtype", "?", getNpcSubtype); + addScriptCommand("kick", "v?", kick); do_init_langs(); diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index 3e1a15a..86cf32f 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -2537,3 +2537,37 @@ BUILDIN(aggravate) script_pushint(st, true); 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; +} diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index 7582828..01c6b65 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -103,5 +103,6 @@ BUILDIN(readBattleParam); BUILDIN(InstanceOwner); BUILDIN(aggravate); BUILDIN(getNpcSubtype); +BUILDIN(kick); #endif // EVOL_MAP_SCRIPT_BUILDINS |