M2O Scripting APIScripting reference
    Preparing search index…
    Global objectClient API

    Radio

    Radio: {
        getStation(): number | null;
        getStationCount(): number;
        getStationId(name: string): number | null;
        getStationName(): string | null;
        getStations(): string[];
        isAvailable(): boolean;
        isLocked(): boolean;
        isOn(): boolean;
        next(): boolean;
        previous(): boolean;
        setStation(station: string | number): boolean;
        turnOff(): boolean;
        turnOn(): boolean;
    }

    Reads and controls the local player's in-car radio. Control is local (not synced to other players) and is rejected while the server has locked the vehicle's radio.

    Type Declaration

    • getStation: function
      • Gets the currently tuned station id.

        Returns number | null

        The station id, or null when the radio is off or no station is tuned.

    • getStationCount: function
      • Gets the number of loaded stations.

        Returns number

        The station count (0 before radio content has streamed in).

    • getStationId: function
      • Resolves a station name to its id.

        Parameters

        • name: string

          Station name, e.g. "Empire".

        Returns number | null

        The station id, or null when no station has that name.

    • getStationName: function
      • Gets the name of the currently tuned station.

        Returns string | null

        The station name, or null when off or the station name is unknown.

    • getStations: function
      • Lists the names of the currently loaded stations.

        Returns string[]

        An array of station names (empty before radio content has streamed in).

    • isAvailable: function
      • Checks whether the local player is the active driver of a car with a radio receiver.

        Returns boolean

        True when the in-car radio can be read or controlled.

    • isLocked: function
      • Checks whether the server has locked this vehicle's radio, which rejects local control.

        Returns boolean

        True when the server owns the radio state.

    • isOn: function
      • Checks whether the radio is currently powered on.

        Returns boolean

        True when the radio is on.

    • next: function
      • Tunes to the next station, wrapping around.

        Returns boolean

        True when applied; false when unavailable, server-locked, or no stations are loaded.

    • previous: function
      • Tunes to the previous station, wrapping around.

        Returns boolean

        True when applied; false when unavailable, server-locked, or no stations are loaded.

    • setStation: function
      • Tunes the radio to a station and turns it on.

        Parameters

        • station: string | number

          Station id or station name to tune to.

        Returns boolean

        True when applied; false when unavailable, server-locked, or the station is invalid.

    • turnOff: function
      • Powers the radio off.

        Returns boolean

        True when applied; false when unavailable or server-locked.

    • turnOn: function
      • Powers the radio on.

        Returns boolean

        True when applied; false when unavailable or server-locked.