Efficient way to draw name' s above players.

What is the most efficient way to draw people’ s name’ s above their head with 3d2d ?

I do not need code although it will be handy but just pseudocode will also suffice.

I would say do it in a PostDrawOpaqueRenderables hook, looping through all the players and drawing the text.

[editline]12:39PM[/editline]

Something like this?

[lua]local col = Color(255, 0, 0);
hook.Add(“PostDrawOpaqueRenderables”, “Text”, function()
local lpos = LocalPlayer():GetPos();
for _, ply in ipairs(player.GetAll()) do
if ply ~= LocalPlayer() then
local ppos = ply:GetPos() + Vector(0, 0, 78);
cam.Start3D2D(ppos, (ppos-lpos):Angle(), 2)
draw.SimpleText(ply:Nick(), “ScoreboardText”, 0, 0, col, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
cam.End3D2D();
end
end
end);[/lua]

Untested.

Almost exactly the same as the code I slapped together, thanks for this :smiley:

Almost:
http://img404.imageshack.us/img404/2927/gmconstruct0224.th.jpg

You just need to rotate the the angle to fix that, like I said, it was untested.

Yeah i fixed it. heres the final code:
[lua]
hook.Add(“PostDrawOpaqueRenderables”, “Text”, function()
local lpos = LocalPlayer():GetPos();
for _, ply in ipairs(player.GetAll()) do
if ply ~= LocalPlayer() then
local ppos = ply:GetPos() + Vector(0, 0, 78);
cam.Start3D2D(ppos, (ppos-lpos):Angle() + Angle(90,-90,90), 0.7)
draw.SimpleText(ply:Nick(), “ScoreboardText”, 0, 0, team.GetColor(ply:Team()), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
cam.End3D2D();
end
end
end);[/lua]

Thanks, how did you test it, with a camera ?

I just took out the if so it would draw it on me, then i viewed meself in a camera :c00lbert:

I expected another effect, how would I draw the text above the head facing toward the player when the player is in the view ?