Jump to content

several teams in GetTeamName


5150

Recommended Posts

how can i make it so my script will read more than one team? i have a security system for A51 and it only allows my gang, Psycho Mans Gang in. i want the "Staff" team to have access too. what do i have to do here?

function hit ( pla, dim ) 
    if getElementType ( pla ) == "player" then 
    local vehicle = getPlayerOccupiedVehicle ( pla ) 
        if vehicle or not vehicle then 
             
            if ( getTeamName(getPlayerTeam(pla)) == "Psycho Mans Gang" ) then 
                outputChatBox ( "Welcome, "..getClientName(pla).."!", pla, 0, 150, 0 ) 
            else 
                setElementData ( pla, "inRestrictedArea", "true" ) 
                triggerClientEvent ( pla, "destroyTrepassor", g_root, pla ) 
            end 
        end 
    end 
end 
addEventHandler ( "onColShapeHit", g_base_col, hit ) 

Link to comment

You can make a table with the allowed teams, like in this code:

local allowedTeams = { ["Psycho Mans Gang"]=true, ["Staff"]=true } 
  
function hit ( pla, dim ) 
    if getElementType ( pla ) == "player" then 
        local vehicle = getPedOccupiedVehicle ( pla ) 
         
        if getPlayerTeam(pla) and allowedTeams[getTeamName(getPlayerTeam(pla))] then 
            outputChatBox ( "Welcome, "..getPlayerName(pla).."!", pla, 0, 150, 0 ) 
        else 
            setElementData ( pla, "inRestrictedArea", "true" ) 
            triggerClientEvent ( pla, "destroyTrepassor", g_root, pla ) 
        end 
    end 
end 
addEventHandler ( "onColShapeHit", g_base_col, hit ) 

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