• How to draw text on visible players?
    3 replies, posted
Quick question, how do I check whether a player is visible or not? I want to draw their name but not if they're through a wall. [CODE]for k, v in pairs (player.GetAll()) do local pos = (v:GetPos() + Vector(0, 0, 80)):ToScreen() if v:IsSuperAdmin() then draw.DrawText("[Super Admin] " .. v:Name(), "Trebuchet18", pos.x, pos.y, Color(249, 43, 43), 1) elseif v:IsAdmin() then draw.DrawText("[Admin] " .. v:Name(), "Trebuchet18", pos.x, pos.y, Color(240, 0, 255), 1) else draw.DrawText(v:Name(), "Trebuchet18", pos.x, pos.y, Color(10, 143, 171), 1) end end[/CODE] And by the way i've already tried [CODE]ToScreen().visible[/CODE] and it doesn't work, it's like completely random and just makes the names flicker.
Why dont you just use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PrePlayerDraw]GM/PrePlayerDraw[/url] It is called only when a player should be drawn
You're going to either have to use traces or util.PixelVisible. For traces, you can just trace to each corner of their bounding box until one of the traces doesn't hit anything or it hits the player, which means that you can see at least part of the player.
[QUOTE=tzahush;48246487]Why dont you just use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PrePlayerDraw]GM/PrePlayerDraw[/url] It is called only when a player should be drawn[/QUOTE] Using that hook results in some weird z-fighting issues with translucent and such.
Sorry, you need to Log In to post a reply to this thread.