mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add minetest.kick_player(name, reason)
This commit is contained in:
parent
ea0def381d
commit
857a49e081
6 changed files with 67 additions and 17 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue