GetVehicleEngineState

From Multi Theft Auto: Wiki
Revision as of 01:13, 24 June 2008 by Ryden (talk | contribs) (New page: __NOTOC__ {{Server client function}} This function returns a vehicle's engine state (on or off). ==Syntax== <section name="Server and Client" class="both" show="true"> <syntaxhighlight lang="lua"> bool ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

Syntax

Click to collapse [-]
Server and Client
bool getVehicleEngineState ( vehicle theVehicle )

Required Arguments

  • theVehicle: The vehicle you wish to change 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 = getPlayerOcuppiedVehicle ( 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 )

See Also