Ok so what i want to do is a rp chat, so people thats to far away from you cant see what your saying. But idk what hook i should use for this.
Ive tried the hook **[Gamemode.PlayerCanSeePlayersChat
[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
if (ply:IsMuted()) then
lpl:SetMuted(ply);
end
elseif (not ply:IsMuted()) then
lpl:SetMuted(ply);
end
end
end
end)
[/lua]
You can easily do something like that for Chat Range as well
Ive made the voice chat radous for my gamemode but it shouldnt return exacly the same on all chat types.
If your yelling the text should be orange if its local ooc it should be grey…
[lua]
local voiceRadius = 500
hook.Add( “PlayerCanHearPlayersVoice”, “SomeUniqueName”, function( pListener, pTalker )
if pListener:GetPos():Distance( pTalker:GetPos() ) > voiceRadius then
return false
end
end )[/lua]
raBBish, you set upa a “VoiceRadius” variable but you aren’t using it, I think you meant
[lua]
local voiceRadius = 500
hook.Add( “PlayerCanHearPlayersVoice”, “SomeUniqueName”, function( pListener, pTalker )
if pListener:GetPos():Distance( pTalker:GetPos() ) > voiceRadius then
return false
end
end )
[/lua]
for other people who want to see how to do it. and since you werent sincere enough to post your script, others are helping out and showing them how to do it. Thats why…
Tip: Use vector:LengthSqr() and square your maximum distance as well. That way you don’t have to do a square root to every player every time someone says something.
VectorFinal = vector1 - vector2 //The order you do this in doesn't matter, since you square the result anyways, it'll always be positive. You could do vector2 - vector1 and get the same answer.
if VectorFinal:LengthSqr() > MaximumRadius ^ 2 then
Why is the OP answering the people that are trying to help him. You ask a question, then you disregard what people say with the reply “I done that already”