Hide hidden players in xplevel command too
This commit is contained in:
parent
a8410a4d7a
commit
850d7f6a9e
@ -1,6 +1,6 @@
|
|||||||
-- LUALOCALS < ---------------------------------------------------------
|
-- LUALOCALS < ---------------------------------------------------------
|
||||||
local math, minetest, next, pairs, table, tonumber, type
|
local ipairs, math, minetest, next, pairs, table, tonumber, type
|
||||||
= math, minetest, next, pairs, table, tonumber, type
|
= ipairs, math, minetest, next, pairs, table, tonumber, type
|
||||||
local math_floor, table_concat, table_sort
|
local math_floor, table_concat, table_sort
|
||||||
= math.floor, table.concat, table.sort
|
= math.floor, table.concat, table.sort
|
||||||
-- LUALOCALS > ---------------------------------------------------------
|
-- LUALOCALS > ---------------------------------------------------------
|
||||||
@ -204,17 +204,24 @@ end
|
|||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
-- QUERY COMMAND
|
-- QUERY COMMAND
|
||||||
|
|
||||||
|
local stpriv = minetest.settings:get(modname .. "_hide") or "stealth"
|
||||||
|
local function isstealth(p) return minetest.check_player_privs(p, stpriv) end
|
||||||
|
|
||||||
minetest.register_chatcommand(modname, {
|
minetest.register_chatcommand(modname, {
|
||||||
description = "Read player(s) xp levels",
|
description = "Read player(s) xp levels",
|
||||||
params = "[player]",
|
params = "[player]",
|
||||||
func = function(_, param)
|
func = function(_, param)
|
||||||
local list = param and param ~= "" and {param}
|
local list = param and param ~= "" and {param}
|
||||||
or minetest.get_connected_players()
|
if not list then
|
||||||
|
list = {}
|
||||||
|
for _, p in ipairs(minetest.get_connected_players()) do
|
||||||
|
if not isstealth(p) then
|
||||||
|
list[#list + 1] = p:get_player_name()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
local xp = {}
|
local xp = {}
|
||||||
for i = 1, #list do
|
for _, p in ipairs(list) do
|
||||||
local p = list[i]
|
|
||||||
if type(p) ~= "string" then p = p:get_player_name() end
|
|
||||||
list[i] = p
|
|
||||||
xp[p] = math_floor(getxp(p) or 0)
|
xp[p] = math_floor(getxp(p) or 0)
|
||||||
end
|
end
|
||||||
table_sort(list, function(a, b) return xp[a] > xp[b] end)
|
table_sort(list, function(a, b) return xp[a] > xp[b] end)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user