Jump to content

don't work!


Enargy,

Recommended Posts

I have an error in this script, I want the car in the id '411 'and '402' Whether booked by a team, but when a player who is not a member of the team can lead

(server)

NameT= "SC Life" 
vehTeam = {{411,402}} 
  
function enterVehicle ( thePlayer, seat, jacked )  
    if getElementType ( thePlayer ) == "player" then 
            local team = getPlayerTeam ( thePlayer ) 
        local teamName = ( team and getTeamName ( team ) or "" ) 
        if ( teamName == NameT ) then 
        if ( vehTeam[getElementModel ( source )] ) then 
        outputChatBox("vehicle from: "..NameT, thePlayer, 255, 255, 0, true) 
        else 
            outputChatBox("you can't use this", thePlayer, 255, 255, 0, true) 
        end 
    end 
end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 

Link to comment

You made your table wrong.

NameT = "SC Life" 
vehTeam = 
    { 
        [ 411 ] = true, 
        [ 402 ] = true 
    } 
  
function enterVehicle ( thePlayer, seat, jacked ) 
    if ( getElementType ( thePlayer ) == "player" ) then 
        local team = getPlayerTeam ( thePlayer ) 
        local teamName = ( team and getTeamName ( team ) or "" ) 
        if ( teamName == NameT ) then 
            if ( vehTeam [ getElementModel ( source ) ] ) then 
                outputChatBox ( "vehicle from: ".. NameT, thePlayer, 255, 255, 0, true ) 
            else 
                outputChatBox ( "you can't use this", thePlayer, 255, 255, 0, true ) 
            end 
        end 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 

Link to comment

This would work like you want.

NameT = "SC Life" 
vehTeam = 
    { 
        [ 411 ] = true, 
        [ 402 ] = true 
    } 
  
function enterVehicle ( thePlayer, seat, jacked ) 
    if ( getElementType ( thePlayer ) == "player" ) then 
        local team = getPlayerTeam ( thePlayer ) 
        local teamName = ( team and getTeamName ( team ) or "" ) 
        if ( teamName == NameT ) then 
            if ( vehTeam [ getElementModel ( source ) ] ) then 
                outputChatBox ( "vehicle from: ".. NameT, thePlayer, 255, 255, 0, true ) 
            else 
                outputChatBox ( "you can't use this", thePlayer, 255, 255, 0, true ) 
                removePedFromVehicle(thePlayer) 
            end 
        end 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 

Link to comment
but I can still enter the car without equipment
NameT = "SC Life" 
vehTeam = 
    { 
        [ 411 ] = true, 
        [ 402 ] = true 
    } 
  
function enterVehicle ( thePlayer, seat, jacked ) 
    if ( getElementType ( thePlayer ) == "player" ) then 
        local team = getPlayerTeam ( thePlayer ) 
        local teamName = ( team and getTeamName ( team ) or "" ) 
        if ( teamName == NameT ) then 
            if ( vehTeam [ getElementModel ( source ) ] ) then 
                outputChatBox ( "vehicle from: ".. NameT, thePlayer, 255, 255, 0, true ) 
            else 
                outputChatBox ( "you can't use this", thePlayer, 255, 255, 0, true ) 
                cancelEvent ( ) 
            end 
        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...