Advertisement
sciaschi

CustomHud.lua

Dec 23rd, 2011
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.71 KB | None | 0 0
  1. if (SERVER) then return nil end
  2.  
  3. hud = {}
  4. hud.maxammo = {}
  5.  
  6. VERSION = .91
  7.  
  8. function hud.HUD() // loops
  9. if hudremoved then return end
  10.     local Client = LocalPlayer() // Name Clients
  11.     local Player = LocalPlayer() // Just in case
  12.     local Weapon = tostring( Client:GetActiveWeapon():GetPrintName() )  // Tostring stops the bugs
  13.     if !Client:Alive() then return end // No HUD when dead
  14.     if Weapon == "#GMOD_Camera" then return end
  15.     if !hud.maxammo[weapon] then // If Doesn't Exist
  16.         hud.maxammo[weapon] = {} // Make new
  17.         hud.maxammo[weapon].p = Client:GetActiveWeapon():Clip1() // Add Primary
  18.         hud.maxammo[weapon].s = Client:GetActiveWeapon():Clip2() // Add Secondary
  19.     end
  20.     if Client:GetActiveWeapon():Clip1() > hud.maxammo[weapon].p then
  21.         hud.maxammo[weapon].p = Client:GetActiveWeapon():Clip1()
  22.     end
  23.     if Client:GetActiveWeapon():Clip1() > hud.maxammo[weapon].s then
  24.         hud.maxammo[weapon].s = Client:GetActiveWeapon():Clip1()
  25.     end
  26.         local Health = Client:Health()
  27.         local Armor = Client:Armor()
  28.         local AmmoLeft = Client:GetActiveWeapon():Clip1()
  29.         local AmmoLeft2 = Client:GetActiveWeapon():Clip2() 
  30.         local HealthPercent = percenthp( Client:Health(), Client:GetMaxHealth() )
  31.         local AmmoPercentPrimary = percent( AmmoLeft, hud.maxammo[weapon].p )
  32.     draw.RoundedBox(0, 40 - 1, (ScrH() - 70) - 1, 200 + 2, (16) + 2, Color(255, 255, 255, 255))
  33.    draw.RoundedBox(0, 40, ScrH() - 70, 200, 16, Color(125, 125, 125, 150))
  34.         local zHealth = HealthPercent * 2
  35.     surface.SetDrawColor(255, 255, 255, 255)
  36.     surface.SetTexture(surface.GetTextureID("CGUI/HealthBig"))
  37.     surface.DrawTexturedRect(40, ScrH() - 70, zHealth, 16)
  38.     draw.RoundedBox(0, 40 - 1, (ScrH() - 54) - 1, 200 + 2, (16) + 2, Color(255, 255, 255, 255))
  39.    draw.RoundedBox(0, 40, ScrH() - 54, 200, 16, Color(125, 125, 125, 150))
  40.         local zAmmo = AmmoPercentPrimary * 2
  41.     surface.SetDrawColor(255, 255, 255, 255)
  42.     surface.SetTexture(surface.GetTextureID("CGUI/AmmoBig"))
  43.     surface.DrawTexturedRect(40, ScrH() - 54, zAmmo, 16)
  44.     draw.RoundedBox(0, 40 - 1, (ScrH() - 38) - 1, 200 + 2, (16) + 2, Color(255, 255, 255, 255))
  45.    draw.RoundedBox(0, 40, ScrH() - 38, 200, 16, Color(125, 125, 125, 150))
  46.         local zArmor = Armor * 2
  47.     surface.SetDrawColor(255, 255, 255, 255)
  48.     surface.SetTexture(surface.GetTextureID("CGUI/ArmorBig"))
  49.     surface.DrawTexturedRect(40, ScrH() - 38, 200, 16)
  50.     draw.SimpleText(""..HealthPercent.." Health ", "ScoreboardText",42,  ScrH()-72, Color(0, 0, 0, 255), 0, 0)
  51.     draw.SimpleText("Armor Unknown", "ScoreboardText",42,  ScrH()-39, Color(0, 0, 0, 255), 0, 0)
  52.     if AmmoLeft == -1 then
  53.         draw.SimpleText("Infinite Ammo", "ScoreboardText",42,  ScrH()-56, Color(0, 0, 0, 255), 0, 0)
  54.     else
  55.         draw.SimpleText(""..AmmoLeft.."/"..hud.maxammo[weapon].p.." Ammo", "ScoreboardText",40,  ScrH()-56, Color(0, 0, 0, 255), 0, 0)
  56.     end
  57. end
  58.  
  59. hook.Add( "HUDPaint", "CustomHud", hud.HUD )
  60.  
  61. function percenthp( num, max )
  62.    return (num / max) * 100 / 10 / 10
  63. end
  64.  
  65. function percent( num, max )
  66.    return (num / max) * 100
  67. end
  68.  
  69. function hud.HideHUD( name )
  70. if !hudremoved then
  71. if name == "CHudHealth" then return false end
  72. if name == "CHudBattery" then return false end
  73. if name == "CHudAmmo" then return false end
  74. if name == "CHudSecondaryAmmo" then return false end
  75. end
  76. return true
  77. end
  78.  
  79. hook.Add("HUDShouldDraw","hud.HideHUD",hud.HideHUD)
  80. hudremoved = false
  81.  
  82. function hud.remove()
  83. if hudremoved == false then
  84. hudremoved = true
  85. elseif hudremoved == true then
  86. hudremoved = false
  87. end
  88. end
  89.  
  90. concommand.Add("chud_toggle","remove",hud.remove) --So many choices
  91. // CHANGE FILE SIZE FOR OVERWRITE WARNING
  92. // CHANGE FILE SIZE FOR OVERWRITE WARNING
  93. // CHANGE FILE SIZE FOR OVERWRITE WARNING
  94. // CHANGE FILE SIZE FOR OVERWRITE WARNING
  95. // CHANGE FILE SIZE FOR OVERWRITE WARNING
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement