Hide text above head if player view is obscured

So, here is a thing. It can be a dot/wanted star or drawn 3d text above player head. How can it be hided for a viewer, if another player is behind a wall, or a truck, for instance?