Audio::setRadioToStationName: Difference between revisions
(yay) |
No edit summary |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
{{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== | ==Syntax== | ||
<syntaxhighlight lang="javascript"> | <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> | </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== | ==See also== | ||
{{ | {{Audio_functions_c}} | ||
[[Category:Clientside API]] | [[Category:Clientside API]] | ||
[[Category:TODO: Example]] | [[Category:TODO: Example]] | ||
Latest revision as of 20:34, 6 October 2024
Client-Side Function
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
- mp.game.audio.playPedRingtone
- mp.game.audio.isPedRingtonePlaying
- mp.game.audio.stopPedRingtone
- mp.game.audio.isMobilePhoneCallOngoing
- mp.game.audio.createNewScriptedConversation
- mp.game.audio.addLineToConversation
- mp.game.audio.addPedToConversation
- mp.game.audio.setMicrophonePosition
- mp.game.audio.startScriptPhoneConversation
- mp.game.audio.preloadScriptPhoneConversation
- mp.game.audio.startScriptConversation
- mp.game.audio.preloadScriptConversation
- mp.game.audio.startPreloadedConversation
- mp.game.audio.getIsPreloadedConversationReady
- mp.game.audio.isScriptedConversationOngoing
- mp.game.audio.isScriptedConversationLoaded
- mp.game.audio.getCurrentScriptedConversationLine
- mp.game.audio.pauseScriptedConversation
- mp.game.audio.restartScriptedConversation
- mp.game.audio.stopScriptedConversation
- mp.game.audio.skipToNextScriptedConversationLine
- mp.game.audio.interruptConversation
- mp.game.audio.interruptConversationAndPause
- mp.game.audio.registerScriptWith
- mp.game.audio.registerScriptWithAudio
- mp.game.audio.unregisterScriptWith
- mp.game.audio.requestMissionBank
- mp.game.audio.requestMissionAudioBank
- mp.game.audio.requestAmbientBank
- mp.game.audio.requestAmbientAudioBank
- mp.game.audio.requestScriptBank
- mp.game.audio.requestScriptAudioBank
- mp.game.audio.hintAmbientBank
- mp.game.audio.hintAmbientAudioBank
- mp.game.audio.hintScriptBank
- mp.game.audio.hintScriptAudioBank
- mp.game.audio.releaseMissionBank
- mp.game.audio.releaseAmbientBank
- mp.game.audio.releaseNamedScriptBank
- mp.game.audio.releaseNamedScriptAudioBank
- mp.game.audio.releaseScriptBank
- mp.game.audio.getSoundId
- mp.game.audio.releaseSoundId
- mp.game.audio.playSound
- mp.game.audio.playSoundFrontend
- mp.game.audio.playDeferredSoundFrontend
- mp.game.audio.playSoundFromEntity
- mp.game.audio.playSoundFromCoord
- mp.game.audio.stopSound
- mp.game.audio.getNetworkIdFromSoundId
- mp.game.audio.getSoundIdFromNetworkId
- mp.game.audio.setVariableOnSound
- mp.game.audio.setVariableOnStream
- mp.game.audio.overrideUnderwaterStream
- mp.game.audio.setVariableOnUnderWaterStream
- mp.game.audio.hasSoundFinished
- mp.game.audio.playPedAmbientSpeechNative
- mp.game.audio.playPedAmbientSpeechAndCloneNative
- mp.game.audio.playPedAmbientSpeechWithVoiceNative
- mp.game.audio.playAmbientSpeechWithVoice
- mp.game.audio.playAmbientSpeechFromPositionNative
- mp.game.audio.playAmbientSpeechAtCoords
- mp.game.audio.overrideTrevorRage
- mp.game.audio.resetTrevorRage
- mp.game.audio.setPlayerAngry
- mp.game.audio.playPain
- mp.game.audio.releaseWeapon
- mp.game.audio.activateSlowmoMode
- mp.game.audio.deactivateSlowmoMode
- mp.game.audio.setAmbientVoiceName
- mp.game.audio.setAmbientVoiceNameHash
- mp.game.audio.getAmbientVoiceNameHash
- mp.game.audio.setPedScream
- mp.game.audio.setPedVoiceGroup
- mp.game.audio.setPedGender
- mp.game.audio.stopCurrentPlayingSpeech
- mp.game.audio.stopCurrentPlayingAmbientSpeech
- mp.game.audio.isAmbientSpeechPlaying
- mp.game.audio.isScriptedSpeechPlaying
- mp.game.audio.isAnySpeechPlaying
- mp.game.audio.canPedSpeak
- mp.game.audio.isPedInCurrentConversation
- mp.game.audio.setPedIsDrunk
- mp.game.audio.playAnimalVocalization
- mp.game.audio.isAnimalVocalizationPlaying
- mp.game.audio.setAnimalMood
- mp.game.audio.isMobilePhoneRadioActive
- mp.game.audio.setMobilePhoneRadioState
- mp.game.audio.getPlayerRadioStationIndex
- mp.game.audio.getPlayerRadioStationName
- mp.game.audio.getRadioStationName
- mp.game.audio.getPlayerRadioStationGenre
- mp.game.audio.isRadioRetuning
- mp.game.audio.isRadioFadedOut
- mp.game.audio.setRadioToStationName
- mp.game.audio.setVehRadioStation
- mp.game.audio.setVehHasRadioOverride
- mp.game.audio.isVehicleRadioEnabled
- mp.game.audio.setEmitterRadioStation
- mp.game.audio.setStaticEmitterEnabled
- mp.game.audio.linkStaticEmitterToEntity
- mp.game.audio.setRadioToStationIndex
- mp.game.audio.setFrontendRadioActive
- mp.game.audio.unlockMissionNewsStory
- mp.game.audio.isMissionNewsStoryUnlocked
- mp.game.audio.getNumberOfPassengerVoiceVariations
- mp.game.audio.getAudibleMusicTrackTextId
- mp.game.audio.playEndCreditsMusic
- mp.game.audio.skipRadioForward
- mp.game.audio.freezeRadioStation
- mp.game.audio.unfreezeRadioStation
- mp.game.audio.setRadioAutoUnfreeze
- mp.game.audio.setInitialPlayerStation
- mp.game.audio.setUserRadioControlEnabled
- mp.game.audio.setRadioTrack
- mp.game.audio.setRadioTrackMix
- mp.game.audio.setVehicleRadioLoud
- mp.game.audio.isVehicleRadioLoud
- mp.game.audio.setMobileRadioEnabledDuringGameplay
- mp.game.audio.doesPlayerVehHaveRadio
- mp.game.audio.isPlayerVehRadioEnable
- mp.game.audio.setVehicleRadioEnabled
- mp.game.audio.setCustomRadioTrackList
- mp.game.audio.clearCustomRadioTrackList
- mp.game.audio.getNumUnlockedRadioStations
- mp.game.audio.findRadioStationIndex
- mp.game.audio.setRadioStationMusicOnly
- mp.game.audio.setRadioFrontendFadeTime
- mp.game.audio.unlockRadioStationTrackList
- mp.game.audio.lockRadioStationTrackList
- mp.game.audio.updateLsur
- mp.game.audio.lockRadioStation
- mp.game.audio.setRadioStationIsVisible
- mp.game.audio.forceRadioTrackListPosition
- mp.game.audio.getCurrentRadioStationHash
- mp.game.audio.setAmbientZoneState
- mp.game.audio.clearAmbientZoneState
- mp.game.audio.setAmbientZoneListState
- mp.game.audio.clearAmbientZoneListState
- mp.game.audio.setAmbientZoneStatePersistent
- mp.game.audio.setAmbientZoneListStatePersistent
- mp.game.audio.isAmbientZoneEnabled
- mp.game.audio.setCutsceneOverride
- mp.game.audio.setCutsceneAudioOverride
- mp.game.audio.setVariableOnCutscene
- mp.game.audio.getPlayerHeadsetSoundAlternate
- mp.game.audio.playPoliceReport
- mp.game.audio.cancelCurrentPoliceReport
- mp.game.audio.blipSiren
- mp.game.audio.overrideVehHorn
- mp.game.audio.isHornActive
- mp.game.audio.setAggressiveHorns
- mp.game.audio.isStreamPlaying
- mp.game.audio.getStreamPlayTime
- mp.game.audio.loadStream
- mp.game.audio.loadStreamWithStartOffset
- mp.game.audio.playStreamFromPed
- mp.game.audio.playStreamFromVehicle
- mp.game.audio.playStreamFromObject
- mp.game.audio.playStreamFrontend
- mp.game.audio.playStreamFromPosition
- mp.game.audio.specialFrontendEqual
- mp.game.audio.stopStream
- mp.game.audio.stopPedSpeaking
- mp.game.audio.disablePedPain
- mp.game.audio.isAmbientSpeechDisabled
- mp.game.audio.setSirenWithNoDriver
- mp.game.audio.setSirenKeepOn
- mp.game.audio.triggerSiren
- mp.game.audio.setHornPermanentlyOn
- mp.game.audio.setHornEnabled
- mp.game.audio.setVehiclePriority
- mp.game.audio.setHornPermanentlyOnTime
- mp.game.audio.useSirenAsHorn
- mp.game.audio.forceVehicleEngine
- mp.game.audio.preloadVehicle
- mp.game.audio.setVehicleStartupRevSound
- mp.game.audio.resetVehicleStartupRevSound
- mp.game.audio.isVehicleAudiblyDamaged
- mp.game.audio.setVehicleEngineDamageFactor
- mp.game.audio.setVehicleBodyDamageFactor
- mp.game.audio.enableVehicleFanbeltDamage
- mp.game.audio.enableVehicleExhaustPops
- mp.game.audio.setVehicleBoostActive
- mp.game.audio.setScriptUpdateDoor
- mp.game.audio.playVehicleDoorOpenSound
- mp.game.audio.playVehicleDoorCloseSound
- mp.game.audio.enableStallWarningSounds
- mp.game.audio.isGameInControlOfMusic
- mp.game.audio.setGpsActive
- mp.game.audio.playMissionComplete
- mp.game.audio.playMissionCompleteAudio
- mp.game.audio.isMissionCompletePlaying
- mp.game.audio.isMissionCompleteReadyForUi
- mp.game.audio.blockDeathJingle
- mp.game.audio.startScene
- mp.game.audio.startAudioScene
- mp.game.audio.stopScene
- mp.game.audio.stopAudioScene
- mp.game.audio.stopScenes
- mp.game.audio.isSceneActive
- mp.game.audio.isAudioSceneActive
- mp.game.audio.setSceneVariable
- mp.game.audio.setAudioSceneVariable
- mp.game.audio.setScriptCleanupTime
- mp.game.audio.addEntityToMixGroup
- mp.game.audio.removeEntityFromMixGroup
- mp.game.audio.isScriptedMusicPlaying
- mp.game.audio.isScriptedMusicPlaying2
- mp.game.audio.prepareMusicEvent
- mp.game.audio.cancelMusicEvent
- mp.game.audio.triggerMusicEvent
- mp.game.audio.isMusicOneshotPlaying
- mp.game.audio.getMusicPlaytime
- mp.game.audio.recordBrokenGlass
- mp.game.audio.clearAllBrokenGlass
- mp.game.audio.forcePedPanicWalla
- mp.game.audio.prepareAlarm
- mp.game.audio.startAlarm
- mp.game.audio.stopAlarm
- mp.game.audio.stopAllAlarms
- mp.game.audio.isAlarmPlaying
- mp.game.audio.getVehicleDefaultHorn
- mp.game.audio.getVehicleDefaultHornIgnoreMods
- mp.game.audio.resetPedFlags
- mp.game.audio.resetPedAudioFlags
- mp.game.audio.setPedFootstepLoud
- mp.game.audio.setPedFootstepQuiet
- mp.game.audio.overridePlayerGroundMaterial
- mp.game.audio.overrideMicrophoneSettings
- mp.game.audio.freezeMicrophone
- mp.game.audio.distantCopCarSirens
- mp.game.audio.setFlag
- mp.game.audio.setAudioFlag
- mp.game.audio.prepareSynchronizedEvent
- mp.game.audio.prepareSynchronizedAudioEvent
- mp.game.audio.prepareSynchronizedEventForScene
- mp.game.audio.prepareSynchronizedAudioEventForScene
- mp.game.audio.playSynchronizedEvent
- mp.game.audio.playSynchronizedAudioEvent
- mp.game.audio.stopSynchronizedEvent
- mp.game.audio.stopSynchronizedAudioEvent
- mp.game.audio.setSynchronizedEventPositionThisFrame
- mp.game.audio.setSynchronizedAudioEventPositionThisFrame
- mp.game.audio.setSpecialEffectMode
- mp.game.audio.setPortalSettingsOverride
- mp.game.audio.removePortalSettingsOverride
- mp.game.audio.getMusicVolSlider
- mp.game.audio.requestTennisBanks
- mp.game.audio.unrequestTennisBanks
- mp.game.audio.stopCutscene
- mp.game.audio.hasMultiplayerDataLoaded
- mp.game.audio.hasMultiplayerDataUnloaded
- mp.game.audio.getVehicleDefaultHornVariation
- mp.game.audio.setVehicleHornVariation
- mp.game.audio.restoreCategoryVariables
- mp.game.audio.getCategoryVariable
- mp.game.audio.setCategoryVariable
- mp.game.audio.copyCategoryVariables
- mp.game.audio.playSoundHash