Skip to content

Instantly share code, notes, and snippets.

@ClobberXD
Created April 24, 2018 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ClobberXD/6de70a7de43ff935df05da118939d140 to your computer and use it in GitHub Desktop.
Save ClobberXD/6de70a7de43ff935df05da118939d140 to your computer and use it in GitHub Desktop.
/hasprivs
core.register_chatcommand("hasprivs", {
params = "<priv>",
description = "Returns a list of all online players with the priv passed as param. e.g. /hasprivs fly",
privs = {server = true},
func = function(caller, param)
param = param:trim()
if param == "" then
return false, "Invalid parameters (see /help hasprivs)"
end
local param_privs = core.string_to_privs(param)
local players_with_privs = {}
for _, player in pairs(minetest.get_connected_players()) do
local toname = player:get_player_name()
if minetest.check_player_privs(toname, {param_privs = true}) then
table.insert(players_with_privs, toname)
end
end
return true, "Players with the " ..param.. " priv: " ..table.concat(players_with_privs, ", ")
end
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment