Jump to content

don't work!


Enargy,

Recommended Posts

Posted

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 ) 

Inactivo.

Posted

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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

That's because you never cancelled the event (this event not cancelable anyway) and you never removed the player from the vehicle.

CiTLh.png
Posted

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 ) 

It's fine to celebrate success but it is more important to heed the lessons of failure.

Posted
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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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