Jump to content

[HELP] I want arpear the rank name not level string


Dimos7

Recommended Posts

function isPlayerStaff ( p )
    if ( p and getElementType ( p ) == 'player' ) then
        if ( isPlayerInACL ( p, "Level 1" ) or isPlayerInACL ( p, "Level 2" ) or isPlayerInACL ( p, "Level 3" ) or isPlayerInACL ( p, "Level 4" ) or isPlayerInACL ( p, "Level 5" ) or isPlayerInACL ( p, "Admin" ) or isPlayerInACL ( p, "Console" ) ) then
            return true
        end
        return false
    end
end

function getPlayerStaffLevel ( p, var )
    if ( isPlayerStaff ( p ) ) then
        local str = nil
        local num = nil
        for i=1,5 do
            if ( isPlayerInACL ( p, 'Level '..tostring ( i ) ) ) then
                num = i
                str = "Level "..tostring(i)
                break 
            end
        end
        if ( var == 'string' ) then
            return str
        elseif ( var == 'int' ) then
            return num
        else
            return str, num
        end
        
    end
    return 0,0
end

function getAllStaff ( )
      local staff = { 
        ['Level 1'] = {"Trial Staff"} ,
        ['Level 2'] = {"Moderator"} ,
        ['Level 3'] = {"Super Moderator"},
        ['Level 4'] =  {"Co- Ownwer"},
        ['Level 5'] =  {"Ownwer"} ,
    }
    
    for i=1,5 do
        for k, v in ipairs ( aclGroupListObjects ( aclGetGroup ( "Level "..tostring ( i ) ) ) ) do
            if ( string.find ( tostring ( v ), 'user.' ) ) then
                local name = tostring ( v:gsub ( "user.", "" ) )
                staff['Level '..tostring ( i )][#staff['Level '..tostring ( i )]+1] = name
            end
        end
    end
    
    return staff
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


-- NG 1.1.4 --
-- Set element data to make getting staff on client side --
function setNewPlayerStaffData ( p )
    if ( isPlayerStaff ( p ) ) then 
        setElementData ( p, "staffLevel", getPlayerStaffLevel ( p, 'int' ) )
    else 
        setElementData ( p, 'staffLevel', 0 )
    end 
end

addEventHandler ( "onPlayerLogin", root, function ( )
    setNewPlayerStaffData ( source )
end );

addEventHandler ( "onResourceStart", resourceRoot, function ( )
    for _, p in pairs ( getElementsByType ( "player" ) ) do 
        setNewPlayerStaffData ( p )
    end 
end )

I want apear the Trail Staff etc not Level 1 etc help me

Link to comment

 

 --- i want this
    str = "Level "..tostring(i) 
      local staff = { 
        ['Level 1'] = {"Trial Staff"} ,
        ['Level 2'] = {"Moderator"} ,
        ['Level 3'] = {"Super Moderator"},
        ['Level 4'] =  {"Co- Ownwer"},
        ['Level 5'] =  {"Ownwer"} ,
  } -- apear that 

 

Edited by Dimos7
Link to comment
       Ranks = { 
        ['Level 1'] = {"Trial Staff"} ,
        ['Level 2'] = {"Moderator"} ,
        ['Level 3'] = {"Super Moderator"},
        ['Level 4'] =  {"Co- Ownwer"},
        ['Level 5'] =  {"Ownwer"} ,
    }


function isInAcl(player)
	for i,v in pairs(Ranks) do
		if isPlayerInACL ( p, v[1] ) then
			return true
		end
	end
end

function isPlayerStaff ( p )
    if ( p and getElementType ( p ) == 'player' ) then
        if ( isInAcl(p) or isPlayerInACL ( p, "Admin" ) or isPlayerInACL ( p, "Console" ) ) then
            return true
        end
        return false
    end
end

function getPlayerStaffLevel ( p, var )
    if ( isPlayerStaff ( p ) ) then
        local str = nil
        local num = nil
        for i=1,#Ranks do
            if ( isPlayerInACL ( p, Ranks['Level '..tostring ( i )][1] ) ) then
                num = i
                str = 'Level '..tostring ( i ) -- OR Ranks['Level '..tostring ( i )][1]
                break 
            end
        end
        if ( var == 'string' ) then
            return str
        elseif ( var == 'int' ) then
            return num
        else
            return str, num
        end
        
    end
    return 0,0
end


function getAllStaff ( )
    
       staff = { 
        ['Level 1'] = {} ,
        ['Level 2'] = {} ,
        ['Level 3'] = {},
        ['Level 4'] =  {},
        ['Level 5'] =  {} ,
		}
	
    for i=1,#Ranks do
        for k, v in ipairs ( aclGroupListObjects ( aclGetGroup ( Ranks['Level '..tostring ( i )][1] ) ) ) do
            if ( string.find ( tostring ( v ), 'user.' ) ) then
                local name = tostring ( v:gsub ( "user.", "" ) )
                staff[Ranks['Level '..tostring ( i )][1]][#staff[Ranks['Level '..tostring ( i )][1]]+1] = name
            end
        end
    end
    
    return staff
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


-- NG 1.1.4 --
-- Set element data to make getting staff on client side --
function setNewPlayerStaffData ( p )
    if ( isPlayerStaff ( p ) ) then 
        setElementData ( p, "staffLevel", getPlayerStaffLevel ( p, 'int' ) )
    else 
        setElementData ( p, 'staffLevel', 0 )
    end 
end

addEventHandler ( "onPlayerLogin", root, function ( )
    setNewPlayerStaffData ( source )
end );

addEventHandler ( "onResourceStart", resourceRoot, function ( )
    for _, p in pairs ( getElementsByType ( "player" ) ) do 
        setNewPlayerStaffData ( p )
    end 
end )

 

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