Hello guys, please look at my hud code:
local hide = {
CHudHealth = true,
CHudBattery = true,
CHudAmmo = true,
CHudSecondaryAmmo = true,
}
hook.Add( "HUDShouldDraw", "HideHUD", function( name )
if ( hide[ name ] ) then return false end
end )
hook.Add( "HUDPaint", "DrawMyHud", function( )
net.Receive( "Round_Status", function(len)
RoundStatus=net.ReadInt(4)
end)
net.Receive( "Send_Countdown", function(len)
Countdown=net.ReadInt(8)
end)
local BgHudC = 40
local BgHudT = 220
local HudC = 60
local HudT = 200
local health = LocalPlayer():Health()
local armor = LocalPlayer():Armor()
local weapon = LocalPlayer():GetActiveWeapon()
local maxhealth = 200
local maxarmor = 100
local AvatarSize = 64
local AvatarBgSize = 0
//Stats
local HpBarW = 200
local HpBarH = 36
local HpBarBgW = 0
local HpBarBgH = 0
local ArBarW = 100
local ArBarH = 22
local ArBarBgW = 0
local ArBarBgH = 0
//Weapon
local AmBarW = 200
local AmBarH = 36
local AmBarBgW = 0
local AmBarBgH = 0
local ReBarW = 100
local ReBarH = 22
local ReBarBgW = 0
local ReBarBgH = 0
local Border = 2
HpBarBgW=HpBarW+(2*Border)
HpBarBgH=HpBarH+(2*Border)
ArBarBgW=ArBarW+(2*Border)
ArBarBgH=ArBarH+(2*Border)
AmBarBgW=AmBarW+(2*Border)
AmBarBgH=AmBarH+(2*Border)
ReBarBgW=ReBarW+(2*Border)
ReBarBgH=ReBarH+(2*Border)
AvatarBgSize=AvatarSize+(2*Border)
local versionL = 220
local versionH = 29
local status = " "
draw.SimpleText( team.GetName( LocalPlayer():Team() ), "Tahoma 25",ScrW()/2, ScrH() * 0.92,Color(255,255,255),1,1 )
local AvatarSize = 64
draw.RoundedBox(4,(ScrW()/2)-((AvatarBgSize)/2), ScrH()-(AvatarBgSize+Border), AvatarBgSize, AvatarBgSize, Color(BgHudC,BgHudC,BgHudC,BgHudT))
local Avatar = vgui.Create( "AvatarImage", Panel )
Avatar:SetSize( AvatarSize, AvatarSize )
Avatar:SetPos( (ScrW()/2)-(AvatarSize/2), ScrH()-(AvatarSize+(2*Border)) )
Avatar:SetPlayer( LocalPlayer(), AvatarSize )
if(RoundStatus == 0)then
if(team.NumPlayers( 3 )==1)then
status = "Waiting for " .. 2-team.NumPlayers( 3 ) .. " more players!"
elseif(team.NumPlayers( 3 )==0)then
status = "Waiting for " .. 2-team.NumPlayers( 3 ) .. " more players!"
end
end
if(RoundStatus == 1)then
status = Countdown .. " sec until Starts"
end
if(RoundStatus == 2)then
if(ClientDead == 1)then
status = team.TotalDeaths( 1 ) .. " dead."
timer.Create( "ClientStatusTimer", 4, 1, function()
ClientDead = 0
end)
end
end
draw.SimpleText( status, "Tahoma 40",ScrW() *0.5, ScrH() *0.1,Color(255,255,255),1,1 )
if(LocalPlayer():Team()==1)then
if health > 0 then
draw.RoundedBox(4,(ScrW()/2)-(HpBarBgW+(AvatarBgSize/2)+Border)-4, ScrH()-(HpBarBgH+Border), HpBarBgW+4, HpBarBgH,Color(BgHudC,BgHudC,BgHudC,BgHudT))
draw.RoundedBox(4,(ScrW()/2)-(HpBarW+(AvatarBgSize/2)+(2*Border))-4, ScrH()-(HpBarH+(2*Border)), HpBarW+4, HpBarH,Color(HudC,HudC,HudC,HudT))
draw.RoundedBox(4,(ScrW()/2)-(HpBarW+(AvatarBgSize/2)+(2*Border))-4, ScrH()-(HpBarH+(2*Border)), health*(HpBarW/maxhealth)+4, HpBarH, Color( (health-maxhealth)*-(255/maxhealth), health*(255/maxhealth), 0 ))
draw.SimpleText(health.. "/" .. maxhealth .. " Health","Tahoma 25",(ScrW()/2)-((HpBarW/2)+(AvatarBgSize/2)+(2*Border)), ScrH()-((HpBarH/2)+(2*Border)), Color( 255,255,255 ), 1, 1)
draw.RoundedBox(4,(ScrW()/2)-(ArBarBgW+(AvatarBgSize/2)+Border)-4, ScrH()-(ArBarBgH+HpBarBgH+(2*Border)), ArBarBgW+4, ArBarBgH, Color(BgHudC,BgHudC,BgHudC,BgHudT))
draw.RoundedBox(4,(ScrW()/2)-(ArBarW+(AvatarBgSize/2)+(2*Border))-4, ScrH()-(ArBarBgH+HpBarBgH+(1*Border)), ArBarW+4, ArBarH,Color(HudC,HudC,HudC,HudT))
draw.RoundedBox(4,(ScrW()/2)-(ArBarW+(AvatarBgSize/2)+(2*Border))-4, ScrH()-(ArBarBgH+HpBarBgH+(1*Border)), armor*(ArBarW/maxarmor)+4, ArBarH, Color((armor-100)*-(255/maxarmor),(armor-100)*-(255/maxarmor),255))
draw.SimpleText(armor .. "/100 Armor","Tahoma 16",(ScrW()/2)-((ArBarW/2)+(AvatarBgSize/2)+(2*Border)), ScrH()-((ArBarBgH/2)+HpBarBgH+(2*Border)),Color(255,255,255),1,1)
end
end
//Spectator View
if(LocalPlayer():Team()==2)then
draw.RoundedBox( 0, 0, 0, ScrW(), 60, Color(0,0,0,240) )
draw.RoundedBox( 0, 0, ScrH()-60, ScrW(), 60, Color(0,0,0,240) )
draw.SimpleText("Spectating","Tahoma 25", ScrW()*0.5, 44,Color(255,255,255),1,1)
end
end)
console says
cl_hud.lua:97: attempt to concatenate global ‘Countdown’ (a nil value)
ingame:
240fps at start
after 10 sec
60fps
after 30sec
30fps
goes down to 20 fps