Looking for a LUA coder to add a voice radius to WinterSurvival! :D

Thread Resolved

[lua]
VC_MAX_RADIUS = 120
timer.Create( “VoiceChatRadius”, 1, 0, function()
local lpl = LocalPlayer();
for _,ply in ipairs(player:GetAll()) do
if (ply ~= lpl) then
if (ply:GetPos():Distance(lpl:GetPos()) <= VC_MAX_RADIUS) then
ply:SetMuted(false);
else
ply:SetMuted(true);
end
end
end
end)
[/lua]

EDIT:
VC_MAX_RADIUS is obviously the distance at which you can hear someone.

Great thanks!

Now where would I place this?

OH WAIT let me guess. init.lua? cl_init.lua?

:smiley:

http://wiki.garrysmod.com/?title=Gamemode.PlayerCanHearPlayersVoice would probably be better than God’s suggestion.

Oh my, Very nice suggestion. Thing is wouldn’t the admins need to talk to the players aswell? :wink:

Nice idea though. Player cant hear admins talk :stuck_out_tongue:

But my question still stands: Where do I place this?

:slight_smile:

OH YES and this just crossed my mind; Wouldnt there need to be an OOC chat aswell? :open_mouth:

[lua]
local VOICE_RADIUS = 256;

function GAMEMODE:PlayerCanHearPlayersVoice(listener, speaker)
local listeners = ents.FindInSphere(listener:GetPos(), VOICE_RADIUS);

 for k, v in pairs(listeners) do
      if (ValidEntity(v) and v:IsPlayer() and v === listener) then
           return true;
      end;
 end;

 return false;

end;
[/lua]

Make a file with the following code in lua/autorun/server/voice_radius.lua

Well let’s see if it works!

I will post back soon as I can test and get results.

Quick typo, change

[lua]
if (ValidEntity(v) and v:IsPlayer() and v === listener) then
[/lua]

to

[lua]
if (ValidEntity(v) and v:IsPlayer() and v == listener) then
[/lua]

After this revision I was able to test it and yield positive results! It works :smiley:

Thank you Chessnut. Now for my next challange: Figuring out why I keep falling through the map!

(Probably going to have to make another Thread for that :P)

Thread Resolved