Code:
surface.CreateFont('******_font', {
font = 'Verdana',
size = 15
}
)
function startsWith(str, text)
return str:find(text) == 1
end
local ******FinderVars = {
CVAR = CreateClientConVar('******_find', 0, false, false),
ENT_CLASS_COLOUR = Color(255, 255, 0),
targets = {},
material = 0,
min = 0,
max = 0
}
function autoComplete(commandName, args)
local entities = {
--sidearm
'weapon_ttt_glock',
'weapon_zm_pistol',
'weapon_zm_revolver',
--sidearm ammo
'item_ammo_pistol_ttt',
'item_ammo_357_ttt',
--prim
'weapon_zm_mac10',
'weapon_zm_shotgun',
'weapon_ttt_m16',
'weapon_zm_rifle',
--prim ammo
'item_ammo_smg1_ttt',
'item_box_buckshot_ttt',
'item_ammo_revolver_ttt',
--grenades
'weapon_ttt_smokegrenade',
'weapon_zm_molotov',
'weapon_ttt_confgrenade',
--equipment
'weapon_ttt_c4', --dropped c4
'ttt_c4', --planted c4
'ttt_health_station',
'weapon_ttt_wtester',
'weapon_ttt_knife',
'ttt_decoy',
'weapon_ttt_flaregun',
'weapon_ttt_phammer',
'weapon_ttt_push',
'ttt_radio',
'weapon_ttt_sipistol',
'weapon_ttt_teleport'
}
args = args:Trim()
args = args:lower()
for i = #entities, 1, -1 do
if (args == nil or startsWith(entities[i], args)) then
entities[i] = commandName .. ' ' .. entities[i]
else
table.remove(entities, i)
end
end
table.sort(entities)
return entities
end
concommand.Add(
'******_find_highlight',
function(ply,cmd,args)
for k, v in pairs(args) do
if (not table.HasValue(******FinderVars.targets, v)) then
table.insert(******FinderVars.targets, v)
end
end
end,
autoComplete,
'Add entities to the paint list.'
)
concommand.Add(
'******_find_clear',
function(ply,cmd,args)
for k, v in pairs(args) do
table.RemoveByValue(******FinderVars.targets, v)
end
end,
autoComplete,
'Remove entities from the paint list.'
)
concommand.Add(
'******_find_clearall',
function()
table.Empty(******FinderVars.targets)
end
)
concommand.Add(
'******_find_tell',
function()
local ent = LocalPlayer():GetEyeTrace().Entity
MsgC(ENT_CLASS_COLOUR, '******Finder >> ')
Msg( (IsValid(ent) and ent:GetClass() or 'error') .. '\n' )
end
)
cvars.AddChangeCallback('******_find', function()
if (******FinderVars.CVAR:GetBool()) then
hook.Add('HUDPaint', '******_ent_finder', function()
cam.Start3D()
render.SuppressEngineLighting(true)
for k, v in pairs(******FinderVars.targets) do
for _, e in pairs(ents.FindByClass(v)) do
if (IsValid(e) and not alivePlayer(e.Owner)) then
******FinderVars.mat = e:GetMaterial()
e:SetMaterial('models/shiny')
e:DrawModel()
e:SetMaterial(******FinderVars.mat)
******FinderVars.min, ******FinderVars.max = e:LocalToWorld(e:OBBMins()):ToScreen(), e:LocalToWorld(e:OBBMaxs()):ToScreen()
cam.Start2D()
draw.DrawText(
e:GetClass(),
'******_font',
(******FinderVars.min.x + ******FinderVars.max.x) / 2,
******FinderVars.max.y - 20,
******FinderVars.ENT_CLASS_COLOUR,
TEXT_ALIGN_CENTER
)
cam.End2D()
end
end
end
render.SuppressEngineLighting(false)
cam.End3D()
end)
else
hook.Remove('HUDPaint', '******_ent_finder')
end
end)
designed for ttt, has all the vanilla ttt ents hardcoded for autocomplete but you can use ******_find_tell to get current entity and highlight without autocomplete