Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tracked_players = {}
- local function start_tracking(ent)
- if not ent or not ent:IsValid() or not ent:IsPlayer() then return end
- table.insert(tracked_players, ent)
- end
- local function stop_tracking(ent)
- if not ent or not ent:IsValid() or not ent:IsPlayer() then return end
- table.RemoveByValue(tracked_players, ent) -- this doesn't error if player is not found: https://wiki.facepunch.com/gmod/table.RemoveByValue
- end
- -- feed this into your callback
- local function track(attacker, path, dmginfo)
- local ent = path.Entity
- if not ent or not ent:IsValid() or not ent:IsPlayer() then return end
- timer.Simple(3, function()
- start_tracking(ent)
- end)
- end
- hook.Add("PreDrawHalos", "MySWEP.StartHaloTracking", function()
- if #tracked_players < 1 then return end
- halo.Add(tracked_players, Color(255,0,0,255), 1, 1, 2, true, true)
- end)
- hook.Add("PlayerDeath", "MySWEP.StopHaloTracking", stop_tracking)
- hook.Add("TTTEndRound", "MySWEP.StopHaloTracking", function()
- for _, ply in ipairs(player.GetAll()) do
- stop_tracking(ply)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment