Audio::setRadioToStationName: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
For a full list, see here: pastebin.com/Kj9t38KF==Syntax==<syntaxhighlight lang="javascript">audio.setRadioToStationName(stationName);</syntaxhighlight>=== Required Arguments ===*'''stationName:''' String===Return value===*'''Undefined'''==Example==<syntaxhighlight lang="javascript">todo</syntaxhighlight>==See also=={{Audio_function_c}}[[Category:Clientside API]][[Category:TODO: Example]]
{{ClientsideJsFunction}}
{{JSContainer|
 
===Required Params===
*'''stationName:''' {{RageType|string}} — The name of the radio station to set.
 
===Return value===
*'''void''' — This function does not return a value.
 
==Syntax==
<syntaxhighlight lang="javascript">
// 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
});
</syntaxhighlight>
}}
 
== 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'''
 
==See also==
{{Audio_functions_c}}
[[Category:Clientside API]]
[[Category:TODO: Example]]

Latest revision as of 20:34, 6 October 2024

Client-Side
Function

 JavaScript



JavaScript Syntax


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

See also