forked from Mirrorlandia_minetest/minetest
Implemented disconnect_player (#10492)
Co-authored-by: rubenwardy <rw@rubenwardy.com>
This commit is contained in:
parent
c85aa0030f
commit
413be76c63
@ -6,6 +6,16 @@ local S = core.get_translator("__builtin")
|
||||
-- Misc. API functions
|
||||
--
|
||||
|
||||
-- @spec core.kick_player(String, String) :: Boolean
|
||||
function core.kick_player(player_name, reason)
|
||||
if type(reason) == "string" then
|
||||
reason = "Kicked: " .. reason
|
||||
else
|
||||
reason = "Kicked."
|
||||
end
|
||||
return core.disconnect_player(player_name, reason)
|
||||
end
|
||||
|
||||
function core.check_player_privs(name, ...)
|
||||
if core.is_player(name) then
|
||||
name = name:get_player_name()
|
||||
|
@ -5741,6 +5741,10 @@ Bans
|
||||
* `minetest.kick_player(name, [reason])`: disconnect a player with an optional
|
||||
reason.
|
||||
* Returns boolean indicating success (false if player nonexistant)
|
||||
* `minetest.disconnect_player(name, [reason])`: disconnect a player with an
|
||||
optional reason, this will not prefix with 'Kicked: ' like kick_player.
|
||||
If no reason is given, it will default to 'Disconnected.'
|
||||
* Returns boolean indicating success (false if player nonexistant)
|
||||
|
||||
Particles
|
||||
---------
|
||||
|
@ -310,8 +310,8 @@ int ModApiServer::l_ban_player(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// kick_player(name, [reason]) -> success
|
||||
int ModApiServer::l_kick_player(lua_State *L)
|
||||
// disconnect_player(name, [reason]) -> success
|
||||
int ModApiServer::l_disconnect_player(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
|
||||
@ -319,11 +319,11 @@ int ModApiServer::l_kick_player(lua_State *L)
|
||||
throw LuaError("Can't kick player before server has started up");
|
||||
|
||||
const char *name = luaL_checkstring(L, 1);
|
||||
std::string message("Kicked");
|
||||
std::string message;
|
||||
if (lua_isstring(L, 2))
|
||||
message.append(": ").append(readParam<std::string>(L, 2));
|
||||
message.append(readParam<std::string>(L, 2));
|
||||
else
|
||||
message.append(".");
|
||||
message.append("Disconnected.");
|
||||
|
||||
RemotePlayer *player = dynamic_cast<ServerEnvironment *>(getEnv(L))->getPlayer(name);
|
||||
if (player == NULL) {
|
||||
@ -554,7 +554,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(disconnect_player);
|
||||
API_FCT(remove_player);
|
||||
API_FCT(unban_player_or_ip);
|
||||
API_FCT(notify_authentication_modified);
|
||||
|
@ -97,8 +97,8 @@ 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);
|
||||
// disconnect_player(name, [reason]) -> success
|
||||
static int l_disconnect_player(lua_State *L);
|
||||
|
||||
// remove_player(name)
|
||||
static int l_remove_player(lua_State *L);
|
||||
|
Loading…
Reference in New Issue
Block a user