Jump to content

I need help (team)


Recommended Posts

I need help with this!

function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle 
    if getElementType ( thePlayer ) == "player" then 
            local p = getTeamName(getPlayerTeam(thePlayer)) 
            if (p == "xd") then 
            else 
            removePedFromVehicle( thePlayer )-- force the player out of the vehicle 
--Here's the problem! ^^^^^^ 
        end 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 

It works fine but it's a bit 'ugly' that. i saw in a server that when you try to enter in a vehicle of police and u aren't police, you can't just enter. But with this script the problem is that you can enter, and when u are in the vehicle, and not in the team, it just spawns you up of the vehicle. that's a bit ugly =/ can't i do that he can't just enter?

Link to comment
function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle 
    if getElementType ( thePlayer ) == "player" then 
        local p = getTeamName(getPlayerTeam(thePlayer)) 
        if ( p ~= "xd" ) then 
            cancelEvent ( ) 
        end 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

Link to comment
function enterVehicle ( thePlayer, seat, jacked )  
    local team = getPlayerTeam ( thePlayer ) if not team then return end 
       local p = getTeamName ( team )  
          if p and p ~= "xd" then 
                cancelEvent ( )  
        end 
  end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

Link to comment

server

addEventHandler ( "onClientVehicleStartEnter", root, 
    function ( thePlayer ) 
        if ( thePlayer == localPlayer ) then 
            local plrTeam = getPlayerTeam ( localPlayer ) 
            if ( plrTeam ) then 
                if ( getTeamName ( plrTeam ) ~= "xd" ) then 
                    cancelEvent ( ) 
                end 
            end 
        end 
    end 
) 

Link to comment
function enterVehicle ( thePlayer, seat, jacked ) 
    local team = getPlayerTeam ( thePlayer ) 
    if ( not team ) then 
        cancelEvent ( ) 
        return 
    end 
  
    local p = getTeamName ( team ) 
    if ( p ~= "xd" ) then 
        cancelEvent ( ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

Link to comment

You must use getElementModel.

function enterVehicle ( thePlayer, seat, jacked ) 
    if ( getElementModel ( source ) == 425 ) then 
        local team = getPlayerTeam ( thePlayer ) 
        if ( not team ) then 
            cancelEvent ( ) 
            return 
        end 
  
        local p = getTeamName ( team ) 
        if ( p ~= "xd" ) then 
            cancelEvent ( ) 
        end 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

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