From 134ec8784fea43b959da11a85107b473d595d803 Mon Sep 17 00:00:00 2001 From: saibotk Date: Sat, 30 May 2020 15:44:44 +0200 Subject: [PATCH] Code commit --- addon.json | 16 ++++++++ lua/autorun/client/glowing_teammates.lua | 51 ++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 addon.json create mode 100644 lua/autorun/client/glowing_teammates.lua diff --git a/addon.json b/addon.json new file mode 100644 index 0000000..97f33bf --- /dev/null +++ b/addon.json @@ -0,0 +1,16 @@ +{ + "ignore": [ + ".git/*", + ".gitignore", + ".gitattributes", + "README.md", + "LICENSE", + "out.gma" + ], + "tags": [ + "fun" + ], + "title": "TTT-Glowing-Teammates", + "type": "tool", + "workshopid": 1137493106 +} diff --git a/lua/autorun/client/glowing_teammates.lua b/lua/autorun/client/glowing_teammates.lua new file mode 100644 index 0000000..cc7daef --- /dev/null +++ b/lua/autorun/client/glowing_teammates.lua @@ -0,0 +1,51 @@ +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 + 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 ply.IsShinigami or not ply:IsShinigami()) then + 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)