SetPlayerVoiceRange

From Onset Developer Wiki
SetPlayerVoiceRange

Type: Function
Context: Server
Introduced: v1.4.1

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)

See also