gear

Used to set or get the vehicle indicator lights.

Indicator Lights

{
    None: 0,
    BlinkLeft: 1,
    BlinkRight: 2,
    BlinkPermBoth: 4,
    StaticBoth: 8,
    Interior: 64,
}

Returns a number.

Declaration

vehicle.indicatorLights: number

Usage

const currentIndicator = vehicle.indicatorLights;

// OR

vehicle.indicatorLights = 2;

Real World Example

This is a simple turn blinker script. Pretty much turns on indicator lights depending on what arrow key you press while in a vehicle.

const LEFT_ARROW = 37;
const RIGHT_ARROW = 39;

let turnTimeout;

function handleKeyPress(keyValue) {
    if (!alt.Player.local.vehicle) {
        return;
    }

    if (turnTimeout) {
        alt.clearTimeout(turnTimeout);
        turnTimeout = null;
    }

    if (keyValue === LEFT_ARROW) {
        alt.Player.local.vehicle.indicatorLights = 1;
    }

    if (keyValue === RIGHT_ARROW) {
        alt.Player.local.vehicle.indicatorLights = 2;
    }

    alt.setTimeout(() => {
        if (!alt.Player.local.vehicle) {
            return;
        }

        alt.Player.local.vehicle.indicatorLights = 0;
    }, 5000);
}

alt.on('keyup', handleKeyPress);

These examples assume you have a vehicle available on client-side.

results matching ""

    No results matching ""