Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.04 KB | None | 0 0
  1. surface.CreateFont( "Flood_HUD_Small", {
  2. font = "Tehoma",
  3. size = 14,
  4. weight = 500,
  5. antialias = true
  6. })
  7.  
  8. surface.CreateFont( "Flood_HUD", {
  9. font = "Tehoma",
  10. size = 16,
  11. weight = 500,
  12. antialias = true
  13. })
  14.  
  15. surface.CreateFont( "Flood_HUD_Large", {
  16. font = "Tehoma",
  17. size = 30,
  18. weight = 500,
  19. antialias = true
  20. })
  21.  
  22. surface.CreateFont( "Flood_HUD_B", {
  23. font = "Tehoma",
  24. size = 18,
  25. weight = 600,
  26. antialias = true
  27. })
  28.  
  29. -- Hud Stuff
  30. local color_grey = Color(120, 120, 120, 100)
  31. local color_black = Color(0, 0, 0, 200)
  32. local active_color = Color(24, 24, 24, 255)
  33. local outline_color = Color(0, 0, 0, 255)
  34. local x = ScrW()
  35. local y = ScrH()
  36.  
  37. -- Timer Stuff
  38. local GameState = 0
  39. local BuildTimer = -1
  40. local FloodTimer = -1
  41. local FightTimer = -1
  42. local ResetTimer = -1
  43.  
  44. local xPos = x * 0.0025
  45. local yPos = y * 0.005
  46.  
  47. -- Hud Positioning
  48. local Spacer = y * 0.006
  49. local xSize = x * 0.2
  50. local ySize = y * 0.04
  51. local bWidth = Spacer + xSize + Spacer
  52. local bHeight = Spacer + ySize + Spacer
  53.  
  54. net.Receive("RoundState", function(len)
  55. GameState = net.ReadFloat()
  56. BuildTimer = net.ReadFloat()
  57. FloodTimer = net.ReadFloat()
  58. FightTimer = net.ReadFloat()
  59. ResetTimer = net.ReadFloat()
  60. end)
  61.  
  62. function GM:HUDPaint()
  63.  
  64. if BuildTimer and FloodTimer and FightTimer and ResetTimer then
  65. if GameState == 0 then
  66. draw.RoundedBoxEx(6, xPos, y * 0.005, x * 0.175, x * 0.018, active_color, true, true, false, false)
  67.  
  68. draw.SimpleText("Waiting for players.", "Flood_HUD", x * 0.01, y * 0.01, color_white, 0, 0)
  69. draw.SimpleText("Defend your house.", "Flood_HUD", x * 0.01, y * 0.044, color_grey, 0, 0)
  70. draw.SimpleText("Get ready for the theifs.", "Flood_HUD", x * 0.01, y * 0.078, color_grey, 0, 0)
  71. draw.SimpleText("The theifs are coming!", "Flood_HUD", x * 0.01, y * 0.115, color_grey, 0, 0)
  72. draw.SimpleText("Restarting the round.", "Flood_HUD", x * 0.01, y * 0.151, color_grey, 0, 0)
  73. else
  74. draw.RoundedBoxEx(6, xPos, y * 0.005, x * 0.175, x * 0.018, color_grey, true, true, false, false)
  75. end
  76.  
  77. if GameState == 1 then
  78. draw.RoundedBox(0, xPos, yPos + (Spacer * 6), x * 0.175, x * 0.018, active_color)
  79. draw.SimpleText(BuildTimer, "Flood_HUD", x * 0.15, y * 0.044, color_white, 0, 0)
  80.  
  81. draw.SimpleText("Waiting for players.", "Flood_HUD", x * 0.01, y * 0.01, color_grey, 0, 0)
  82. draw.SimpleText("Defend your house.", "Flood_HUD", x * 0.01, y * 0.044, color_white, 0, 0)
  83. draw.SimpleText("Get ready for the theifs.", "Flood_HUD", x * 0.01, y * 0.078, color_grey, 0, 0)
  84. draw.SimpleText("The theifs are coming!", "Flood_HUD", x * 0.01, y * 0.115, color_grey, 0, 0)
  85. draw.SimpleText("Restarting the round.", "Flood_HUD", x * 0.01, y * 0.151, color_grey, 0, 0)
  86. else
  87. draw.RoundedBox(0, xPos, yPos + (Spacer * 6), x * 0.175, x * 0.018, color_grey)
  88. draw.SimpleText(BuildTimer, "Flood_HUD", x * 0.15, y * 0.044, color_grey, 0, 0)
  89. end
  90.  
  91. if GameState == 2 then
  92. draw.RoundedBox(0, xPos, yPos + (Spacer * 12), x * 0.175, x * 0.018, active_color)
  93. draw.SimpleText(FloodTimer, "Flood_HUD", x * 0.15, y * 0.078, color_white, 0, 0)
  94.  
  95. draw.SimpleText("Waiting for players.", "Flood_HUD", x * 0.01, y * 0.01, color_grey, 0, 0)
  96. draw.SimpleText("Defend your house.", "Flood_HUD", x * 0.01, y * 0.044, color_grey, 0, 0)
  97. draw.SimpleText("Get ready for the theifs.", "Flood_HUD", x * 0.01, y * 0.078, color_white, 0, 0)
  98. draw.SimpleText("The theifs are coming!", "Flood_HUD", x * 0.01, y * 0.115, color_grey, 0, 0)
  99. draw.SimpleText("Restarting the round.", "Flood_HUD", x * 0.01, y * 0.151, color_grey, 0, 0)
  100. else
  101. draw.RoundedBox(0, xPos, yPos + (Spacer * 12), x * 0.175, x * 0.018, color_grey)
  102. draw.SimpleText(FloodTimer, "Flood_HUD", x * 0.15, y * 0.078, color_grey, 0, 0)
  103. end
  104.  
  105. if GameState == 3 then
  106. draw.RoundedBox(0, xPos, yPos + (Spacer * 18), x * 0.175, x * 0.018, active_color)
  107.  
  108. draw.SimpleText(FightTimer, "Flood_HUD", x * 0.15, y * 0.115, color_white, 0, 0)
  109. draw.SimpleText("Waiting for players.", "Flood_HUD", x * 0.01, y * 0.01, color_grey, 0, 0)
  110. draw.SimpleText("Defend your house.", "Flood_HUD", x * 0.01, y * 0.044, color_grey, 0, 0)
  111. draw.SimpleText("Get ready for the theifs.", "Flood_HUD", x * 0.01, y * 0.078, color_grey, 0, 0)
  112. draw.SimpleText("The theifs are coming!", "Flood_HUD", x * 0.01, y * 0.115, color_white, 0, 0)
  113. draw.SimpleText("Restarting the round.", "Flood_HUD", x * 0.01, y * 0.151, color_grey, 0, 0)
  114. else
  115. draw.RoundedBox(0, xPos, yPos + (Spacer * 18), x * 0.175, x * 0.018, color_grey)
  116. draw.SimpleText(FightTimer, "Flood_HUD", x * 0.15, y * 0.115, color_grey, 0, 0)
  117. end
  118.  
  119. if GameState == 4 then
  120. draw.RoundedBoxEx(6, xPos, yPos + (Spacer * 24), x * 0.175, x * 0.018, active_color, false, false, true, true)
  121.  
  122. draw.SimpleText(ResetTimer, "Flood_HUD", x * 0.15, y * 0.151, color_white, 0, 0)
  123. draw.SimpleText("Waiting for players.", "Flood_HUD", x * 0.01, y * 0.01, color_grey, 0, 0)
  124. draw.SimpleText("Defend your house.", "Flood_HUD", x * 0.01, y * 0.044, color_grey, 0, 0)
  125. draw.SimpleText("Get ready for the theifs.", "Flood_HUD", x * 0.01, y * 0.078, color_grey, 0, 0)
  126. draw.SimpleText("The theifs are coming!", "Flood_HUD", x * 0.01, y * 0.115, color_grey, 0, 0)
  127. draw.SimpleText("Restarting the round.", "Flood_HUD", x * 0.01, y * 0.151, color_white, 0, 0)
  128. else
  129. draw.RoundedBoxEx(6,xPos, yPos + (Spacer * 24), x * 0.175, x * 0.018, color_grey, false, false, true, true)
  130. draw.SimpleText(ResetTimer, "Flood_HUD", x * 0.15, y * 0.151, color_grey, 0, 0)
  131. end
  132. end
  133.  
  134. -- Display Prop's Health
  135. local tr = util.TraceLine(util.GetPlayerTrace(LocalPlayer()))
  136. if tr.Entity:IsValid() and not tr.Entity:IsPlayer() then
  137. if tr.Entity:GetNWInt("CurrentPropHealth") == "" or tr.Entity:GetNWInt("CurrentPropHealth") == nil or tr.Entity:GetNWInt("CurrentPropHealth") == NULL then
  138. draw.SimpleText("Fetching Health", "Flood_HUD_Small", x * 0.5, y * 0.5 - 25, color_white, 1, 1)
  139. else
  140. draw.SimpleText("Health: " .. tr.Entity:GetNWInt("CurrentPropHealth"), "Flood_HUD_Small", x * 0.5, y * 0.5 - 25, color_white, 1, 1)
  141. end
  142. end
  143.  
  144. -- Display Player's Health and Name
  145. if tr.Entity:IsValid() and tr.Entity:IsPlayer() then
  146. draw.SimpleText("Name: " .. tr.Entity:GetName(), "Flood_HUD_Small", x * 0.5, y * 0.5 - 75, color_white, 1, 1)
  147. draw.SimpleText("Health: " .. tr.Entity:Health(), "Flood_HUD_Small", x * 0.5, y * 0.5 - 60, color_white, 1, 1)
  148. end
  149.  
  150. -- Bottom left HUD Stuff
  151. if LocalPlayer():Alive() and IsValid(LocalPlayer()) then
  152. draw.RoundedBox(6, 4, y - ySize - Spacer - (bHeight * 2), bWidth, bHeight * 2 + ySize, Color(24, 24, 24, 255))
  153.  
  154. -- Health
  155. local pHealth = LocalPlayer():Health()
  156. local pHealthClamp = math.Clamp(pHealth / 100, 0, 1)
  157. local pHealthWidth = (xSize - Spacer) * pHealthClamp
  158.  
  159. draw.RoundedBoxEx(6, Spacer * 2, y - (Spacer * 4) - (ySize * 3), Spacer + pHealthWidth, ySize, Color(128, 28, 28, 255), true, true, false, false)
  160. draw.SimpleText(math.Max(pHealth, 0).." HP","Flood_HUD_B", xSize * 0.5 + (Spacer * 2), y - (ySize * 2.5) - (Spacer * 4), color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  161.  
  162. -- Ammo
  163. if IsValid(LocalPlayer():GetActiveWeapon()) then
  164. if LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()) > 0 or LocalPlayer():GetActiveWeapon():Clip1() > 0 then
  165. local wBulletCount = (LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()) + LocalPlayer():GetActiveWeapon():Clip1()) + 1
  166. local wBulletClamp = math.Clamp(wBulletCount / 100, 0, 1)
  167. local wBulletWidth = (xSize - bWidth) * wBulletClamp
  168.  
  169. draw.RoundedBox(0, Spacer * 2, y - (ySize * 2) - (Spacer * 3), bWidth + wBulletWidth, ySize, Color(30, 105, 105, 255))
  170. draw.SimpleText(wBulletCount.." Bullets", "Flood_HUD_B", xSize * 0.5 + (Spacer * 2), y - ySize - (ySize * 0.5) - (Spacer * 3), color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  171. else
  172. draw.RoundedBox(0, Spacer * 2, y - (ySize * 2) - (Spacer * 3), xSize, ySize, Color(30, 105, 105, 255))
  173. draw.SimpleText("Doesn't Use Ammo", "Flood_HUD_B", xSize * 0.5 + (Spacer * 2), y - ySize - (ySize * 0.5) - (Spacer * 3), color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  174. end
  175. else
  176. draw.RoundedBox(0, Spacer * 2, y - (ySize * 2) - (Spacer * 3), xSize, ySize, Color(30, 105, 105, 255))
  177. draw.SimpleText("No Ammo", "Flood_HUD_B", xSize * 0.5 + (Spacer * 2), y - ySize - (ySize * 0.5) - (Spacer * 3), color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  178. end
  179.  
  180. -- Cash
  181. local pCash = LocalPlayer():GetNWInt("flood_cash") or 0
  182. local pCashClamp = math.Clamp(pCash / 5000, 0, xSize)
  183.  
  184. draw.RoundedBoxEx(6, Spacer * 2, y - ySize - (Spacer * 2), xSize, ySize, Color(63, 140, 64, 255), false, false, true, true)
  185. draw.SimpleText("$"..pCash, "Flood_HUD_B", (xSize * 0.5) + (Spacer * 2), y - (ySize * 0.5) - (Spacer * 2), WHITE, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  186. end
  187. end
  188.  
  189. function hidehud(name)
  190. for k, v in pairs{"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"} do
  191. if name == v then return false end
  192. end
  193. end
  194. hook.Add("HUDShouldDraw", "hidehud", hidehud)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement