GetVehicleEngineState

From Multi Theft Auto: Wiki
Revision as of 12:08, 23 November 2011 by OpenIDUser32 (talk | contribs)

Jump to: navigation, search

This function returns a vehicle's engine state (on or off).

Syntax

bool getVehicleEngineState ( vehicle theVehicle )

Required Arguments

  • theVehicle: The vehicle you wish to get the engine state of.

Returns

Returns true if the vehicle's engine is started, false otherwise.

Example

Click to collapse [-]
Serverside example

This example will switch the vehicle engine state with the command "/switchengine".

function switchEngine ( playerSource )
    local theVehicle = getPedOccupiedVehicle ( playerSource )

    -- Check if the player is in any vehicle and if he is the driver
    if theVehicle and getVehicleController ( theVehicle ) == playerSource then
        local state = getVehicleEngineState ( theVehicle )
        setVehicleEngineState ( theVehicle, not state )
    end
end
addCommandHandler ( "switchengine", switchEngine )

Changelog

See Also

FROM VERSION 1.6 r7485 ONWARDS
FROM VERSION 1.6 r7485 ONWARDS