3D Voice

How can you increase the range of 3D voice chat? I’d like to make it more realistic.

the hook PlayerCanHearPlayer I believe

The documentation: http://wiki.garrysmod.com/?title=Gamemode.PlayerCanHearPlayersVoice

Does not suggest that would work.

[lua]
hook.Add(“PlayerCanHearPlayersVoice”, “asd”, function(listener, talker)
for k, v in pairs( ents.FindInSphere( talker:GetPos(), 500) //origin, radius
if( v == listener ) then
return true;
else
return false;
end
end
end)
[/lua]

Something to that effect

Couldn’t you do something a bit simpler?
[lua]
if listner:Distance(talker:GetPos()) <= 200 then
–blah whatever
[/lua]
I mean of course that’s not the whole code but you can do something with that strip.

wait…

I’m confused now, are you trying to create your own chat radius or what?

yeah

For one thing, I’m pretty sure this wouldn’t work except truncate the current maximum 3D voice range.

Also, it would be more efficient to do listener:GetPos():Distance(talker:GetPos())

Anyone else know?

[lua]
hook.Add(“PlayerCanHearPlayersVoice”, “asd”, function(listener, talker)
if( (listener:GetPos() - talker:GetPos() ):LengthSqr <= /Your distance^2/ ) then // because if im remembering correctly Flapadar told me LengtSqr was more effecient then Length I might be wrong
return true
else
return false;
end
end)
[/lua]

maybe?

I’m pretty sure that won’t work. The documentation implies that returning the second value true will enable 3D voice. Logically, if “true, true” enables 3D voice, then doing distance checks would only truncate the normal maximum distance.

Currently, I’m not able to check it, however I’m sure someone out there already knows the answer?

The way I understand it, the documentation suggests that the first “true” determines if it’s heard. The second true may enable 3D voice, but if you don’t deal with that at all and just simply check the distance yourself it should work just fine. I don’t have any method of testing this at the moment, sadly. It shouldn’t be hard to test the script if someone has access to another human being.

You need to overwrite the base function, not just hook it.

The problem is that I really DO want 3D voice, so that people close are louder, and there is positional sound. I’ve played games where this is done effectively before, and the experience is quite mindblowing, because it sounds just like real-life. Specifically, I’m talking about BF2: Project Reality with Mumble. You can hear people from up to 50m away, however it becomes very faint when they’re far away.

So your aim is to make them louder as they come closer? not just being able to hear them?

I’d just like to know how to change the range of the current 3D Voice system. 3D Voice is that new feature that was added recently, which actually gave people using voice chat a positional source, so it actually sounded like it was coming from them.

I saw DarkRP had the option of enabling this in the admin menu, have you tried looking into DarkRP’s code?