Check if player exists on use of /privs (#7554)

* /privs: Check if player exists
This commit is contained in:
ClobberXD 2018-07-16 18:25:04 +05:30 committed by Loïc Blot
parent 1aaee5b30d
commit a0635f6024

@ -84,7 +84,7 @@ core.register_chatcommand("admin", {
func = function(name) func = function(name)
local admin = core.settings:get("name") local admin = core.settings:get("name")
if admin then if admin then
return true, "The administrator of this server is "..admin.."." return true, "The administrator of this server is " .. admin .. "."
else else
return false, "There's no administrator named in the config file." return false, "There's no administrator named in the config file."
end end
@ -97,6 +97,9 @@ core.register_chatcommand("privs", {
func = function(caller, param) func = function(caller, param)
param = param:trim() param = param:trim()
local name = (param ~= "" and param or caller) local name = (param ~= "" and param or caller)
if not core.player_exists(name) then
return false, "Player " .. name .. " does not exist."
end
return true, "Privileges of " .. name .. ": " return true, "Privileges of " .. name .. ": "
.. core.privs_to_string( .. core.privs_to_string(
core.get_player_privs(name), ' ') core.get_player_privs(name), ' ')