OnClientVehicleEnter

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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

Parameters

ped thePed, int seat
  • thePed: the player or ped that entered the vehicle
  • seat: the number of the seat that the ped is now sitting on. 0 = driver, higher numbers are passenger seats.

Source

The source of the event is the vehicle that the ped entered.

Example

This code updates a GUI label with the name of the vehicle the local player is in.

lblVehicle = guiCreateLabel(10, 200, 150, 20, "Currently on foot", false)
addEventHandler("onClientVehicleEnter", getRootElement(),
    function(thePlayer, seat)
        if thePlayer == getLocalPlayer() then
            guiSetText(lblVehicle, "Currently in a " .. getVehicleName(source))
        end
    end
)
addEventHandler("onClientVehicleExit", getRootElement(),
    function(thePlayer, seat)
        if thePlayer == getLocalPlayer() then
            guiSetText(lblVehicle, "Currently on foot")
        end
    end
)

This example disables helikills & blade collisions upon entering a heli

function onHeliEnter()
   if getVehicleType(source) == "Helicopter" then
           setHeliBladeCollisionsEnabled (source, false)
    end
end
addEventHandler ("onClientVehicleEnter", root, onHeliEnter)

See Also

Client vehicle events


Client event functions