HUDPaint Code to tell what team your on

Hey, if someone can help me that will be great.

I’m looking for someone to give me the piece of code to tell you what team your on, on the HUD

Thanks Fresh :slight_smile:


[lua]function DrawStupidTeam()
draw.WordBox(0, 20, 20, team.GetName(LocalPlayer():Team()), “HUDNumber5”, Color(0, 0, 0, 255), Color(255,0,0,255))
hook.Add(“HUDPaint”, “Damn it”, DrawStupidTeam)[/lua]
Font might be wrong thought.

function GM:HUDPaint( )

local ply = LocalPlayer()
local ob = ply:GetObserverTarget()
if ob and IsValid(ob) and ob:IsPlayer() and ob:Alive() then
	draw.AAText( ob:Nick(), "Deathrun_SmoothBig", ScrW()/2, 5, Color(255,0,0,255), TEXT_ALIGN_CENTER)
	ply = ob

local hy = ScrH() - 35

draw.RoundedBox( 1, hx, hy, hw, hh, Color( 0, 0, 0, 255 ) )
draw.RoundedBox( 1, hx + border, hy + border, hw - border*2, hh - border*2, Color( 66, 66, 66, 200 ) )
local thp = ply:Alive() and ply:Health() or 0
local hp = thp
if hp > 0 then
	hp = ( hw - border*2 ) * ( math.Clamp(ply:Health(),0,100)/100)
	draw.RoundedBox( 0, hx + border, hy + border, hp, hh - border*2, Color( 145, 255, 0, 255 ) )

draw.AAText( tostring( thp > 99999999999 and "Outnumbered" or math.max(thp, 0) ), "Deathrun_SmoothBig", hx + 5, hy - 3, Color(51,49,49,255), TEXT_ALIGN_LEFT )

surface.SetFont( "Deathrun_SmoothBig" )
local rt = string.ToMinutesSeconds(self:GetRoundTime())
local ttw, _ = surface.GetTextSize( rt )

local tw = hw/2 - 55
draw.WordBox( 4, tw - ttw/2, hy - 45, rt, "Deathrun_SmoothBig", Color( 66, 66, 66, 200 ), Color( 255, 0, 0, 255 ) )



Thats the code, now where do i put it? :stuck_out_tongue:

1st of all.
What the hell is draw.AAText ? (Is that something new added in GM13 update ?)
Why use so many locals and doing stuff like
[lua]local thp = something
local hp = thp[/lua]
Makes no sense, you could do
[lua]local hp = something[/lua] instead
And making locals for short stuff like ScrH() - 35 is plain stupid.

He only does that once. And no, it’s not “plain stupid” to have locals for that, it keeps code much more organized.

Somewhere clientside. (E.G: lua/autorun/client)

He’s using my deathrun gamemode; it’s a function I added to smooth out draw.SimpleText.
[lua]function draw.AAText( text, font, x, y, color, align )
draw.SimpleText( text, font, x+1, y+1, Color(0,0,0,math.min(color.a,120)), align )
draw.SimpleText( text, font, x+2, y+2, Color(0,0,0,math.min(color.a,50)), align )
draw.SimpleText( text, font, x, y, color, align )

and no, it’s not stupid. Why call ScrH() 5 times instead of just making a local var for it?

Yeah shadow, i’ve edited the gamemode to make it look better, would you be able to help me code in a team (for Death/Runner) Also i think that the next update it should have the Team on it. Could you code it in for me Shadow?

Also is there anyway I can use pictures instead of Drawing a box? I have all the png’s ready.

You could simply use [LUA]LocalPlayer():Team()[/LUA] To get the current Team or you could use an IF statement if you want to customize it more.
if (LocalPlayer():Team() == TEAM_RUNNER) then
elseif (LocalPlayer():Team() == TEAM_DEATH) then

And for custom images.

[LUA]local image = Material(“source/xxx.png”)


I guess everything what is here will answer to your questions.

Im pretty new to HUDPaint, could you perhaps help me code it?

Please could someone respond? I have posted the HUD above.

I already told you what to do.