OnVehicleExit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 5: Line 5:
==Parameters==  
==Parameters==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
player player, int seat, player jacker
player thePlayer, int seat, player jacker
</syntaxhighlight>  
</syntaxhighlight>  


*'''player''': A player element representing the player who exited the vehicle
*'''thePlayer''': 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
Line 18: Line 18:
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">
function addHelmetOnEnter ( player, seat, jacked )
function addHelmetOnEnter ( thePlayer, 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 ( thePlayer, "moto", "moto", 16 ) -- add the helmet
   end
   end
end
end
addEventHandler ( "onVehicleEnter", getRootElement(), addHelmetOnEnter )
addEventHandler ( "onVehicleEnter", getRootElement(), addHelmetOnEnter )


function removeHelmetOnExit ( player, seat, jacked )
function removeHelmetOnExit ( thePlayer, 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 ( thePlayer, 16 ) -- remove the helmet
   end
   end
end
end

Revision as of 18:46, 12 December 2008

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

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

See Also

Vehicle events


Event functions