Garry's Mod Wiki

Revision Difference

GM:PlayerCanHearPlayersVoice#552526

<function name="PlayerCanHearPlayersVoice" parent="GM" type="hook"> <ishook>yes</ishook> <description> Decides whether a player can hear another player using voice chat. ⤶ <note>This hook is called **several** times a tick, so ensure your code is efficient.</note>⤶ ⤶ <warning>This hook is called **several** times a tick, so ensure your code is efficient.</warning>⤶ </description> <realm>Server</realm> <predicted>No</predicted> <hidepredictionwarning>No</hidepredictionwarning> <args> <arg name="listener" type="Player">The listening player.</arg> <arg name="talker" type="Player">The talking player.</arg> </args> <rets> <ret name="" type="boolean">Return `true` if the listener should hear the talker, `false` if they shouldn't.</ret> <ret name="" type="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.</ret> </rets> </function> <example> <description>Players can only hear each other if they are within 500 units.</description> <code> hook.Add( "PlayerCanHearPlayersVoice", "Maximum Range", function( listener, talker ) if listener:GetPos():DistToSqr( talker:GetPos() ) > 250000 then return false end end ) </code> </example>