Advertisement
Guest User

Untitled

a guest
May 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.48 KB | None | 0 0
  1. --[[-------------------------------------------------------------------------
  2. BarHUD for DarkRP + Noob Friendly Config
  3. Developed By Derpes
  4. Contact Me: http://steamcommunity.com/id/TheDerpyFail
  5. ---------------------------------------------------------------------------]]
  6.  
  7. if(SERVER)then
  8.  
  9. --[[-------------------------------------------------------------------------
  10. SERVER CONFIGURATION
  11. ---------------------------------------------------------------------------]]
  12. --Should the user need to download fonts required? (Set to true if you don't have the 'bebasneue' font in your servers fastdl/workshop packs)
  13. --DEFAULT: true
  14. local downloadFonts = true
  15. --[[-------------------------------------------------------------------------
  16. END OF SERVER CONFIGURATION
  17. ---------------------------------------------------------------------------]]
  18.  
  19. --Downloads the required fonts to the client if downloadFonts is set to true
  20. if(downloadFonts)then
  21. resource.AddSingleFile("resource/fonts/bebasneue.ttf")
  22. end
  23.  
  24. elseif(CLIENT)then
  25.  
  26. local jobBarCol--Don't touch this!
  27.  
  28. --[[-------------------------------------------------------------------------
  29. CLIENT CONFIGURATION
  30. ---------------------------------------------------------------------------]]
  31. --Logo
  32. --Try to use 100x100 for a nice fit, you can change the size settings in the commented line within the HUDPaint hook.
  33. --If you know at least basic lua, use the wiki for the code shown there for help
  34. --DEFAULT: false
  35. local showLogo = false
  36. local logo = Material("yourpath/yourlogo.png")
  37.  
  38. --The currency to be shown within the wallet and salary information
  39. local myCurrency = "$"
  40.  
  41. --Should the job bar color be the same as the player's team color?
  42. --DEFAULT: true
  43. local jobBarTeamColor = true
  44.  
  45. --Text shown on each bar, leave a colon and space at the end of the string to keep it looking tidy.
  46. local healthText = "Health: "
  47. local armorText = "Armor: "
  48. local jobText = "Job: "
  49. local walletText = "Wallet: "
  50. local ammoText = "Ammo: "
  51. local ammoHoldText = "Holding: "
  52.  
  53. --Text Color Configuration
  54. local barTextCol = Color(255,255,255,255)--Bar statistic text color
  55. local barTextOutlineCol = Color(0,0,0,255)--Bar statistic text outline color
  56. local salaryTextCol = Color(140,220,140,255)--Color of the salary text (+$45)
  57.  
  58. --Bar/Box Color Configuration
  59. local barBaseCol = Color(30,30,30,210)--Base top bar
  60. local barBaseOutlineCol = Color(0,130,200,255)--Base top bar outline
  61. local barOutlineCol = Color(0,0,0,255)--Most outer outline for each bar
  62. local barOutline2Col = Color(70,70,70,255)--Second most outer outline for each bar
  63. local healthBarCol = Color(225,50,50,255)--Health bar foreground
  64. local healthBarBackCol = Color(70,30,30,255)--Health bar background
  65. local armorBarCol = Color(50,50,225,255)--Armor bar foreground
  66. local armorBarBackCol = Color(30,30,70,255)--Armor bar background
  67. if(jobBarTeamColor)then
  68. jobBarCol = team.GetColor(LocalPlayer():Team())--Color of the player's team, comment this out and uncomment the one below for a set color.
  69. else
  70. jobBarCol = Color(100,100,100,255)--Job bar background
  71. end
  72. local walletBarCol = Color(120,120,20,255)--Wallet bar background
  73. local ammoBarCol = Color(30,30,30,255)--Ammo bar background
  74.  
  75. --Elements that it shouldn't draw. The nasty HL2 yellow shit.
  76. --Stuff disappeared since adding this HUD? This is likely to be where and why.
  77. --true = disable it
  78. --false = show it
  79. local DerpHUDnoDraw= {
  80. CHudDeathNotice = true,
  81. CHudHealth = true,
  82. CHudBattery = true,
  83. CHudAmmo = true,
  84. CHudSecondaryAmmo = true,
  85. CHudCrosshair = true,
  86. CHudDamageIndicator = true,
  87. CHudHistoryResource = true,
  88. }
  89.  
  90. --Bar Size/Space Configuration (Shouldn't change this unless you know what you're doing)
  91. local space = ScrW()*0.04
  92. local barWidth = ScrW()*0.15
  93. local barHeight = ScrW()*0.0167
  94.  
  95. --[[-------------------------------------------------------------------------
  96. END OF CLIENT CONFIGURATION
  97. (If you don't know lua, I'd suggest to just NOT touch anything below here)
  98. ---------------------------------------------------------------------------]]
  99.  
  100. --Convar for toggling the HUD, default visible
  101. CreateClientConVar("derphud_toggle","1",false,false)
  102.  
  103. --Creating Our Fonts
  104. surface.CreateFont("barFont",{font="bebasneue",size=22,weight=500})
  105. surface.CreateFont("barFontSmall",{font="bebasneue",size=17,weight=500})
  106.  
  107. --Initialize the smooth variables so they don't return as nil
  108. local smoothHealth = 0
  109. local smoothArmor = 0
  110.  
  111. --The paint hook, all the goodies
  112. hook.Add("HUDPaint","derp_mainHUD",function()
  113.  
  114. --Check if the HUD is toggled before drawing it
  115. if (GetConVarNumber("derphud_toggle")==0)then return end
  116.  
  117. --Drawing Base
  118. draw.RoundedBox(0,0,0,ScrW(),ScrH()*0.04,barBaseCol)
  119. surface.SetDrawColor(barBaseOutlineCol)
  120. surface.DrawOutlinedRect(-2,-2,ScrW()+4,ScrH()*0.04+3)
  121.  
  122. --Drawing Logo
  123. if(showLogo)then
  124. surface.SetDrawColor(255,255,255,150)
  125. surface.SetMaterial(logo)
  126. surface.DrawTexturedRect(10,ScrH()-110,100,100)
  127. end
  128.  
  129. --Creating a variable to make the health/armor bars increase/decrease with a smooth animation
  130. smoothHealth = math.Approach(smoothHealth,math.Clamp(LocalPlayer():Health(),0,100),50*FrameTime())
  131. smoothArmor = math.Approach(smoothArmor,math.Clamp(LocalPlayer():Armor(),0,100),50*FrameTime())
  132.  
  133. --Drawing Health Information
  134. draw.RoundedBox(0,space,5,barWidth,barHeight,barOutlineCol)
  135. draw.RoundedBox(0,space+1,6,barWidth-2,barHeight-2,barOutline2Col)
  136. draw.RoundedBox(0,space+2,7,barWidth-4,barHeight-4,healthBarBackCol)
  137. local mathHealth = (barWidth-8)*(smoothHealth/100)+8
  138. draw.RoundedBox(0,space+4,9,mathHealth-8,barHeight-8,healthBarCol)
  139. draw.SimpleTextOutlined(healthText..LocalPlayer():Health() or 0,"barFont",(space+4)+(barWidth/2),20,barTextCol,1,1,1,barTextOutlineCol)
  140.  
  141. --Drawing Armor Information
  142. draw.RoundedBox(0,(space*2)+barWidth,5,barWidth,barHeight,barOutlineCol)
  143. draw.RoundedBox(0,(space*2)+barWidth+1,6,barWidth-2,barHeight-2,barOutline2Col)
  144. draw.RoundedBox(0,(space*2)+barWidth+2,7,barWidth-4,barHeight-4,armorBarBackCol)
  145. local mathArmor = (barWidth-8)*(smoothArmor/100)+8
  146. draw.RoundedBox(0,(space*2)+barWidth+4,9,mathArmor-8,barHeight-8,armorBarCol)
  147. draw.SimpleTextOutlined(armorText..LocalPlayer():Armor() or 0,"barFont",space*2+barWidth+4+(barWidth/2),20,barTextCol,1,1,1,barTextOutlineCol)
  148.  
  149. --Drawing Job Information
  150. draw.RoundedBox(0,(space*3)+(barWidth*2),5,barWidth,barHeight,barOutlineCol)
  151. draw.RoundedBox(0,(space*3)+(barWidth*2)+1,6,barWidth-2,barHeight-2,barOutline2Col)
  152. draw.RoundedBox(0,(space*3)+(barWidth*2)+2,7,barWidth-4,barHeight-4,jobBarCol)
  153. draw.SimpleTextOutlined(jobText..LocalPlayer():getDarkRPVar("job") or "","barFont",space*3+(barWidth*2)+4+(barWidth/2),20,barTextCol,1,1,1,barTextOutlineCol)
  154.  
  155. --Drawing Wallet & Sallery Information
  156. draw.RoundedBox(0,(space*4)+(barWidth*3),5,barWidth,barHeight,barOutlineCol)
  157. draw.RoundedBox(0,(space*4)+(barWidth*3)+1,6,barWidth-2,barHeight-2,barOutline2Col)
  158. draw.RoundedBox(0,(space*4)+(barWidth*3)+2,7,barWidth-4,barHeight-4,walletBarCol)
  159. draw.SimpleTextOutlined(walletText..myCurrency..LocalPlayer():getDarkRPVar("money") or 0,"barFont",space*4+(barWidth*3)+4+(barWidth/2),20,barTextCol,1,1,1,barTextOutlineCol)
  160. draw.SimpleTextOutlined("+ "..myCurrency..LocalPlayer():getDarkRPVar("salary") or 0,"barFontSmall",space*4+(barWidth*3)+4+(barWidth/1.05),20,salaryTextCol,TEXT_ALIGN_RIGHT,1,1,barTextOutlineCol)
  161.  
  162. --Drawing Ammo Information
  163. draw.RoundedBox(0,(space*5)+(barWidth*4),5,barWidth,barHeight,barOutlineCol)
  164. draw.RoundedBox(0,(space*5)+(barWidth*4)+1,6,barWidth-2,barHeight-2,barOutline2Col)
  165. draw.RoundedBox(0,(space*5)+(barWidth*4)+2,7,barWidth-4,barHeight-4,ammoBarCol)
  166. if(LocalPlayer():GetActiveWeapon():Clip1()!=-1)then
  167. draw.SimpleTextOutlined(ammoText.. LocalPlayer():GetActiveWeapon():Clip1() .. "/" .. LocalPlayer():GetAmmoCount( LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType() ),"barFont",space*5+(barWidth*4)+4+(barWidth/2),20,barTextCol,1,1,barTextOutlineCol)
  168. else
  169. if(LocalPlayer():GetActiveWeapon():GetPrintName()!=nil)then
  170. draw.SimpleTextOutlined(ammoHoldText..LocalPlayer():GetActiveWeapon():GetPrintName(),"barFont",space*5+(barWidth*4)+4+(barWidth/2),20,barTextCol,1,1,barTextOutlineCol)
  171. end
  172. end
  173.  
  174. end)
  175.  
  176. --Disabling elements configured within the clientside configuration
  177. hook.Add("HUDShouldDraw","HideHUDDefaultGmodYellowShit",function(name)
  178. if(DerpHUDnoDraw[name])then return false end
  179. end)
  180.  
  181. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement