"Spotting" a player/NPC

So I want to make it so in my gamemode, if you are looking at a player or NPC and hit a specific button while you have your crosshair on them, a small triangle appears on top of their head and follows them till it disappears in about 5 seconds.
And yes, this is suppose to be like the Battlefield spotting.
I really have no idea how I can make this, since I’m not a lua expert.

This is very simple to do. Just get the entity a player is looking at:

[lua]ply:GetEyeTrace().Entity[/lua]

The rest should be very simple to do.

Building off what Hyper Iguana said, it is pretty straight forward.

You’ll probably want a concommand so people can bind it to what they want ( or not use it all together ) rather than trying to make it some combination of use, sprint and flashlight.

Next, you’ll want to perform a trace with a custom mask, preferably MASK_OPAQUE and MASK_SHOT so it can travel through non-opaque objects ( like windows and fences ) that wouldn’t be hit by a bullet.

After the trace, you mark the entity - this could be sending the player a usermessage, setting a networked variable on the player, or doing it entirely clientside, and then a couple of seconds later, unset this variable.

The triangle would be a simple texture or a poly drawn above their head via the surface library.