Garry's Mod Wiki

GM:PlayerCanHearPlayersVoice

  boolean, boolean GM:PlayerCanHearPlayersVoice( Player listener, Player talker )

Description

Decides whether a player can hear another player using voice chat.

This hook is called several times a tick, so ensure your code is efficient.

Arguments

1 Player listener
The listening player.
2 Player talker
The talking player.

Returns

1 boolean
Return true if the listener should hear the talker, false if they shouldn't.
2 boolean
3D sound. If set to true, will fade out the sound the further away listener is from the talker, the voice will also be in stereo, and not mono.

Example

Players can only hear each other if they are within 500 units.

hook.Add( "PlayerCanHearPlayersVoice", "Maximum Range", function( listener, talker ) if listener:GetPos():DistToSqr( talker:GetPos() ) > 250000 then return false end end )