Set a tag above the players head if hes Team1.

Tilte^

How can i make a code that puts some text above the players head if hes team1?

like [lua]if (pl:Team() == 1) then[/lua]
The text above head code here

How can i do this? Also i want the text to be all blue.

Thank you.

it’s [lua ] and [/ lua] like
[lua]if (pl:Team() == 1) then[/lua]

[lua]
local ply = LocalPlayer()
hook.Add(“HUDPaint”,0, function()
for k,v in pairs(player.GetAll()) do
if v:Team() == 1 then
local pos = v:GetPos():ToScreen()
draw.DrawText(v:Nick(), “ScoreboardText”, pos.x - 0, pos.y - 0, Color(125,225,55,255),1)
end
end
end)
[/lua]

Yea i know :wink: Just didten notice it.

Also i belive this would work:
[lua]
local pl = LocalPlayer()
hook.Add(“HUDPaint”,0, function()
for k,v in pairs(player.GetAll()) do
if v:Team() == 1 then
local pos = v:GetPos():ToScreen()
draw.DrawText(v:Nick(), “[VIP]”, pos.x - 0, pos.y - 0, Color(125,225,55,255),1)
end
end
end)
[/lua]
Cant see why it shuldent.

Because LocalPlayer() will return a NULL_ENTITY (but you don’t even need to use the LocalPlayer so why are you defining it?)

I was using Distance then i removed it.

That code would show the names at their feet.
[lua]
hook.Add(“HUDPaint”, “NameTags”, function()
for k,v in pairs(player.GetAll()) do
if v:Team() == 1 then
local pos = v:GetPos()
pos:Add(Vector(0, 0, 86))
pos = pos:ToScreen()
draw.DrawText(v:Nick(), “ScoreboardText”, pos.x, pos.y, Color(125,225,55,255),1)
end
end
end)
[/lua]

Well i dont want it to be at there feets or having there name. It shuld just be above there heads and saying [VIP]

Could anyone make a quick code on how to do that? Or atleast tell me how i would do it?

He just did ¬__¬

I believe the code above would show the person’s name even if they are behind a wall/hidden from view. 3D2D would be better for this.

[lua]
for _,v in pairs(player.GetAll()) do
if not(v == LocalPlayer()) then
TraceTable = {start = (LocalPlayer():GetPos() + Vector(0, 0, 64)), endpos = (v:GetPos() + Vector(0, 0, 64)), mask = MASK_OPAQUE}
Trace = util.TraceLine(TraceTable)
if not(Trace.Hit) then
Pos = (v:GetPos() + Vector(0, 0, 86)):ToScreen()
if(Pos.visible) and (v:IsUserGroup(“VIP”)) then
surface.SetFont(“DefaultSmallDropShadow”)
draw.RoundedBox(4, Pos.x - surface.GetTextSize(“VIP”)/2 - 5, Pos.y - 6, surface.GetTextSize(“VIP”) + 10, 16, Color(50, 50, 50))
draw.DrawText(“VIP”, “DefaultSmallDropShadow”, Pos.x, Pos.y - 5, Color(255, 255, 255), 1)
end
end
end

end[/lua]

Stolen almost directly from my gamemode.

“mask = 16513”

Why don’t you just use the ENUM? Makes the code so much easier to understand.