2020-05-30 15:44:44 +02:00
local tttGlowingDetective = CreateConVar ( " ttt_glowing_detective " , " 1 " , { FCVAR_SERVER_CAN_EXECUTE , FCVAR_ARCHIVE , FCVAR_NOTIFY } , " Should the detective be seen through walls? " ) : GetBool ( ) ;
local function GlowingTTT ( )
local mates = { }
local ply = LocalPlayer ( )
if ply.GetTeam then
for k , v in pairs ( player.GetAll ( ) ) do
2020-06-18 21:06:46 +02:00
if v ~= ply and v : IsActive ( ) and ply : IsSpecial ( ) and not v : IsInnocent ( ) and ( ( v : GetTeam ( ) == ply : GetTeam ( ) and not ply : GetDetective ( ) ) or ( v : GetRole ( ) == ply : GetRole ( ) ) ) and ( not TTT2 or ply : GetSubRole ( ) ~= ROLE_SHINIGAMI ) then
2020-05-30 15:44:44 +02:00
table.insert ( mates , v )
end
end
else
for k , v in pairs ( player.GetAll ( ) ) do
if v : IsActiveTraitor ( ) and v ~= ply then
table.insert ( mates , v )
elseif tttGlowingDetective and v : IsActiveDetective ( ) and v ~= ply then
table.insert ( mates , v )
end
end
end
if # mates == 0 then return end
for _ , v in pairs ( mates ) do
local clr = Color ( 255 , 0 , 0 )
if v.GetRoleTable and v : GetRoleTable ( ) . DefaultColor then
clr = v : GetRoleTable ( ) . DefaultColor
elseif v.GetRoleColor and v : GetRoleColor ( ) then
clr = v : GetRoleColor ( )
elseif v : IsTraitor ( ) then
clr = Color ( 255 , 0 , 0 )
elseif v : IsDetective ( ) then
clr = Color ( 0 , 0 , 255 )
end
if TTT2 then
outline.Add ( v , clr , OUTLINE_MODE_VISIBLE )
else
halo.Add ( { v } , clr , 0 , 0 , 3 , true , true )
end
end
end
local function CheckTTTGlow ( )
if gamemode.Get ( " terrortown " ) then
hook.Add ( " PreDrawHalos " , " AddTTTTeamGlow " , GlowingTTT )
end
end
hook.Add ( " PostGamemodeLoaded " , " LoadTTTTeamGlow " , CheckTTTGlow )