Permalink
Browse files

Update cl_voice.lua

Fixed names not always updating if it is changed during speaking.
  • Loading branch information...
1 parent 72ffb70 commit a604ec04125583f85a49dfc7bff6fd2168eb6f3e @robotboy655 robotboy655 committed Jul 15, 2014
Showing with 11 additions and 11 deletions.
  1. +11 −11 garrysmod/gamemodes/terrortown/gamemode/cl_voice.lua
@@ -419,9 +419,11 @@ g_VoicePanelList = nil
-- 255 at 100
-- 5 at 5000
local function VoiceNotifyThink(pnl)
- if not (ValidPanel(pnl) and LocalPlayer() and IsValid(pnl.Player)) then return end
-
- local d = LocalPlayer():GetPos():Distance(pnl.Player:GetPos())
+ if not (ValidPanel(pnl) and LocalPlayer() and IsValid(pnl.ply)) then return end
+ if not (GetGlobalBool("ttt_locational_voice", false) and (not pnl.ply:IsSpec()) and (pnl.ply != LocalPlayer())) then return end
+ if LocalPlayer():IsActiveTraitor() && pnl.ply:IsActiveTraitor() then return end
+
+ local d = LocalPlayer():GetPos():Distance(pnl.ply:GetPos())
pnl:SetAlpha(math.max(-0.1 * d + 255, 15))
end
@@ -455,6 +457,12 @@ function GM:PlayerStartVoice( ply )
local pnl = g_VoicePanelList:Add("VoiceNotify")
pnl:Setup(ply)
pnl:Dock(TOP)
+
+ local oldThink = pnl.Think
+ pnl.Think = function( self )
+ oldThink( self )
+ VoiceNotifyThink( self )
+ end
local shade = Color(0, 0, 0, 150)
pnl.Paint = function(s, w, h)
@@ -463,11 +471,6 @@ function GM:PlayerStartVoice( ply )
draw.RoundedBox(4, 1, 1, w-2, h-2, shade)
end
- if GetGlobalBool("ttt_locational_voice", false) and (not ply:IsSpec()) and (ply != client) then
- pnl.Player = ply
- pnl.Think = VoiceNotifyThink
- end
-
if client:IsActiveTraitor() then
if ply == client then
if not client.traitor_gvoice then
@@ -476,9 +479,6 @@ function GM:PlayerStartVoice( ply )
elseif ply:IsActiveTraitor() then
if not ply.traitor_gvoice then
pnl.Color = Color(200, 20, 20, 255)
-
- -- unhook locational fade think
- pnl.Think = nil
end
end
end

0 comments on commit a604ec0

Please sign in to comment.