• No Voice Chat in TTT
    3 replies, posted
Hi. I want to deactivate the Voice Chat in TTT So I scripted this: [Lua] for i, ply in pairs(self:GetAlivePlayers()) do hook.Add( "PlayerCanHearPlayersVoice", "Maximum Range", function( listener, talker ) if listener:GetPos():Distance( talker:GetPos() ) > 0 then return false end end )[/Lua] This runs Serverside And this is the Error I´ve got: [ERROR] addons/ttt antirandomat/gamemodes/terrortown/entities/weapons/weapon_ttt_antirandomat/shared.lua:143: attempt to index global 'self' (a nil value) 1. unknown - addons/ttt antirandomat/gamemodes/terrortown/entities/weapons/weapon_ttt_antirandomat/shared.lua:143 2. AntiRandomEvent - addons/ttt antirandomat/gamemodes/terrortown/entities/weapons/weapon_ttt_antirandomat/shared.lua:123 3. unknown - addons/ttt antirandomat/gamemodes/terrortown/entities/weapons/weapon_ttt_antirandomat/shared.lua:104 Line 143 is this: " hook.Add( "PlayerCanHearPlayersVoice", "Maximum Range", function( listener, talker )" Line 123 is an "end" of a function that triggers randomly an event. So the Code above , too. Line 104 is the same function as in Line 123, that is triggered when the player uses SWEP:PrimaryAttack I didn´t use PlayerCanHearPlayersVoice before. Thanks for help.
What is the use of the for loop? You don't need to make a hook for each player (and if you did, you'd be doing it wrong). You also don't need to do any conditional checking if you want to disable it completely, just make it return false no matter what [code] hook.Add("PlayerCanHearPlayersVoice", "DisableVoice", function( listener, talker) return false end) [/code]
[QUOTE=monkeymacman;52513138]What is the use of the for loop? You don't need to make a hook for each player (and if you did, you'd be doing it wrong). You also don't need to do any conditional checking if you want to disable it completely, just make it return false no matter what [code] hook.Add("PlayerCanHearPlayersVoice", "DisableVoice", function( listener, talker) return false end) [/code][/QUOTE] Unless he wants it to only be disabled for living players (Since he tried to use GetLivingPlayers in his original code), in which case: [lua]hook.Add("PlayerCanHearPlayersVoice", "DisableVoice", function( listener, talker) return not listener:IsTerror() and not talker:IsTerror() end)[/lua]
[QUOTE=monkeymacman;52513138]What is the use of the for loop? You don't need to make a hook for each player (and if you did, you'd be doing it wrong). You also don't need to do any conditional checking if you want to disable it completely, just make it return false no matter what [code] hook.Add("PlayerCanHearPlayersVoice", "DisableVoice", function( listener, talker) return false end) [/code][/QUOTE] Thanks for your help. I will try as you said.
Sorry, you need to Log In to post a reply to this thread.