VoiceChat.defaultVolume: Difference between revisions
No edit summary |
|||
| Line 3: | Line 3: | ||
===Required Params=== | ===Required Params=== | ||
*'''volume:''' {{RageType|number}} | *'''volume:''' {{RageType|number}} — The desired volume level for the voice chat (0 to 1). | ||
===Return value=== | ===Return value=== | ||
*''' | *'''void''' — This function does not return a value. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
mp.voiceChat.defaultVolume = volume; | // Function to set the voice chat volume | ||
function setVoiceChatVolume() { | |||
let volume = 0.5; // Set the desired volume level (0 = muted, 1 = maximum) | |||
// Set the default voice chat volume | |||
mp.voiceChat.defaultVolume = volume; | |||
// Notify the player that the voice chat volume has been set | |||
mp.gui.chat.push("Voice chat volume set to: " + volume); | |||
} | |||
// Bind the function to a key (the "E" key) | |||
mp.keys.bind(69, false, function() { // 69 is the key code for "E" | |||
// | setVoiceChatVolume(); // Call the function to change the voice chat volume | ||
}); | |||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | }} | ||
==See | |||
{{ | ==See also== | ||
{{VoiceChat_functions_c}} | |||
[[Category:Clientside API]] | |||
[[Category:TODO: Example]] | |||
Latest revision as of 20:47, 6 October 2024
Client-Side Function
JavaScript Syntax
Required Params
- volume: number — The desired volume level for the voice chat (0 to 1).
Return value
- void — This function does not return a value.
Syntax
// Function to set the voice chat volume
function setVoiceChatVolume() {
let volume = 0.5; // Set the desired volume level (0 = muted, 1 = maximum)
// Set the default voice chat volume
mp.voiceChat.defaultVolume = volume;
// Notify the player that the voice chat volume has been set
mp.gui.chat.push("Voice chat volume set to: " + volume);
}
// Bind the function to a key (the "E" key)
mp.keys.bind(69, false, function() { // 69 is the key code for "E"
setVoiceChatVolume(); // Call the function to change the voice chat volume
});