Player::enableVoiceTo: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
(Added Serverside C# Example; Added the JSContainer Template, to make the JS example look better.)
Line 7: Line 7:
<pre>
<pre>
player.enableVoiceTo(Player player)
player.enableVoiceTo(Player player)
</pre>
<pre>
Player.EnableVoiceTo(Client player);
</pre>
</pre>


== Examples ==
== Examples ==
{{JSContainer|
{{Example}}


This example below shows how all players can hear the player with ID "0".
This example below shows how all players can hear the player with ID "0".


<pre>
<syntaxhighlight lang="javascript">
let player = mp.players.at(0);
let player = mp.players.at(0);


Line 21: Line 27:
         player.enableVoiceTo(_player);
         player.enableVoiceTo(_player);
});
});
</pre>
</syntaxhighlight>
}}
 
{{CSharpContainer|
{{Example}}
<syntaxhighlight lang="C#">
[Command("listento")]
public void ListenToTarget(Client player, Client target)
{
    player.EnableVoiceTo(target);
 
    //If you want it to be bidirectional
    target.EnableVoiceTo(player);
}
</syntaxhighlight>
}}


== See Also ==
== See Also ==

Revision as of 06:00, 26 November 2019

Server-Side

This function is used to enable voice listening to a certain player.

Syntax

player.enableVoiceTo(Player player)
Player.EnableVoiceTo(Client player);

Examples

JavaScript Syntax

Example

This example below shows how all players can hear the player with ID "0".

let player = mp.players.at(0);

mp.players.forEach((_player) => {
        if(player == _player) return false;
        
        player.enableVoiceTo(_player);
});



C# Syntax

Example

[Command("listento")]
public void ListenToTarget(Client player, Client target)
{
    player.EnableVoiceTo(target);

    //If you want it to be bidirectional
    target.EnableVoiceTo(player);
}


See Also