Advertisement
Roite

SleekHud

Oct 23rd, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.04 KB | None | 0 0
  1. /*---------------------------------------------------------------------------
  2. Which default HUD elements should be hidden?
  3. ---------------------------------------------------------------------------*/
  4.  
  5. surface.CreateFont( "namef", {
  6.  font = "Bebas Neue",
  7.  size = 24,
  8.  weight = 500,
  9.  blursize = 0,
  10.  scanlines = 0,
  11.  antialias = true
  12. } )
  13.  
  14. surface.CreateFont( "namefsmall", {
  15.  font = "Bebas Neue",
  16.  size = 16,
  17.  weight = 500,
  18.  blursize = 0,
  19.  scanlines = 0,
  20.  antialias = true
  21. } )
  22.  
  23. surface.CreateFont( "jobf", {
  24.  font = "Bebas Neue",
  25.  size = 34,
  26.  weight = 500,
  27.  blursize = 0,
  28.  scanlines = 0,
  29.  antialias = true
  30. } )
  31.  
  32. surface.CreateFont( "jobfsmall", {
  33.  font = "Bebas Neue",
  34.  size = 24,
  35.  weight = 500,
  36.  blursize = 0,
  37.  scanlines = 0,
  38.  antialias = true
  39. } )
  40.  
  41. surface.CreateFont( "jobfxsmall", {
  42.  font = "Bebas Neue",
  43.  size = 16,
  44.  weight = 500,
  45.  blursize = 0,
  46.  scanlines = 0,
  47.  antialias = true
  48. } )
  49.  
  50. surface.CreateFont( "moneyf", {
  51.  font = "Bebas Neue",
  52.  size = 48,
  53.  weight = 500,
  54.  blursize = 0,
  55.  scanlines = 0,
  56.  antialias = true
  57. } )
  58.  
  59. surface.CreateFont( "moneyfsmall", {
  60.  font = "Bebas Neue",
  61.  size = 36,
  62.  weight = 500,
  63.  blursize = 0,
  64.  scanlines = 0,
  65.  antialias = true
  66. } )
  67.  
  68. surface.CreateFont( "salaryf", {
  69.  font = "Bebas Neue",
  70.  size = 24,
  71.  weight = 500,
  72.  blursize = 0,
  73.  scanlines = 0,
  74.  antialias = true
  75. } )
  76.  
  77. surface.CreateFont( "healthf", {
  78.  font = "Bebas Neue",
  79.  size = 16,
  80.  weight = 500,
  81.  blursize = 0,
  82.  scanlines = 0,
  83.  antialias = true
  84. } )
  85.  
  86. surface.CreateFont( "healthf2", {
  87.  font = "Bebas Neue",
  88.  size = 20,
  89.  weight = 500,
  90.  blursize = 0,
  91.  scanlines = 0,
  92.  antialias = true
  93. } )
  94.  
  95. surface.CreateFont( "wantf", {
  96.  font = "Bebas Neue",
  97.  size = 36,
  98.  weight = 500,
  99.  blursize = 0,
  100.  scanlines = 0,
  101.  antialias = true
  102. } )
  103.  
  104. surface.CreateFont( "hungerf", {
  105.  font = "Bebas Neue",
  106.  size = 18,
  107.  weight = 500,
  108.  blursize = 0,
  109.  scanlines = 0,
  110.  antialias = true
  111. } )
  112.  
  113. local hideHUDElements = {
  114.    -- if you DarkRP_HUD this to true, ALL of DarkRP's HUD will be disabled. That is the health bar and stuff,
  115.    -- but also the agenda, the voice chat icons, lockdown text, player arrested text and the names above players' heads
  116.    ["DarkRP_HUD"] = false,
  117.  
  118.    -- DarkRP_EntityDisplay is the text that is drawn above a player when you look at them.
  119.    -- This also draws the information on doors and vehicles
  120.    ["DarkRP_EntityDisplay"] = false,
  121.  
  122.    -- DarkRP_ZombieInfo draws information about zombies for admins who use /showzombie.
  123.    ["DarkRP_ZombieInfo"] = false,
  124.  
  125.    -- This is the one you're most likely to replace first
  126.    -- DarkRP_LocalPlayerHUD is the default HUD you see on the bottom left of the screen
  127.    -- It shows your health, job, salary and wallet
  128.    ["DarkRP_LocalPlayerHUD"] = true,
  129.  
  130.    -- Drawing the DarkRP agenda
  131.    ["DarkRP_Agenda"] = false
  132. }
  133.  
  134. -- this is the code that actually disables the drawing.
  135. hook.Add("HUDShouldDraw", "HideDefaultDarkRPHud", function(name)
  136.    if hideHUDElements[name] then return false end
  137. end)
  138.  
  139. --if true then return end -- REMOVE THIS LINE TO ENABLE THE CUSTOM HUD BELOW
  140.  
  141. /*---------------------------------------------------------------------------
  142. The Custom HUD
  143. only draws health
  144. ---------------------------------------------------------------------------*/
  145. local Health = 0
  146.  
  147. HM = {}
  148.  
  149. HM.UsingHungerMod = true
  150.  
  151. local av
  152. local name
  153.  
  154. local oldName
  155.  
  156. local function DrawPlayerAvatar( p )
  157.    
  158.    oldName = LocalPlayer():Name()
  159.    print( oldName )
  160.    
  161.    av = vgui.Create("AvatarImage")
  162.    av:SetPos(64,ScrH() - 130)
  163.    av:SetSize(56, 56)
  164.    av:SetPlayer( p, 64 )
  165. end
  166.  
  167. local function formatNumber(n)
  168.    if not n then return "" end
  169.    if n >= 1e14 then return tostring(n) end
  170.     n = tostring(n)
  171.     local sep = sep or ","
  172.     local dp = string.find(n, "%.") or #n+1
  173.    for i=dp-4, 1, -3 do
  174.       n = n:sub(1, i) .. sep .. n:sub(i+1)
  175.     end
  176.     return n
  177. end
  178.  
  179. local function hudPaint()
  180.  
  181.    draw.RoundedBox( 4, 9, ScrH() - 143, 392, 133, Color( 0, 0, 0, 255 ) )
  182.    draw.RoundedBox( 4, 10, ScrH() - 142, 390, 132, Color( 38, 38, 38, 255 ) )
  183.    draw.RoundedBoxEx( 4, 10, ScrH() - 142, 40, 80, Color( 54, 54, 54, 255 ), true, false, false, false )
  184.    draw.RoundedBoxEx( 4, 400 - 156, ScrH() - 142, 156, 80, Color( 54, 54, 54, 255 ), false, true, false, false )
  185.    
  186.    surface.SetDrawColor( 0, 0, 0, 255 )
  187.    surface.DrawLine( 10, ScrH() - 102, 50, ScrH() - 102 )
  188.    
  189.    surface.SetDrawColor( 61, 61, 61, 255 )
  190.    surface.DrawLine( 10, ScrH() - 101, 50, ScrH() - 101 )
  191.    
  192.    surface.SetDrawColor( 4, 4, 4, 255 )
  193.    surface.DrawLine( 10, ScrH() - 62, 400, ScrH() - 62 )
  194.    
  195.    surface.SetDrawColor( 61, 61, 61, 255 )
  196.    surface.DrawLine( 10, ScrH() - 61, 400, ScrH() - 61 )
  197.    
  198.    surface.SetDrawColor( 84, 84, 84, 255 )
  199.    surface.DrawLine( 11, ScrH() - 142, 398, ScrH() - 142 )
  200.    
  201.    surface.SetDrawColor( 24, 24, 24, 255 )
  202.    surface.DrawLine( 400 - 156, ScrH() - 142, 400 - 156, ScrH() - 62 )
  203.    
  204.    surface.SetDrawColor( 24, 24, 24, 255 )
  205.    surface.DrawLine( 50, ScrH() - 142, 50, ScrH() - 62 )
  206.    
  207.    local font
  208.    
  209.    surface.SetFont( "namef" )
  210.    local PlayerName = LocalPlayer():Name()
  211.    local Width, Height = surface.GetTextSize(PlayerName)
  212.    if Width > 100 then
  213.       font = "namefsmall"
  214.    else
  215.       font = "namef"
  216.    end
  217.    
  218.    surface.SetFont( "namefsmall" )
  219.    local wh, hw = surface.GetTextSize(PlayerName)
  220.    if font == "namefsmall" and wh > 100 then
  221.       PlayerName = string.sub( LocalPlayer():Name(), 1, 18 )..".."
  222.    end
  223.    
  224.    if font == "namef" and Width < 100 then
  225.       local PlayerName = LocalPlayer():Name()
  226.    end
  227.    
  228.    draw.SimpleText( PlayerName, font, 130, ScrH() - 132, Color( 255, 255, 255 ) )
  229.    
  230.    local jfont
  231.    local jof
  232.    local eof
  233.    
  234.    surface.SetFont( "jobf" )
  235.    local PlayerJob = team.GetName(LocalPlayer():Team())
  236.    local wi, hi = surface.GetTextSize(PlayerJob)
  237.    if wi > 100 and wi < 140 then
  238.       jfont = "jobfsmall"
  239.       jof = 2
  240.    elseif wi > 140 then
  241.       jfont = "jobfxsmall"
  242.       jof = 4
  243.    else
  244.       jfont = "jobf"
  245.       jof = 0
  246.    end
  247.    
  248.    if jfont == "jobfsmall" and font == "namefsmall" then
  249.       jof = jof - 4
  250.    elseif jfont == "jobf" and font == "namefsmall" then
  251.       jof = jof - 6
  252.    elseif   jfont == "jobfxsmall" and font == "namefsmall" then
  253.       jof = jof - 8
  254.    else
  255.       jof = jof
  256.    end
  257.    draw.SimpleText( PlayerJob, jfont, 130, ScrH() - 118 + jof, Color( 220, 220, 220, 255 ) )
  258.    draw.SimpleText( "Faim: "..math.Round(LocalPlayer():getDarkRPVar( "Energy" ) or 0), "hungerf", 130, ScrH() - 88 + jof, Color( 200, 200, 200, 255 ) )
  259.    
  260.    local mfont
  261.    
  262.    surface.SetFont( "moneyf" )
  263.    local PlayerMoney = formatNumber(LocalPlayer():getDarkRPVar( "money" ))
  264.    local wl, hl = surface.GetTextSize(PlayerMoney)
  265.    
  266.    if wl > 140 then
  267.       mfont = "moneyfsmall"
  268.    else
  269.       mfont = "moneyf"
  270.    end
  271.    
  272.    draw.SimpleText( "€"..PlayerMoney, mfont, 320, ScrH() - 132, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER )
  273.    draw.SimpleText( "Salaire: €"..formatNumber(LocalPlayer():getDarkRPVar( "salary" )), "salaryf", 320, ScrH() - 96, Color( 200, 200, 200, 255 ), TEXT_ALIGN_CENTER )
  274.    
  275.    local x, y = 30, ScrH() - 20
  276.    local localplayer = LocalPlayer()
  277.    Health = math.min(100, (Health == localplayer:Health() and Health) or Lerp(0.1, Health, localplayer:Health()))
  278.  
  279.    local DrawHealth = math.Min(Health / GAMEMODE.Config.startinghealth, 1)
  280.    local Border = math.Min(6, math.pow(2, math.Round(3*DrawHealth)))
  281.    draw.RoundedBox(4, 20 + 60, y - 33, 309 - 7, 16, Color(0,0,0,200))
  282.    if LocalPlayer():Health() > 0 then
  283.       draw.RoundedBox(4, 21 + 60, y - 32, (309 - 9) * DrawHealth, 14, Color(255,40,40,180))
  284.    end
  285.  
  286.    draw.DrawText(math.Max(0, math.Round(localplayer:Health())), "healthf", 302 / 2 + 80, y - 33, Color(255,255,255,200), 1, TEXT_ALIGN_CENTER)
  287.    
  288.    local armor = LocalPlayer():Armor()
  289.    draw.RoundedBox(4, 20 + 60, ScrH() - 34, 302, 16, Color(0,0,0,200))
  290.    if armor > 0 then
  291.       draw.RoundedBox(4, 21 + 60, ScrH() - 33, armor * 3, 14, Color(40,40,255,255))
  292.    end
  293.    draw.SimpleText(armor, "healthf", 80 + 302 / 2, ScrH() - 33, Color(255,255,255,200), TEXT_ALIGN_CENTER)
  294.    
  295.    draw.SimpleText("Vie:", "healthf2", 20, ScrH() - 54, Color(255,255,255,255), TEXT_ALIGN_LEFT)
  296.    draw.SimpleText("Armure:", "healthf2", 20, ScrH() - 36, Color(255,255,255,255), TEXT_ALIGN_LEFT)
  297.    
  298.    if LocalPlayer():isWanted() then
  299.       draw.SimpleText("!", "wantf", 30, ScrH() - 98, Color( math.sin( CurTime() * 3 ) * 255, 0, 0 ), TEXT_ALIGN_CENTER)
  300.    else
  301.       draw.SimpleText("!", "wantf", 30, ScrH() - 98, Color( 0, 0, 0, 255 ), TEXT_ALIGN_CENTER)
  302.    end
  303.    
  304.    draw.SimpleText("+", "wantf", 30, ScrH() - 138, Color( 0, 0, 0, 255 ), TEXT_ALIGN_CENTER)
  305.    
  306.    if av then
  307.       return
  308.    else
  309.       DrawPlayerAvatar( LocalPlayer() )
  310.    end
  311. end
  312. hook.Add("HUDPaint", "DarkRP_Mod_HUDPaint", hudPaint)
  313.  
  314. hook.Add( "HUDShouldDraw", "Remove default", function( name )
  315.     if ( name == "CHudHealth" or name == "CHudBattery" ) then
  316.         return false
  317.     end
  318. end )
  319.  
  320. hook.Add("HUDDrawTargetID", "HMHUD", function()
  321.    return
  322. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement