diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-04-23 14:35:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-23 14:35:08 +0200 |
commit | 29ab20c27229672c24a7699afbcd54caad903331 (patch) | |
tree | e42e7ea35f54b1439055abc500191eb29baa6355 /src/script/lua_api | |
parent | dda171d2925e20efc00c78bcb45cf595fd986da9 (diff) | |
download | minetest-29ab20c27229672c24a7699afbcd54caad903331.tar.gz minetest-29ab20c27229672c24a7699afbcd54caad903331.tar.bz2 minetest-29ab20c27229672c24a7699afbcd54caad903331.zip |
Player data to Database (#5475)
* Player data to Database
Add player data into databases (SQLite3 & PG only)
PostgreSQL & SQLite: better POO Design for databases
Add --migrate-players argument to server + deprecation warning
* Remove players directory if empty
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_server.cpp | 17 | ||||
-rw-r--r-- | src/script/lua_api/l_server.h | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/script/lua_api/l_server.cpp b/src/script/lua_api/l_server.cpp index 6ac4bb653..d94f3e31d 100644 --- a/src/script/lua_api/l_server.cpp +++ b/src/script/lua_api/l_server.cpp @@ -334,6 +334,22 @@ int ModApiServer::l_kick_player(lua_State *L) return 1; } +int ModApiServer::l_remove_player(lua_State *L) +{ + NO_MAP_LOCK_REQUIRED; + std::string name = luaL_checkstring(L, 1); + ServerEnvironment *s_env = dynamic_cast<ServerEnvironment *>(getEnv(L)); + assert(s_env); + + RemotePlayer *player = s_env->getPlayer(name.c_str()); + if (!player) + lua_pushinteger(L, s_env->removePlayerFromDatabase(name) ? 0 : 1); + else + lua_pushinteger(L, 2); + + return 1; +} + // unban_player_or_ip() int ModApiServer::l_unban_player_or_ip(lua_State *L) { @@ -510,6 +526,7 @@ void ModApiServer::Initialize(lua_State *L, int top) API_FCT(get_ban_description); API_FCT(ban_player); API_FCT(kick_player); + API_FCT(remove_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 008810784..e6c0df978 100644 --- a/src/script/lua_api/l_server.h +++ b/src/script/lua_api/l_server.h @@ -92,6 +92,9 @@ private: // kick_player(name, [message]) -> success static int l_kick_player(lua_State *L); + // remove_player(name) + static int l_remove_player(lua_State *L); + // notify_authentication_modified(name) static int l_notify_authentication_modified(lua_State *L); |