I’m trying to figure out the best way of drawing an element to my hud like the default darkrp playerinfo hud (the one that is above a player). I found a 3d2d function snippet that allows me to use draw funcs above a head but there are a few issues I have ran into with this.
First off, is the correct way to go about drawing a player info hud? Is there a better way of doing it?
The first screenshot is self explanatory, how could I make it so that players can’t see their own info, but still can see other players info.
For the second screenshot I am trying to add the blur effect like the rest of the hud to this as well.
local function DrawBlurRect(x, y, w, h, amount, heavyness) surface.SetDrawColor(255, 255, 255, 255) surface.SetMaterial(blur) for i = 1, heavyness do blur:SetFloat("$blur", (i / 3) * (amount or 6)) blur:Recompute() render.UpdateScreenEffectTexture() render.SetScissorRect(x, y, x + w, y + h, true) surface.DrawTexturedRect(0 * -1, 0 * -1, ScrW(), ScrH()) render.SetScissorRect(0, 0, 0, 0, false) end end function plyinfohud() local ply = LocalPlayer() local HeadPos, HeadAng = ply:GetBonePosition( ply:LookupBone("ValveBiped.Bip01_Head1") ) local Pos = HeadPos + Vector(0, 5, 40) local Ang = EyeAngles() Ang:RotateAroundAxis( Ang:Right(), 90 ) Ang:RotateAroundAxis( Ang:Up(), -90 ) cam.Start3D2D(Pos, Ang, 0.1) -- draw.RoundedBox(0,-100,-200,200,100,Color(255,255,255)) DrawBlurRect( -100, -100, 200, 100, 5, 4 ) draw.RoundedBox( 10, -100, 100, 200, 100, Color( 0, 0, 0, 175 ) ) draw.SimpleText(ply:Nick(),"plyhud",0,150,Color(255,255,255),1,1) cam.End3D2D() end hook.Add("PostDrawOpaqueRenderables", "plyinfo", plyinfohud)
Could the reason it is not drawing possibly have something to do with the 2d/3d rendering stuff? I can’t see why because draw.box is 2d, but the 3d2d cam allows it to work. Thoughts??
Thanks in advance for any help!