VoiceChat.defaultVolume: Difference between revisions
(Created page with "{{ClientsideJsFunction}} {{JSContainer| ===Required Params=== *'''volume:''' {{RageType|number}} ===Return value=== *''' {{RageType|number}} ''' ==Syntax== <syntaxhighlight lang="javascript"> mp.voiceChat.defaultVolume = volume; </syntaxhighlight> ==Example== <syntaxhighlight lang="javascript"> //todo </syntaxhighlight> }} ==See Also== *Functions: **mp.voiceChat.getPreprocessingParam **voiceChat.setPreprocessingParam|mp.voiceChat...") |
No edit summary |
||
| (One intermediate revision by one other user not shown) | |||
| 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
});