OnVehicleExit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Added forcedByScript parameter)
Line 5: Line 5:
==Parameters==  
==Parameters==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
player thePlayer, int seat, player jacker
player thePlayer, int seat, player jacker, bool forcedByScript
</syntaxhighlight>  
</syntaxhighlight>  


Line 11: Line 11:
*'''seat''': an [[int]] representing the seat in which the player exited from.
*'''seat''': an [[int]] representing the seat in which the player exited from.
*'''jacker''': a [[player]] element representing the player who jacked the driver.
*'''jacker''': a [[player]] element representing the player who jacked the driver.
{{New feature/item|3.0154|1.5.3|11247|
*'''forcedByScript:''' a [[boolean]] representing whether the exit was forced using [[removePedFromVehicle]] or by the player.
}}


==Source==
==Source==
Line 43: Line 46:
end)
end)
</syntaxhighlight>
</syntaxhighlight>
==Changelog==
{{ChangelogHeader}}
{{ChangelogItem|1.5.3-9.11247|Added forcedByScript argument}}


{{See also/Server event|Vehicle events}}
{{See also/Server event|Vehicle events}}

Revision as of 02:23, 21 November 2018

This event is triggered when a player leaves a vehicle.

Parameters

player thePlayer, int seat, player jacker, bool forcedByScript
  • thePlayer: a player element representing the player who exited the vehicle.
  • seat: an int representing the seat in which the player exited from.
  • jacker: a player element representing the player who jacked the driver.

Source

The source of this event is the vehicle that was exited.

Example

This example adds a 'moto' helmet to a player when he gets on a nrg bike, and removes it when he gets off.

function addHelmetOnEnter ( thePlayer, seat, jacked )
    if ( getElementModel ( source ) == 522 ) then -- if its a nrg
        addPedClothes ( thePlayer, "moto", "moto", 16 ) -- add the helmet
    end
end
addEventHandler ( "onVehicleEnter", getRootElement(), addHelmetOnEnter )

function removeHelmetOnExit ( thePlayer, seat, jacked )
    if ( getElementModel ( source ) == 522 ) then -- if its a nrg
        removePedClothes ( thePlayer, 16 ) -- remove the helmet
    end
end
addEventHandler ( "onVehicleExit", getRootElement(), removeHelmetOnExit )


Example 2

This example will turn off a vehicle's engine when the driver gets out of the car.

addEventHandler ( "onPlayerVehicleExit", getRootElement(), function(theVehicle, leftSeat, jackerPlayer)
    if leftSeat == 0 and not jackerPlayer then
       setVehicleEngineState( theVehicle, false)
    end
end)

Changelog

Version Description
1.5.3-9.11247 Added forcedByScript argument

See Also

Vehicle events


Event functions