I have 2 huds in my gamemode but I'm having a bit of trouble.
How would I make it so one hud appears for one team and another hud for the other team?
[CODE]--Human Hud--
local S_ANIM = 5
local S_RES = 3
local a_hpv = 100
local a_amb = 0.5
local a_amm = 0.5
local a_ams = 0.5
local a_amn = 0.5
local a_amv = 0
local a_dth = 0
local max_ammo = { invalidweapon = 1 }
local function drawBar( x, y, w, h, curve, res, c, bc )
local tab = {}
surface.SetDrawColor( bc )
for i = 1, res, S_RES do
i = math.min( i, res )
local t = {}
t.x = ScrW() * ( x + w * i / res )
t.y = ScrH() * ( y + curve * math.sin( t.x / ScrW() * math.pi ) )
tab[#tab+1] = t
if i == res then
surface.DrawLine( t.x, t.y, t.x, t.y + ScrH() * h )
else
surface.DrawLine( t.x, t.y, ScrW() * ( x + w * math.min( i + S_RES, res ) / res ), ScrH() * ( y + curve * math.sin( (ScrW() * ( x + w * math.min( i + S_RES, res ) / res )) / ScrW() * math.pi ) ) )
end
end
for i = res, 1, -S_RES do
i = math.max( i, 1 )
local t = {}
t.x = ScrW() * ( x + w * i / res )
t.y = ScrH() * ( y + curve * math.sin( t.x / ScrW() * math.pi ) + h )
tab[#tab+1] = t
if i == 1 then
surface.DrawLine( t.x, t.y, t.x, t.y - ScrH() * h )
else
surface.DrawLine( t.x, t.y, ScrW() * ( x + w * math.min( i - S_RES, res ) / res ), ScrH() * ( y + curve * math.sin( (ScrW() * ( x + w * math.min( i - S_RES, res ) / res )) / ScrW() * math.pi ) + h ) )
end
end
surface.SetDrawColor( c )
surface.DrawPoly( tab )
end
local function drawCurve( y, curve, c, bc )
for i = 0, ScrW() - 1, S_RES do
surface.SetDrawColor( c )
surface.DrawLine( i, ScrH() * ( y + curve * math.sin( i / ScrW() * math.pi ) ), i + S_RES, ScrH() * ( y + curve * math.sin( ( i + 1 ) / ScrW() * math.pi ) ) )
surface.SetDrawColor( bc )
surface.DrawLine( i, ScrH() * ( y + curve * math.sin( i / ScrW() * math.pi ) ) + 1, i + S_RES, ScrH() * ( y + curve * math.sin( ( i + 1 ) / ScrW() * math.pi ) ) + 1 )
surface.DrawLine( i, ScrH() * ( y + curve * math.sin( i / ScrW() * math.pi ) ) - 1, i + S_RES, ScrH() * ( y + curve * math.sin( ( i + 1 ) / ScrW() * math.pi ) ) - 1 )
end
end
surface.CreateFont( "PHHUD_Human_Pip", { size = ScreenScale( 14 ), weight = 500 } )
surface.CreateFont( "PHHUD_Human_PipSub", { size = ScreenScale( 12 ), weight = 500 } )
surface.CreateFont( "PHHUD_Human_Tiny", { size = ScreenScale( 4 ), weight = 300 } )
hook.Add( "HUDPaint", "PHHUDHuman", function()
-- Logic
local cme = LocalPlayer()
local chp = cme:Health()
local cwep = cme:GetActiveWeapon()
local ca1, ca2, cas = 0, 0, 0
if cwep and cwep:IsValid() then
ca1 = cwep:Clip1()
ca2 = cme:GetAmmoCount( cwep:GetSecondaryAmmoType() )
cas = cme:GetAmmoCount( cwep:GetPrimaryAmmoType() )
max_ammo[ cwep:GetClass() ] = math.max( max_ammo[ cwep:GetClass() ] or 0, ca1 )
end
local canim = math.Clamp( FrameTime() * S_ANIM, 0, 1 )
a_hpv = a_hpv + ( chp - a_hpv ) * canim
a_amv = a_amv + ( ca1 - a_amv ) * canim
a_amb = a_amb + ( ( ca1 > -1 and 0 or 0.5 ) - a_amb ) * canim
a_amm = a_amm + ( ( ( ca1 > -1 or cas > 0 ) and 0 or 0.5 ) - a_amm ) * canim
a_ams = a_ams + ( ( ( ca1 > -1 and cas > 0 ) and 0 or 0.5 ) - a_ams ) * canim
a_amn = a_amn + ( ( ( ca2 > 0 ) and 0 or 0.5 ) - a_ams ) * canim
a_dth = a_dth + ( ( cme:Alive() and 0 or 1 ) - a_dth ) * math.Clamp( FrameTime() * ( cme:Alive() and S_ANIM or S_ANIM ), 0, 1 )
-- if a_dth > 0.001 then
-- for i = 0, ScrW() - 1, S_RES do
-- surface.SetDrawColor( 255, 0, 0, a_dth * 255 )
-- surface.DrawLine( i, ScrH() / 2 + a_dth * math.sin( RealTime() * 5 + i / 30 ) * ScrH() * ( 0.4 - 0.05 * math.sin( i / ScrW() * math.pi ) ), i + S_RES, ScrH() / 2 + a_dth * math.sin( RealTime() * 5 + ( i + S_RES ) / 30 ) * ScrH() * ( 0.4 - 0.05 * math.sin( ( i + S_RES ) / ScrW() * math.pi ) ) )
-- end
-- end
drawCurve( 0.9, -0.05, Color( 255, chp > 19 and 255 or 0, chp > 19 and 255 or 0, 100 ), Color( 0, 0, 0, 50 ) )
drawCurve( 0.1, 0.05, Color( 255, chp > 19 and 255 or 0, chp > 19 and 255 or 0, 100 ), Color( 0, 0, 0, 50 ) )
-- Health
drawBar( 0.05, 0.84, 0.3, 0.05, -0.05, 100, Color( chp < 20 and math.abs( math.sin( RealTime() * 5 ) ) * 100 or 0, 0, 0, 100 ), Color( chp < 20 and math.abs( math.sin( RealTime() * 5 ) ) * 100 or 0, 0, 0 ) )
drawBar( 0.055, 0.845, 0.29 * math.min( a_hpv, 100 ) / 100, 0.04, -0.05, 100, Color( 255, 0, 0, 150 ), Color( 255, 0, 0 ) )
drawBar( 0.36, 0.84, 0.05, 0.05, -0.05, 25, Color( chp < 20 and math.abs( math.sin( RealTime() * 5 ) ) * 100 or 0, 0, 0, 100 ), Color( chp < 20 and math.abs( math.sin( RealTime() * 5 ) ) * 100 or 0, 0, 0 ) )
draw.SimpleTextOutlined( chp, "PHHUD_Human_Pip", ScrW() * 0.385, ScrH() * ( 0.84 - 0.05 * math.sin( 0.385 * math.pi ) + 0.025 ), Color( 255, 255, 255 ), 1, 1, 1, Color( 0, 0, 0 ) )
-- Ammunition
local f = math.min( a_amv / max_ammo[ cwep and cwep:IsValid() and cwep:GetClass() or "invalidweapon" ], 1 )
drawBar( 0.65 + a_amb, 0.84, 0.3, 0.05, -0.05, 100, Color( 0, 0, 0, 100 ), Color( 0, 0, 0 ) )
drawBar( 0.655 + a_amb + ( 1- f ) * 0.29, 0.845, f * 0.29, 0.04, -0.05, 100, Color( 0, 0, 255, 150 ), Color( 0, 0, 255 ) )
drawBar( 0.59 + a_amm, 0.84, 0.05 + ( a_amb - a_amm ) / 10, 0.05, -0.05, 25, Color( 0, 0, 0, 100 ), Color( 0, 0, 0 ) )
draw.SimpleTextOutlined( ca1 == -1 and cas or ca1, "PHHUD_Human_Pip", ScrW() * ( 0.615 + ( a_amb - a_amm ) / 20 + a_amm ), ScrH() * ( 0.84 - 0.05 * math.sin( ( 0.615 + ( a_amb - a_amm ) / 20 + a_amm ) * math.pi ) + 0.025 ), Color( 255, 255, 255 ), 1, 1, 1, Color( 0, 0, 0 ) )
drawBar( 0.59 + a_ams, 0.91, 0.08, 0.05, -0.05, 25, Color( 0, 0, 0, 100 ), Color( 0, 0, 0 ) )
draw.SimpleTextOutlined( cas, "PHHUD_Human_PipSub", ScrW() * ( 0.63 + a_ams ), ScrH() * ( 0.91 - 0.05 * math.sin( ( 0.615 + a_ams ) * math.pi ) + 0.025 ), Color( 255, 255, 255 ), 1, 1, 1, Color( 0, 0, 0 ) )
drawBar( 0.68 + a_amn, 0.91, 0.05, 0.05, -0.05, 25, Color( 0, 0, 0, 100 ), Color( 0, 0, 0 ) )
draw.SimpleTextOutlined( ca2, "PHHUD_Human_Pip", ScrW() * ( 0.705 + a_amn ), ScrH() * ( 0.91 - 0.05 * math.sin( ( 0.705 + a_amn ) * math.pi ) + 0.025 ), Color( 255, 255, 255 ), 1, 1, 1, Color( 0, 0, 0 ) )
-- Time
drawBar( 0.25, 0.105, 0.08, 0.05, 0.05, 25, Color( 0, 0, 0, 100 ), Color( 0, 0, 0 ) )
draw.SimpleTextOutlined( "00:00", "PHHUD_Human_PipSub", ScrW() * 0.29, ScrH() * ( 0.105 + 0.05 * math.sin( 0.29 * math.pi ) + 0.025 ), Color( 255, 255, 255 ), 1, 1, 1, Color( 0, 0, 0 ) )
-- Points
drawBar( 0.67, 0.105, 0.08, 0.05, 0.05, 25, Color( 0, 0, 0, 100 ), Color( 0, 0, 0 ) )
draw.SimpleTextOutlined( "2700", "PHHUD_Human_PipSub", ScrW() * 0.71, ScrH() * ( 0.105 + 0.05 * math.sin( 0.71 * math.pi ) + 0.025 ), Color( 255, 255, 255 ), 1, 1, 1, Color( 0, 0, 0 ) )
-- Useless Stuff
end )
--Alien Hud--
local S_ANIM = 5
local S_RES = 2
if GM:NEW_ROUND( ) then
local CURTIME == round.Time
end
if GM:GAME_OVER() then
local CURTIME == round.Break
end
local CURSCORE == pl.Points
local a_hp = 0
local am_max = { [""] = 0 }
local am_w = 0
local am_c = 0
local am_cs = 0
local a_t = 0
surface.CreateFont( "PHHUD_Alien_Main", { size = ScreenScale( 34 ), weight = 700 } )
surface.CreateFont( "PHHUD_Alien_Sub", { size = ScreenScale( 24 ), weight = 700 } )
hook.Add( "HUDPaint", "PHHUDAlien", function()
local cme = LocalPlayer()
local chp = cme:Health()
local cwep = cme:GetActiveWeapon()
local ca1, ca2, cas = 0, 0, 0
if cwep and cwep:IsValid() then
ca1 = cwep:Clip1()
ca2 = cme:GetAmmoCount( cwep:GetSecondaryAmmoType() )
cas = cme:GetAmmoCount( cwep:GetPrimaryAmmoType() )
end
-- Logic
a_hp = a_hp + ( ( chp / 3 ) - a_hp ) * math.Clamp( FrameTime() * S_ANIM, 0, 1 )
if IsValid( cwep ) then
am_max[ cwep:GetClass() or "" ] = math.max( am_max[ cwep:GetClass() or "" ] or 0, cwep:Clip1() )
am_w = am_w + ( ScrW() * 0.3 * ( ca1 > -1 and 2/3 / am_max[ cwep:GetClass() ] or 0 ) - am_w ) * math.Clamp( FrameTime() * S_ANIM, 0, 1 )
am_c = am_c + ( ( ca1 > -1 and cwep:Clip1() or 0 ) - am_c ) * math.Clamp( FrameTime() * S_ANIM * 3, 0, 1 )
am_cs = am_cs + ( cas - am_
In the draw hooks make something like [code]if LocalPlayer():Team() != 1 then return end[/code]Remember to replace 1 with your team id.
[QUOTE=Robotboy655;41616501]In the draw hooks make something like [code]if LocalPlayer():Team() != 1 then return end[/code]Remember to replace 1 with your team id.[/QUOTE]
Thank you!
Sorry, you need to Log In to post a reply to this thread.