• Draw halo on distance
    4 replies, posted
Hello! Please, help me with draw halo code. I need the halo to appear at a distance of < 500. If I in TEAM_POLICE then the CITIZEN is farther than distance 500, then the halo is not shown. hook.Add( "PreDrawHalos", "ShowHalos", function() if LocalPlayer():Team() == TEAM_CITIZEN then CIT = {} for k,v in pairs(player.GetAll()) do if v:Team() == TEAM_POLICE then table.insert(CIT, v) break end end for k,v in pairs(ents.FindInSphere(LocalPlayer():GetPos(), 100)) do halo.Add(CIT, Color(255, 255, 255), 1, 1, 1, true, true) end end end) Thank u
You have 100 in FindInSphere, change to 500
Thank u for the answer. This code call error hook.Add( "PreDrawHalos", "ShowHalos", function() if LocalPlayer():Team() == TEAM_POLICE then CIT = {} for k,v in pairs(player.GetAll()) do for k,v in pairs(ents.FindInSphere(LocalPlayer():GetPos(), 500)) do if v:Team() == TEAM_CITIZEN then table.insert(CIT, v) end halo.Add(CIT, Color(255, 255, 255), 1, 1, 1, true, true) end end end end)  attempt to call method 'Team' (a nil value)
You don't need the first loop so just do this: hook.Add( "PreDrawHalos", "ShowHalos", function() if LocalPlayer():Team() == TEAM_POLICE then CIT = {} for k, v in pairs(ents.FindInSphere(LocalPlayer():GetPos(), 500)) do if v:IsValid() and v:IsPlayer() and v:Team() == TEAM_CITIZEN then -- If the entity is valid and a player and is a citizen then table.insert(CIT, v) end halo.Add(CIT, Color(255, 255, 255), 1, 1, 1, true, true) end end end)
Thank u!
Sorry, you need to Log In to post a reply to this thread.