SetPlayerVoiceRange: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.4.1}} {{FuncDescription|Sets the voice range of a player. The range can't be greater than the voice distance set in the server_config|server_confi..." |
No edit summary |
||
Line 16: | Line 16: | ||
== Example == | == Example == | ||
Server: | |||
<syntaxhighlight lang="Lua"> | <syntaxhighlight lang="Lua"> | ||
function | AddRemoteEvent("ServerWhisper", function(player, whisper) | ||
if whisper then | |||
-- Player will be heard only 4 meters (400 cm) | |||
end | SetPlayerVoiceRange(player, 400.0) | ||
else | |||
SetPlayerVoiceRange(player, 0.0) | |||
end | |||
end) | |||
</syntaxhighlight> | |||
Client: | |||
<syntaxhighlight lang="Lua"> | |||
AddEvent("OnKeyPress", function(key) | |||
if key == "N" then | |||
CallRemoteEvent("ServerWhisper", true) | |||
end | |||
end) | |||
AddEvent("OnKeyRelease", function(key) | |||
if key == "N" then | |||
CallRemoteEvent("ServerWhisper", false) | |||
end | |||
end) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 27: | Line 47: | ||
* [[IsPlayerVoiceChannel]] | * [[IsPlayerVoiceChannel]] | ||
*[[SetPlayerVoiceChannel]] | *[[SetPlayerVoiceChannel]] | ||
*[[SetPlayerVoiceRange]] |
Latest revision as of 19:24, 11 January 2021
Description
Sets the voice range of a player.
The range can't be greater than the voice distance set in the server_config.json.
To reset the voice range pass a value of 0.0 or less to this function.
Syntax
SetPlayerVoiceRange(player, range)
Parameters
- player
The player identifier. - range
The desired voice range.
Return Value
- This function returns true on success.
Example
Server:
AddRemoteEvent("ServerWhisper", function(player, whisper)
if whisper then
-- Player will be heard only 4 meters (400 cm)
SetPlayerVoiceRange(player, 400.0)
else
SetPlayerVoiceRange(player, 0.0)
end
end)
Client:
AddEvent("OnKeyPress", function(key)
if key == "N" then
CallRemoteEvent("ServerWhisper", true)
end
end)
AddEvent("OnKeyRelease", function(key)
if key == "N" then
CallRemoteEvent("ServerWhisper", false)
end
end)