Author Topic: Toggle between !admin and !unadmin  (Read 3559 times)

0 Members and 1 Guest are viewing this topic.

Offline TheMilkMan

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Toggle between !admin and !unadmin
« on: June 08, 2019, 06:12:41 PM »
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:
Code: [Select]
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 )
« Last Edit: June 09, 2019, 08:32:12 PM by TheMilkMan »

Offline nated0708gqiaa

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: Toggle between !admin and !unadmin
« Reply #1 on: June 10, 2019, 11:58:13 PM »
Are you trying to make it so where the command needs to be on a certain job or...

Offline I_AM_TOOD

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Toggle between !admin and !unadmin
« Reply #2 on: June 18, 2019, 09:25:42 PM »
For some reason "!unadmin" isn't revoking godmode. It should, but isn't...

Offline mark272

  • Newbie
  • *
  • Posts: 16
  • Karma: 5
Re: Toggle between !admin and !unadmin
« Reply #3 on: June 26, 2019, 08:39:22 AM »
I think you didn’t set the should_revoke or how its called to false.