aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/script')
-rw-r--r--src/script/lua_api/l_server.cpp26
-rw-r--r--src/script/lua_api/l_server.h3
2 files changed, 29 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);
}
diff --git a/src/script/lua_api/l_server.h b/src/script/lua_api/l_server.h
index 21f300400..0d0aa45c8 100644
--- a/src/script/lua_api/l_server.h
+++ b/src/script/lua_api/l_server.h
@@ -79,6 +79,9 @@ private:
// unban_player_or_ip()
static int l_unban_player_or_ip(lua_State *L);
+ // kick_player(name, [message]) -> success
+ static int l_kick_player(lua_State *L);
+
// notify_authentication_modified(name)
static int l_notify_authentication_modified(lua_State *L);