Audio::setRadioToStationName
JavaScript
Required Params
- stationName: string — The name of the radio station to set.
Return value
- void — This function does not return a value.
Syntax
// Function to set the radio station
function setRadioStation(stationName) {
// Check if the player is in a vehicle
let player = mp.players.local; // Reference to the local player
if (player.vehicle) { // Check if the player is in a vehicle
// Set the radio to the specified station
mp.game.audio.setRadioToStationName(stationName);
// Notify the player that the radio station has been changed
mp.gui.chat.push("Radio station set to: " + stationName);
} else {
// Notify the player that they need to be in a vehicle to change the radio
mp.gui.chat.push("You must be in a vehicle to change the radio station.");
}
}
// Bind the function to a key (for example, the "E" key)
mp.keys.bind(69, false, function() { // 69 is the key code for "E"
let stationName = "RADIO_01_CLASS_ROCK"; // Replace with the desired radio station name
setRadioStation(stationName); // Call the function to change the radio station
});
List of GTA 5 Radio Stations
- RADIO_01_LOS_SANTOS
- RADIO_02_LODOWN
- RADIO_03_ROCK
- RADIO_04_PUNK
- RADIO_05_TALK_01
- RADIO_06_CLASSIC
- RADIO_07_REBEL
- RADIO_08_SOULWAX
- RADIO_09_EAST_LA
- RADIO_10_WORLDWIDE
- RADIO_11_FLYLO
- RADIO_12_THELAB
- RADIO_13_SELF
- RADIO_14_IFRUIT
- RADIO_15_MIRRORPARK
- RADIO_16_NOSTALGIA
- RADIO_17_SPORTS
- RADIO_18_CLASSICS
- RADIO_19_WINNERS
- RADIO_20_RNB