Jump to content

Admin checker function


StefanAlmighty

Recommended Posts

I have several admin ranks saved to a database and I have seperate functions for recognizing each admin rank. But now, I need a function which recognizes all admin ranks. Here is that function:

  
function isPlayerAdmin(player) 
    if not player or not isElement(player) or not getElementType(player) == "player" then 
        return false 
    end 
    return  isPlayerJuniorAdmin(player) 
    or      isPlayerGeneralAdmin(player) 
    or      isPlayerSeniorAdmin(player) 
    or      isPlayerHeadAdmin(player) 
    or      isPlayerCommunityDirector(player) 
end 
  

My issue is, it doesn't recognize the final "isPlayerCommunityDirector(player)" when using it in commands. For example I have an admin chat (/a) which uses "exports.chat:isPlayerAdmin(source)". It works for every admin except Community Directors, where it simply doesn't allow them to use the command. All of the others are able to use it.

Here is the function, which works fine in any other scenario:

  
function isPlayerCommunityDirector(player) 
    if not player or not isElement(player) or not getElementType(player) == "player" then 
        return false 
    end 
    local rank = getElementData(player, "admin_rank") or 0 
    return (rank >= 5) 
end 
  

Link to comment

What about if I added my other ranks?

  
function isPlayerAdmin(player) 
    if not player or not isElement(player) or not getElementType(player) == "player" then 
        return false 
    end 
    return  isPlayerJuniorAdmin(player) 
    or      isPlayerGeneralAdmin(player) 
    or      isPlayerSeniorAdmin(player) 
    or      isPlayerHeadAdmin(player) 
    or      isPlayerCommunityDirector(player) 
    or      isPlayerHelper(player) 
    or      isPlayerScripter(player) 
end 
  

getElementData(player, "scripter_rank")

getElementData(player, "helper_rank")

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...