GetVehicleRotorState

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

ADDED/UPDATED IN VERSION 1.6.0 r22862:
This function returns a vehicle's (plane or helicopter) rotor state (on or off).
[[{{{image}}}|link=|]] Note: The function should not be confused with getVehicleEngineState.

Syntax

bool getVehicleRotorState ( vehicle theVehicle )


OOP Syntax Help! I don't understand this!

Method: vehicle:getRotorState(...)
Variable: .rotorState
Counterpart: setVehicleRotorState


Required Arguments

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

Returns

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

Example

Click to collapse [-]
Client

This code adds a simple command that allows you to check a vehicle's rotor state keeping in mind you have to be in either a plane or helicopter.

function checkRotor()
    -- We need to check if the player is in a vehicle, and whether or not it is a plane or helicopter
    local vehicle = getPedOccupiedVehicle(localPlayer)
    if (not vehicle or (getVehicleType(vehicle) ~= "Helicopter" and getVehicleType(vehicle) ~= "Plane")) then
        outputChatBox("You are not in a plane or helicopter!", 255, 0, 0)
        return false
    end
    -- And now we show rotor state using a neat ternary expression
    local rotorState = getVehicleRotorState(vehicle)
    outputChatBox("Your vehicle's rotor is "..(rotorState and "spinning" or "stopped").."!", 0, 255, 0)
end
addCommandHandler("rotor", checkRotor)

See Also