Jump to content

[Help] Staff Ranks script


Hero192

Recommended Posts

Doesn't works even if i changed the default ranks to custom and adding them in ACL ,help me please?

There is more than one way to do it.

Example 1 :

-- Using table 
  
local Ranks = {"Trial Staff","Trained Staff","Etc ..."} -- Put all your ranks here and make sure to add them all to your ACL.xml file. 
  
-- function to check if the player staff or not  
function isPlayerStaff (player)  
    if isElement(player) and getElementType (player) == "player" then 
        for a, g in ipairs (Ranks) do 
            if isPlayerInACL (player,g) then  
                return true 
            end 
        end  
    end 
    return false 
end 
  
-- get staff rank  
function getStaffRank (player) 
    if isPlayerStaff (player) then 
        for a, g in ipairs (Ranks) do 
            if isPlayerInACL (player,g) then 
            return tostring (g) 
            end  
        end  
    end  
    return false 
end 
  
function isPlayerInACL ( player, acl ) 
    local account = getPlayerAccount ( player ) 
    if ( isGuestAccount ( account ) ) then 
        return false 
    end 
    if ( aclGetGroup ( acl ) ) then 
        return isObjectInACLGroup ( "user."..getAccountName ( account ), aclGetGroup ( acl ) ) 
    end 
    
    return false; 
end 
  
function getOnlineStaff ( ) 
    local online = { } 
    for i, v in ipairs ( getElementsByType ( "player" ) ) do 
        if ( isPlayerStaff ( v ) ) then 
            table.insert ( online, v ) 
        end 
    end 
    return online 
end 
  

Example 2 :

-- Add all admins accounts name inside  a tabe like this  
  
Admins = { 
{"Bla ", "Head Staff"},    
{"Bla Bla","Trial Staff"},    
} 
  
function staffRanks(_,acc) 
    for index, data in pairs(Admins) do 
        if (getAccountName(acc) == data[1]) then 
            setElementData(source, "staffRank", data[2]) 
        end 
    end 
end 
addEventHandler("onPlayerLogin", root, staffRank) 
  
function isPlayerStaff(player) 
    if isElement(player) then  
        if (getElementData(player, "staffRank")) then 
            return true 
        else 
            return false 
        end 
    end  
    return false 
end 
  
function getStaffRank (player) 
    if isPlayerStaff (player) then 
        return getElementData(player, "staffRank") 
    end  
end 
  
-- Etc ... 

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...