• Voice Chat: Making one player hear another
    9 replies, posted
Id like to make it so that (this is DRP by the way) under specific conditions, certain players can hear each other regardless of voice chat radius. I know theres Gamemode.PlayerCanHearPlayersVoice but wouldnt that only work within a radius? Thanks!
[code] -- Psuedocode hook.Add("PlayerCanHearPlayersVoice", "VoiceThingy", function( listener, talker ) if talker == talkerPerson and listener == allowedListener then return true end end) [/code] [url]http://wiki.garrysmod.com/page/GM/PlayerCanHearPlayersVoice[/url] I recommend you use a table though.
Will this avoid 3d Voice chat radius all together? Thats what im aiming for, Im trying to make a call system.
on distance: [lua] local function distcheck(pos1, pos2) --function to check distances in space if type(pos1) && type(pos2) == "Vector" then return pos1:Distance(pos2) end return false end function GM:PlayerCanHearPlayersVoice(listener, talker) if distcheck(listener:GetPos(), talker:GetPos()) < 150 then return true, false end return false, false end [/lua] you need to specify how you want to hear people
Nah I ment, what I want is basically being able to make one player hear another (and vice versa ofc) regardless of voice chat radius meaning, it doesnt matter if they are next to each other or at the other end of the map they will still hear each other.
[QUOTE=Chizbang;44908827]Nah I ment, what I want is basically being able to make one player hear another (and vice versa ofc) regardless of voice chat radius meaning, it doesnt matter if they are next to each other or at the other end of the map they will still hear each other.[/QUOTE] [lua] function GM:PlayerCanHearPlayersVoice(listener, talker) return true, false end [/lua]
[QUOTE=john552;44910141][lua] function GM:PlayerCanHearPlayersVoice(listener, talker) return true, false end [/lua][/QUOTE] How do I specify the listener and the talker? Do I call the function and put the players in the arguments? Sorry, Im pretty stupid :p
[QUOTE=Chizbang;44910172]How do I specify the listener and the talker? Do I call the function and put the players in the arguments? Sorry, Im pretty stupid :p[/QUOTE] the listener and talker are already specified when a player talks, just override your normal playerscanhearplayersvoice with this
[QUOTE=Chizbang;44910172]How do I specify the listener and the talker? Do I call the function and put the players in the arguments? Sorry, Im pretty stupid :p[/QUOTE] look at my earlier post, I explained it. Also, listener and talker are automatically declared in the function when a player talks.
[QUOTE=Chizbang;44910172]How do I specify the listener and the talker? Do I call the function and put the players in the arguments? Sorry, Im pretty stupid :p[/QUOTE] To answer both of your questions, the first return value is whether they should hear each other talk, and the second value is whether 3D sound should be used or not, so if you return true, false they will hear each other and it will sound like a "phone call" And the two arguments in the function are the two people talking, this is a hook remember so it gets called any time someone talks and for every player that is in the game. So what you want to do is on your phone code, set something like this: player1.TalkingTo = player2 player2.TalkingTo = player1 then in your hook you do [code]hook.Add("PlayerCanHearPlayersVoice", "PlayerCanHearPlayersVoicePhoneCall", function(ply1, ply2) return ply1.TalkingTo and ply1.TalkingTo == ply2, false end)[/code]
Sorry, you need to Log In to post a reply to this thread.