From 8f0e38e00a4533ad6ff5a1b2c24036e94a23fb70 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Fri, 22 Mar 2019 13:23:19 +0100 Subject: [PATCH] player hide feature --- doc/mod.md | 9 +++++++++ mapserver_mod/mapserver/bridge.lua | 7 ++++++- mapserver_mod/mapserver/init.lua | 1 + mapserver_mod/mapserver/privs.lua | 4 ++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 mapserver_mod/mapserver/privs.lua diff --git a/doc/mod.md b/doc/mod.md index 52f92bb..2d4999d 100644 --- a/doc/mod.md +++ b/doc/mod.md @@ -42,3 +42,12 @@ secure.http_mods = mapserver mapserver.url = http://127.0.0.1:8080 mapserver.key = ZJoSpysiKGlYexof ``` + +### Hiding players from the map + +If (for any reason) you want to hide players on the map, you can `/grant` them the following priv: +``` +mapserver_hide_player +``` + +The player-position and data will not be sent to the mapserver diff --git a/mapserver_mod/mapserver/bridge.lua b/mapserver_mod/mapserver/bridge.lua index 34d709e..e0054f5 100644 --- a/mapserver_mod/mapserver/bridge.lua +++ b/mapserver_mod/mapserver/bridge.lua @@ -78,6 +78,9 @@ function send_stats() end for _, player in ipairs(minetest.get_connected_players()) do + + local is_hidden = minetest.check_player_privs(player:get_player_name(), {mapserver_hide_player = true}) then + local info = { name = player:get_player_name(), pos = player:get_pos(), @@ -86,7 +89,9 @@ function send_stats() velocity = player:get_player_velocity() } - table.insert(data.players, info) + if not is_hidden then + table.insert(data.players, info) + end end local json = minetest.write_json(data) diff --git a/mapserver_mod/mapserver/init.lua b/mapserver_mod/mapserver/init.lua index d361e2f..cfeed41 100644 --- a/mapserver_mod/mapserver/init.lua +++ b/mapserver_mod/mapserver/init.lua @@ -7,6 +7,7 @@ dofile(MP.."/train.lua") dofile(MP.."/label.lua") dofile(MP.."/border.lua") dofile(MP.."/legacy.lua") +dofile(MP.."/privs.lua") -- optional mapserver-bridge stuff below diff --git a/mapserver_mod/mapserver/privs.lua b/mapserver_mod/mapserver/privs.lua new file mode 100644 index 0000000..30d07bb --- /dev/null +++ b/mapserver_mod/mapserver/privs.lua @@ -0,0 +1,4 @@ + +minetest.register_privilege("mapserver_hide_player", { + description = "Player is hidden from the map" +})