diff options
Diffstat (limited to 'src/script/lua_api/l_server.cpp')
-rw-r--r-- | src/script/lua_api/l_server.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/script/lua_api/l_server.cpp b/src/script/lua_api/l_server.cpp index 9d3575a72..dc05ccbbe 100644 --- a/src/script/lua_api/l_server.cpp +++ b/src/script/lua_api/l_server.cpp @@ -160,6 +160,31 @@ int ModApiServer::l_ban_player(lua_State *L) return 1; } +// kick_player(name, [reason]) -> success +int ModApiServer::l_kick_player(lua_State *L) +{ + NO_MAP_LOCK_REQUIRED; + const char *name = luaL_checkstring(L, 1); + std::string message; + if (lua_isstring(L, 2)) + { + message = std::string("Kicked: ") + lua_tostring(L, 2); + } + else + { + message = "Kicked."; + } + Player *player = getEnv(L)->getPlayer(name); + if (player == NULL) + { + lua_pushboolean(L, false); // No such player + return 1; + } + getServer(L)->DenyAccess(player->peer_id, narrow_to_wide(message)); + lua_pushboolean(L, true); + return 1; +} + // unban_player_or_ip() int ModApiServer::l_unban_player_or_ip(lua_State *L) { @@ -327,6 +352,7 @@ void ModApiServer::Initialize(lua_State *L, int top) API_FCT(get_ban_list); API_FCT(get_ban_description); API_FCT(ban_player); + API_FCT(kick_player); API_FCT(unban_player_or_ip); API_FCT(notify_authentication_modified); } |