local meta = FindMetaTable('Player')
function meta:InAdminmode()
return self:GetNWBool('ulx_adminmode', false)
end
function ulx.adminmode(ply)
ply:SetNWBool('ulx_adminmode', !ply:InAdminmode())
ulx.fancyLogAdmin(ply, '#A ' .. (ply:InAdminmode() and 'включил' or 'выключил') .. ' админ-мод.')
end
local adminmode = ulx.command('Utility', 'ulx adminmode', ulx.adminmode, '!adminmode')
adminmode:defaultAccess(ULib.ACCESS_ADMIN)
adminmode:help('Включить/выключить админ-мод')
local function restrict(ply)
if !ply:InAdminmode() then
DarkRP.notify(ply, 1, 5, 'Ты не включил админ-мод!')
return false
end
end
local whitelisted = {
['ulx help'] = true,
['ulx adminmode'] = true,
['ulx motd'] = true,
['ulx version'] = true,
}
hook.Add('PlayerNoClip', 'adminmode', restrict)
hook.Add(ULib.HOOK_COMMAND_CALLED, 'adminmode', function(ply, cmd, args)
if !IsValid(ply) then return end
if cmd:sub(1,3) != 'ulx' then return end
if !whitelisted[cmd] then return restrict(ply) end
end)