Rename hasprivs command to haspriv (#7860)
This commit is contained in:
parent
657a3d1e05
commit
6b102ce51f
@ -106,28 +106,28 @@ core.register_chatcommand("privs", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
core.register_chatcommand("hasprivs", {
|
core.register_chatcommand("haspriv", {
|
||||||
params = "<privilege>",
|
params = "<privilege>",
|
||||||
description = "Return list of all online players with privilege.",
|
description = "Return list of all online players with privilege.",
|
||||||
privs = {basic_privs = true},
|
privs = {basic_privs = true},
|
||||||
func = function(caller, param)
|
func = function(caller, param)
|
||||||
param = param:trim()
|
param = param:trim()
|
||||||
if param == "" then
|
if param == "" then
|
||||||
return false, "Invalid parameters (see /help hasprivs)"
|
return false, "Invalid parameters (see /help haspriv)"
|
||||||
end
|
end
|
||||||
if not core.registered_privileges[param] then
|
if not core.registered_privileges[param] then
|
||||||
return false, "Unknown privilege!"
|
return false, "Unknown privilege!"
|
||||||
end
|
end
|
||||||
local privs = core.string_to_privs(param)
|
local privs = core.string_to_privs(param)
|
||||||
local players_with_privs = {}
|
local players_with_priv = {}
|
||||||
for _, player in pairs(core.get_connected_players()) do
|
for _, player in pairs(core.get_connected_players()) do
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
if core.check_player_privs(player_name, privs) then
|
if core.check_player_privs(player_name, privs) then
|
||||||
table.insert(players_with_privs, player_name)
|
table.insert(players_with_priv, player_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true, "Players online with the \"" .. param .. "\" priv: " ..
|
return true, "Players online with the \"" .. param .. "\" privilege: " ..
|
||||||
table.concat(players_with_privs, ", ")
|
table.concat(players_with_priv, ", ")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user