OnClientPlayerVehicleEnter: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Fixed example)
Line 14: Line 14:


==Example==
==Example==
This will check if the car you entered is a Banshee or not.
This example will tell you the name of the vehicle you enter.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function checkVehicles()
function checkVehicles(theVehicle)
local theVehicle = getPedOccupiedVehicle(source)
outputChatBox("You entered a "..getVehicleName(theVehicle).."!")
if (getVehicleName(theVehicle)) == "Banshee" then
outputChatBox("You entered a Banshee!")
else
outputChatBox("This isn't a Banshee!")
end
end
end
addEventHandler("onClientPlayerVehicleEnter",getRootElement(),checkVehicles)
addEventHandler("onClientPlayerVehicleEnter", localPlayer, checkVehicles)
</syntaxhighlight>
</syntaxhighlight>



Revision as of 20:08, 21 July 2020

This event is fired when a player or ped enters a vehicle.

Parameters

vehicle theVehicle, int seat
  • theVehicle: the vehicle that the player entered
  • seat: the seat that the player now is on. Driver's seat = 0, higher numbers are passenger seats.

Source

The source of this event is the player or ped that entered the vehicle.

Example

This example will tell you the name of the vehicle you enter.

function checkVehicles(theVehicle)
	outputChatBox("You entered a "..getVehicleName(theVehicle).."!")
end
addEventHandler("onClientPlayerVehicleEnter", localPlayer, checkVehicles)

See Also

Client player events


Client event functions