1. Toggle for !admin to also do !unadmin when pressing it again
Also How do I restrict admin powers unless you're in admin mode
Current Code for this:
function ulx.admin( calling_ply, should_revoke )
if not should_revoke then
calling_ply:GodEnable()
else
calling_ply:GodDisable()
end
if not should_revoke then
calling_ply:SetModel( "models/player/combine_super_soldier.mdl" )
end
if not should_revoke then
ulx.fancyLogAdmin( calling_ply, true, "#A is now administrating" )
end
end
local admin = ulx.command( "Admin", "ulx admin", ulx.admin, { "!admin", "!admin"}, true )
admin:addParam{ type=ULib.cmds.BoolArg, invisible=true }
admin:defaultAccess( ULib.ACCESS_SUPERADMIN )
admin:help( "Noclip, & God Mode yourself" )
admin:setOpposite( "ulx unadmin", { _, true }, "!unadmin", true )
function ulx.unadmin( calling_ply, should_revoke )
if not should_revoke then
ulx.fancyLogAdmin( calling_ply, true, "#A has stopped administrating" )
end
if not should_revoke then
local jobTable = calling_ply:getJobTable()
if not jobTable then return self.Sandbox.PlayerSetModel(ply) end
if jobTable.PlayerSetModel then
local model = jobTable.PlayerSetModel(ply)
if model then ply:SetModel(model) return end
end
local EndModel = ""
if GAMEMODE.Config.enforceplayermodel then
if istable(jobTable.model) then
local ChosenModel = string.lower(calling_ply:getPreferredModel(calling_ply:Team()) or "")
local found
for _, Models in pairs(jobTable.model) do
if ChosenModel == string.lower(Models) then
EndModel = Models
found = true
break
end
end
if not found then
EndModel = jobTable.model[math.random(#jobTable.model)]
end
else
EndModel = jobTable.model
end
calling_ply:SetModel(EndModel)
else
local cl_playermodel = ply:GetInfo("cl_playermodel")
local modelname = player_manager.TranslatePlayerModel(cl_playermodel)
calling_ply:SetModel(calling_ply:getPreferredModel(calling_ply:Team()) or modelname)
end
calling_ply.darkrp.PlayerSetModel( ply )
calling_ply:SetupHands()
end
end
local admin = ulx.command( "Unadmin", "ulx unadmin", ulx.unadmin, { "!unadmin", "!unadmin"}, true)
unadmin:addParam{ type=ULib.cmds.BoolArg, invisible=true }
unadmin:defaultAccess( ULib.ACCESS_SUPERADMIN )
unadmin:help( "Noclip, & God Mode yourself" )
unadmin:setOpposite( "ulx admin", { _, true }, "!admin", true )