OnVehicleExit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server event}}
This event is triggered when a player leaves a vehicle.
This event is triggered when a player leaves a vehicle.


==Syntax==  
==Parameters==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
void onVehicleExit ( player player, int seat, player jacker )
player player, int seat, player jacker
</syntaxhighlight>  
</syntaxhighlight>  


==Variables==
* The source of this event is the vehicle which was exited
*'''player''': A player element representing the player who exited the vehicle
*'''player''': A player element representing the player who exited the vehicle
*'''seat''': An integer representing the seat in which the player exited from
*'''seat''': An integer 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
==Source==
The [[event system#Event source|source]] of this event is the [[vehicle]] that was entered.


==Example==  
==Example==  
This example adds a 'moto' helmet to a player when he gets on a nrg bike, and removes it when he gets off.
This example adds a 'moto' helmet to a player when he gets on a nrg bike, and removes it when he gets off.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler ( "onVehicleEnter", getRootElement(), "onEnterVehicle" )
function addHelmetOnEnter ( player, seat, jacked )
function onEnterVehicle ( player, seat, jacked )
   if ( getVehicleID ( source ) == 522 ) then -- if its a nrg
   if ( getVehicleID ( source ) == 522 ) then -- if its a nrg
     addPlayerClothes ( player, "moto", "moto", 16 ) -- add the helmet
     addPlayerClothes ( player, "moto", "moto", 16 ) -- add the helmet
   end
   end
end
end
addEventHandler ( "onVehicleEnter", getRootElement(), addHelmetOnEnter )


addEventHandler ( "onVehicleExit", getRootElement(), "onExitVehicle" )
function removeHelmetOnExit ( player, seat, jacked )
function onExitVehicle ( player, seat, jacked )
   if ( getVehicleID ( source ) == 522 ) then -- if its a nrg
   if ( getVehicleID ( source ) == 522 ) then -- if its a nrg
     removePlayerClothes ( player, 16 ) -- remove the helmet
     removePlayerClothes ( player, 16 ) -- remove the helmet
   end
   end
end
end
addEventHandler ( "onVehicleExit", getRootElement(), removeHelmetOnExit )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Event_functions}}
{{Event_functions}}

Revision as of 14:13, 22 October 2007

This event is triggered when a player leaves a vehicle.

Parameters

player player, int seat, player jacker
  • player: 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 entered.

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 ( player, seat, jacked )
  if ( getVehicleID ( source ) == 522 ) then -- if its a nrg
    addPlayerClothes ( player, "moto", "moto", 16 ) -- add the helmet
  end
end
addEventHandler ( "onVehicleEnter", getRootElement(), addHelmetOnEnter )

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

See Also