Radio
constRadio:object
Defined in: client/api.d.ts:875
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
Section titled “Type Declaration”getStation()
Section titled “getStation()”getStation():
number|null
Gets the currently tuned station id.
Returns
Section titled “Returns”number | null
The station id, or null when the radio is off or no station is tuned.
getStationCount()
Section titled “getStationCount()”getStationCount():
number
Gets the number of loaded stations.
Returns
Section titled “Returns”number
The station count (0 before radio content has streamed in).
getStationId()
Section titled “getStationId()”getStationId(
name):number|null
Resolves a station name to its id.
Parameters
Section titled “Parameters”string
Station name, e.g. “Empire”.
Returns
Section titled “Returns”number | null
The station id, or null when no station has that name.
getStationName()
Section titled “getStationName()”getStationName():
string|null
Gets the name of the currently tuned station.
Returns
Section titled “Returns”string | null
The station name, or null when off or the station name is unknown.
getStations()
Section titled “getStations()”getStations():
string[]
Lists the names of the currently loaded stations.
Returns
Section titled “Returns”string[]
An array of station names (empty before radio content has streamed in).
isAvailable()
Section titled “isAvailable()”isAvailable():
boolean
Checks whether the local player is the active driver of a car with a radio receiver.
Returns
Section titled “Returns”boolean
True when the in-car radio can be read or controlled.
isLocked()
Section titled “isLocked()”isLocked():
boolean
Checks whether the server has locked this vehicle’s radio, which rejects local control.
Returns
Section titled “Returns”boolean
True when the server owns the radio state.
isOn()
Section titled “isOn()”isOn():
boolean
Checks whether the radio is currently powered on.
Returns
Section titled “Returns”boolean
True when the radio is on.
next()
Section titled “next()”next():
boolean
Tunes to the next station, wrapping around.
Returns
Section titled “Returns”boolean
True when applied; false when unavailable, server-locked, or no stations are loaded.
previous()
Section titled “previous()”previous():
boolean
Tunes to the previous station, wrapping around.
Returns
Section titled “Returns”boolean
True when applied; false when unavailable, server-locked, or no stations are loaded.
setStation()
Section titled “setStation()”setStation(
station):boolean
Tunes the radio to a station and turns it on.
Parameters
Section titled “Parameters”station
Section titled “station”string | number
Station id or station name to tune to.
Returns
Section titled “Returns”boolean
True when applied; false when unavailable, server-locked, or the station is invalid.
turnOff()
Section titled “turnOff()”turnOff():
boolean
Powers the radio off.
Returns
Section titled “Returns”boolean
True when applied; false when unavailable or server-locked.
turnOn()
Section titled “turnOn()”turnOn():
boolean
Powers the radio on.
Returns
Section titled “Returns”boolean
True when applied; false when unavailable or server-locked.
