SetRadioChannel: Difference between revisions
Jump to navigation
Jump to search
m (→Example) |
(Remove spaces) |
||
(16 intermediate revisions by 11 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
This function sets the | This function sets the heard radio channel, even while not in a vehicle. | ||
{{Note|This function sometimes doesn't work when setting the radio channel to another different from the current one due to unknown reasons. If you experience this issue, simply add setRadioChannel(0) at the beginning of the script, outside any function.}} | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool setRadioChannel ( int ID ) | bool setRadioChannel ( int ID ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 16: | Line 17: | ||
Returns ''true'' if channel was set successfully, ''false'' otherwise. | Returns ''true'' if channel was set successfully, ''false'' otherwise. | ||
==Example== | ==Example== | ||
This example adds a command ''setradio'' which can be used to change the current radio station by ID. | |||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addCommandHandler ( "setradio", | addCommandHandler ( "setradio", | ||
function ( command, stationID ) | function ( command, stationID ) | ||
setRadioChannel ( tonumber( stationID ) ) | local result = setRadioChannel ( tonumber( stationID ) ) | ||
outputChatBox ( " | if result then -- if we had a valid ID | ||
outputChatBox ( "Changed your radio station to " .. getRadioChannelName ( tonumber ( stationID ) ) .. "!" ) | |||
else | |||
outputChatBox ( "Invalid radio station ID, valid ones are 0-12." ) | |||
end | |||
end | end | ||
) | ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
== Issues == | |||
{{Issues| | |||
{{Issue|423|setRadioChannel doesn't work when outside a vehicle}} | |||
}} | |||
==See Also== | ==See Also== | ||
{{Client_audio_functions}} | {{Client_audio_functions}} | ||
[[hu:setRadioChannel]] | |||
[[AR:setRadioChannel]] | |||
[[RO:SetRadioChannel]] | |||
[[PT-BR:setRadioChannel]] |
Latest revision as of 20:39, 29 October 2023
This function sets the heard radio channel, even while not in a vehicle.
Syntax
bool setRadioChannel ( int ID )
Required Arguments
- ID: The ID of the radio station you want to play.
- 0: Radio Off
- 1: Playback FM
- 2: K-Rose
- 3: K-DST
- 4: Bounce FM
- 5: SF-UR
- 6: Radio Los Santos
- 7: Radio X
- 8: CSR 103.9
- 9: K-Jah West
- 10: Master Sounds 98.3
- 11: WCTR
- 12: User Track Player
Returns
Returns true if channel was set successfully, false otherwise.
Example
This example adds a command setradio which can be used to change the current radio station by ID.
Click to collapse [-]
ClientaddCommandHandler ( "setradio", function ( command, stationID ) local result = setRadioChannel ( tonumber( stationID ) ) if result then -- if we had a valid ID outputChatBox ( "Changed your radio station to " .. getRadioChannelName ( tonumber ( stationID ) ) .. "!" ) else outputChatBox ( "Invalid radio station ID, valid ones are 0-12." ) end end )
Issues
Issue ID | Description |
---|---|
#423 | setRadioChannel doesn't work when outside a vehicle |
See Also
- getRadioChannel
- getRadioChannelName
- getSFXStatus
- getSoundBPM
- getSoundBufferLength
- getSoundEffectParameters
- getSoundEffects
- getSoundFFTData
- getSoundLength
- getSoundLevelData
- getSoundMaxDistance
- getSoundMetaTags
- getSoundMinDistance
- getSoundPan
- getSoundPosition
- getSoundProperties
- getSoundSpeed
- getSoundVolume
- getSoundWaveData
- isSoundLooped
- isSoundPanningEnabled
- isSoundPaused
- playSFX3D
- playSFX
- playSound3D
- playSound
- setRadioChannel
- setSoundEffectEnabled
- setSoundEffectParameter
- setSoundLooped
- setSoundMaxDistance
- setSoundMinDistance
- setSoundPan
- setSoundPanningEnabled
- setSoundPaused
- setSoundPosition
- setSoundProperties
- setSoundSpeed
- setSoundVolume
- stopSound
- Shared
- playSoundFrontEnd