• Problems with overhead display
    5 replies, posted
Okay, so i need to have such feature : If the person have a gun license, the white paper (from silk icons) will pop up above his head Code in the end was my previous one,it worked like this: if i had a license, on the display of another person would be written that he had it too (but he hadnt) https://files.facepunch.com/forum/upload/149560/ed660c8c-4bbc-4784-af13-4aabf88ddefe/image.png LocalPlayer():getDarkRPVar("HasGunlicense") then surface.SetDrawColor(255, 255, 255, 255) surface.SetMaterial(Material("icon16/page_white.png"))     surface.DrawTexturedRect(-9, -17, 16, 16)
local function DrawName( ply )     if ( !IsValid( ply ) ) then return end     if ( ply == LocalPlayer() ) then return end     if ( !ply:Alive() ) then return end     local Distance = LocalPlayer():GetPos():Distance( ply:GetPos() )     if ( Distance < 200 ) then     local offset = Vector(0, 0, 23)     local ang = LocalPlayer():EyeAngles()     local pos = ply:EyePos() + offset + ang:Up()          ang:RotateAroundAxis(ang:Forward(), 90)     ang:RotateAroundAxis(ang:Right(), 90)     cam.Start3D2D(pos, Angle(0, ang.y, 90), 0.25) local nick, plyTeam = ply:Nick(), ply:getDarkRPVar("job")             draw.DrawText(nick, "gbeorgHUDA2", 1, 2, Color(255,255,255), TEXT_ALIGN_CENTER) draw.DrawText(plyTeam, "gbeorgHUDA2", -1, 30, Color(31,174,233), TEXT_ALIGN_CENTER) if LocalPlayer():getDarkRPVar("HasGunlicense") then surface.SetDrawColor(255, 255, 255, 255) surface.SetMaterial(Material("icon16/page_white.png"))     surface.DrawTexturedRect(-9, -17, 16, 16) end     cam.End3D2D()     end end hook.Add( "PostPlayerDraw", "DrawName", DrawName )
local function DrawName( ply ) if ( !IsValid( ply ) ) then return end if ( ply == LocalPlayer() ) then return end if ( !ply:Alive() ) then return end local Distance = LocalPlayer():GetPos():Distance( ply:GetPos() ) if ( Distance < 200 ) then local offset = Vector(0, 0, 23) local ang = LocalPlayer():EyeAngles() local pos = ply:EyePos() + offset + ang:Up() ang:RotateAroundAxis(ang:Forward(), 90) ang:RotateAroundAxis(ang:Right(), 90) cam.Start3D2D(pos, Angle(0, ang.y, 90), 0.25) local nick, plyTeam = ply:Nick(), ply:getDarkRPVar("job") draw.DrawText(nick, "gbeorgHUDA2", 1, 2, Color(255,255,255), TEXT_ALIGN_CENTER) draw.DrawText(plyTeam, "gbeorgHUDA2", -1, 30, Color(31,174,233), TEXT_ALIGN_CENTER) if ply:getDarkRPVar("HasGunlicense") then surface.SetDrawColor(255, 255, 255, 255) surface.SetMaterial(Material("icon16/page_white.png")) surface.DrawTexturedRect(-9, -17, 16, 16) end cam.End3D2D() end end hook.Add( "PostPlayerDraw", "DrawName", DrawName )
Might not want to be calling Material() in the hook, as it just needs to be called once. And like what above said, you are using LocalPlayer() (the player viewing the text above the player's head) and not the player that's below the text I also made it a bit easier to read: local pageMat = Material("icon16/page_white.png") local function DrawName( ply )   if ( !IsValid( ply ) ) then return end   if ( ply == LocalPlayer() ) then return end   if ( !ply:Alive() ) then return end   local Distance = LocalPlayer():GetPos():Distance( ply:GetPos() )   if ( Distance < 200 ) then     local offset = Vector(0, 0, 23)     local ang = LocalPlayer():EyeAngles()     local pos = ply:EyePos() + offset + ang:Up()     ang:RotateAroundAxis(ang:Forward(), 90)     ang:RotateAroundAxis(ang:Right(), 90)          cam.Start3D2D(pos, Angle(0, ang.y, 90), 0.25)     local nick, plyTeam = ply:Nick(), ply:getDarkRPVar("job")       draw.DrawText(nick, "gbeorgHUDA2", 1, 2, Color(255,255,255), TEXT_ALIGN_CENTER)       draw.DrawText(plyTeam, "gbeorgHUDA2", -1, 30, Color(31,174,233), TEXT_ALIGN_CENTER)              if ply:getDarkRPVar("HasGunlicense") then       surface.SetDrawColor(255, 255, 255, 255)       surface.SetMaterial(pageMat)         surface.DrawTexturedRect(-9, -17, 16, 16)       end           cam.End3D2D()   end end hook.Add("PostPlayerDraw", "DrawName", DrawName)
Thank you guys!
Sorry, you need to Log In to post a reply to this thread.