OnVehicleExit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Undo revision 50125 by Marcin778 (talk))
Line 1: Line 1:
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
__NOTOC__
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
{{Server event}}
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
This event is triggered when a player leaves a vehicle.
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
 
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
==Parameters==
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
<syntaxhighlight lang="lua">
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
player thePlayer, int seat, player jacker
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
</syntaxhighlight>
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
 
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
*'''thePlayer''': A player element representing the player who exited the vehicle
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
*'''seat''': An integer representing the seat in which the player exited from
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
*'''jacker''': A player element representing the player who jacked the driver
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
 
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
==Source==
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
The [[event system#Event source|source]] of this event is the [[vehicle]] that was exited.
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
 
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
==Example==
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
This example adds a 'moto' helmet to a player when he gets on a nrg bike, and removes it when he gets off.
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
<syntaxhighlight lang="lua">
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
function addHelmetOnEnter ( thePlayer, seat, jacked )
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
    if ( getElementModel ( source ) == 522 ) then -- if its a nrg
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
        addPedClothes ( thePlayer, "moto", "moto", 16 ) -- add the helmet
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
    end
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
end
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
addEventHandler ( "onVehicleEnter", getRootElement(), addHelmetOnEnter )
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
 
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
function removeHelmetOnExit ( thePlayer, seat, jacked )
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
    if ( getElementModel ( source ) == 522 ) then -- if its a nrg
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
        removePedClothes ( thePlayer, 16 ) -- remove the helmet
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
    end
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
end
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
addEventHandler ( "onVehicleExit", getRootElement(), removeHelmetOnExit )
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
</syntaxhighlight>
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
 
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
 
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
==Example 2==
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
This example will turn off a vehicle's engine when the driver gets out of the car.
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
<syntaxhighlight lang="lua">
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
addEventHandler ( "onPlayerVehicleExit", getRootElement(), function(theVehicle, leftSeat, jackerPlayer)
    if leftSeat == 0 and not jackerPlayer then
      setVehicleEngineState( theVehicle, false)
    end
end)
</syntaxhighlight>
 
{{See also/Server event|Vehicle events}}

Revision as of 18:37, 1 January 2017

This event is triggered when a player leaves a vehicle.

Parameters

player thePlayer, int seat, player jacker
  • thePlayer: A player element representing the player who exited the vehicle
  • seat: An integer 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)

See Also

Vehicle events


Event functions