aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/script/lua_api/l_server.cpp26
-rw-r--r--src/script/lua_api/l_server.h3
-rw-r--r--src/server.h3
3 files changed, 31 insertions, 1 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);
diff --git a/src/server.h b/src/server.h
index 21e9c811c..19bedf74a 100644
--- a/src/server.h
+++ b/src/server.h
@@ -330,6 +330,8 @@ public:
void peerAdded(con::Peer *peer);
void deletingPeer(con::Peer *peer, bool timeout);
+ void DenyAccess(u16 peer_id, const std::wstring &reason);
+
private:
friend class EmergeThread;
@@ -415,7 +417,6 @@ private:
void DiePlayer(u16 peer_id);
void RespawnPlayer(u16 peer_id);
- void DenyAccess(u16 peer_id, const std::wstring &reason);
void DeleteClient(u16 peer_id, ClientDeletionReason reason);
void UpdateCrafting(u16 peer_id);