Jump to content

onEnterVehicle


yMassai

Recommended Posts

carros [ source ] = createVehicle ( modelo, -50.28254, -1142.70104, 1.62812, 0, 0, 65 ) 
  
function onEnterVehicle () 
    if .. 
        triggerClientEvent ( "createMarcaEvent", localPlayer ) 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onEnterVehicle ) 
  
function onExitVehicle () 
    if .. 
        triggerClientEvent("destroytruckt",localPlayer) 
    end 
end 
addEventHandler ( "onPlayerVehicleExit", getRootElement(), onExitVehicle ) 

when the player enter the vehicle the desired event occurs.

what functions can I use to identify the player get in and out of the vehicle?

Link to comment

I don't understand, what do you want?

What do you mean with if...

btw, you can trigger for only 1 car to. like this:

  
lolauto = createVehicle ( modelo, -50.28254, -1142.70104, 1.62812, 0, 0, 65 ) 
  
function autofunction () 
--Some epic crap here 
end 
addEventHandler ( "onPlayerVehicleEnter",lolauto, autofunction ) 
  

And why using [ source ] when it's not defined....

In my opinion you should read the wiki again

Link to comment
carros [ source ] = createVehicle ( modelo, -50.28254, -1142.70104, 1.62812, 0, 0, 65 ) 
function onExitVehicle () 
    if ( isElement ( carros [ source ] ) )  then 
        triggerClientEvent("destroytruck",getRootElement ( )) 
    end 
end 
addEventHandler ( "onPlayerVehicleExit", getRootElement(), onExitVehicle ) 
  
function onEnterVehicle () 
    if ( isElement ( carros [ source ] )) then 
        triggerClientEvent("destroytruck",getRootElement ( )) 
        triggerClientEvent ( "createMarcaEvent", getRootElement ( ) ) 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onEnterVehicle ) 

working

Link to comment
I don't understand, what do you want?

What do you mean with if...

btw, you can trigger for only 1 car to. like this:

  
lolauto = createVehicle ( modelo, -50.28254, -1142.70104, 1.62812, 0, 0, 65 ) 
  
function autofunction () 
--Some epic crap here 
end 
addEventHandler ( "onPlayerVehicleEnter",lolauto, autofunction ) 
  

And why using [ source ] when it's not defined....

In my opinion you should read the wiki again

You should too, onPlayerVehicleEnter source element is the player element, not the vehicle.

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