Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.06 KB | None | 0 0
  1.  
  2. surface.CreateFont( "hud_font_24", { font = "DermaDefault", size = 24, weight = 600, bold = true, strikeout = false, outline = false, shadow = false, outline = false,})
  3. surface.CreateFont( "hud_font_18", { font = "DermaDefault", size = 18, weight = 600, bold = true, strikeout = false, outline = false, shadow = false, outline = false,})
  4. surface.CreateFont( "hud_font_14", { font = "DermaDefault", size = 14, weight = 600, bold = true, strikeout = false, outline = false, shadow = false, outline = false,})
  5.  
  6. local backgroundColor = Color(5, 181, 240, 255)
  7. local foregroundColor = Color(0,0,0,255)
  8. local hungerColor
  9. local scrw = ScrW()
  10. local scrh = ScrH()
  11. local hudW = 400
  12. local hudH = 150
  13.  
  14. local function DrawCustomHUD()
  15. --
  16. --
  17. -- some shit you don't need
  18. --
  19. --
  20. if !DermaShown then
  21. PlayerIcon = vgui.Create("DModelPanel")
  22. PlayerIcon:SetModel(LocalPlayer():GetModel())
  23. function PlayerIcon:LayoutEntity( Entity ) return end
  24. PlayerIcon:SetAnimated(False)
  25. PlayerIcon:SetPos(40 + 2, scrh - hudH - 20 + 4 + 15 + 2)
  26. PlayerIcon:SetSize(hudH - 44, hudH - 44)
  27. PlayerIcon:SetCamPos( Vector( 16, -4, 65))
  28. PlayerIcon:SetLookAt( Vector( 0, 0, 66.5 ) )
  29.  
  30.  
  31. DermaShown = true
  32.  
  33. end
  34. if IsValid(PlayerIcon) then
  35. if PlayerIcon:GetModel() == nil or PlayerIcon:GetModel() != LocalPlayer():GetModel() then
  36. PlayerIcon:SetModel(LocalPlayer():GetModel() or "models/props_junk/watermelon01.mdl")
  37. end
  38. end
  39. end
  40.  
  41.  
  42. hook.Add("HUDPaint", "DrawCustomHUD", DrawCustomHUD)
  43.  
  44.  
  45. local function drawBaseHUD()
  46.  
  47. surface.SetDrawColor(backgroundColor)
  48. surface.DrawRect(20, scrh - hudH - 20, hudW, hudH)
  49. surface.SetDrawColor(foregroundColor)
  50. surface.DrawRect(20 + 4, scrh - hudH - 20 + 4, hudW - 8, hudH - 8)
  51.  
  52. surface.SetDrawColor(color_white)
  53. surface.DrawRect(40, scrh - hudH - 20 + 4 + 15, hudH - 40, hudH - 40)
  54. surface.SetDrawColor(foregroundColor)
  55. surface.DrawRect(40 + 2, scrh - hudH - 20 + 4 + 15 + 2, hudH - 40 - 4, hudH - 40 - 4)
  56.  
  57. end
  58.  
  59. local function drawPlayerInfo()
  60.  
  61. local ply = LocalPlayer()
  62. draw.SimpleText("Name: " .. ply:Name(), "hud_font_18", hudH + 10, scrh - hudH + 10, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
  63. draw.SimpleText("Credits: " .. DarkRP.formatMoney(ply:getDarkRPVar("money")), "hud_font_18", hudH + 10, scrh - hudH + 30, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
  64. draw.SimpleText("Job: " .. team.GetName(ply:Team()), "hud_font_18", hudH + 10, scrh - hudH + 50, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
  65.  
  66. end
  67.  
  68. local function drawPlayerStats()
  69.  
  70. local ply = LocalPlayer()
  71. if ply:getDarkRPVar("xp") then
  72. local xp = ply:getDarkRPVar("xp")
  73. local maxXP = (((10+(((ply:getDarkRPVar('level') or 1)*((ply:getDarkRPVar('level') or 1)+1)*90))))*LevelSystemConfiguration.XPMult)
  74. local level = ply:getDarkRPVar("level")
  75. surface.SetDrawColor(backgroundColor)
  76. surface.DrawRect(20, scrh - hudH - hudH / 3 - 25, hudW, hudH / 3)
  77. surface.SetDrawColor(foregroundColor)
  78. surface.DrawRect(20 + 4, scrh - hudH - hudH / 3 - 25 + 4, hudW - 8, hudH / 3 - 8)
  79.  
  80. --XP:
  81. draw.SimpleText("Level " .. level .. " ".. math.Round((xp / maxXP) * 100) .." %", "hud_font_18", 20 + 4 + hudW / 2, scrh - hudH - hudH / 3 - 10, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  82. surface.SetDrawColor(100, 100, 100, 255)
  83. surface.DrawRect(20 + 4 + 5, scrh - hudH - hudH / 3.5 - hudH * .05, hudW - 8 - 10, hudH * .1)
  84. surface.SetDrawColor(255,255,255,255)
  85. surface.DrawRect(20 + 4 + 5 + 4, scrh - hudH - hudH / 3.5 - hudH * .05 + 4, (hudW - 8 - 10 - 8) * (xp / maxXP) , hudH * .1 - 8)
  86. end
  87.  
  88. --Health:
  89. surface.SetDrawColor(255,90,90,50)
  90. surface.DrawRect(hudH + 20, scrh - hudH + 70, (hudW - hudH - 20), 10)
  91. surface.SetDrawColor(255,90,90,255)
  92. surface.DrawRect(hudH + 20, scrh - hudH + 70, (hudW - hudH - 20) * (math.Clamp(ply:Health(), 0, 100) / ply:GetMaxHealth()), 10)
  93. draw.SimpleText(ply:Health() .. " HP", "hud_font_14", hudH + 20 + (hudW - hudH - 20) / 2, scrh - hudH + 70 + 5, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  94.  
  95. --Armor:
  96. surface.SetDrawColor(80, 95, 191, 50)
  97. surface.DrawRect(hudH + 20, scrh - hudH + 85, (hudW - hudH - 20) , 10)
  98. surface.SetDrawColor(80, 95, 191, 255)
  99. surface.DrawRect(hudH + 20, scrh - hudH + 85, (hudW - hudH - 20) * (math.Clamp(ply:Armor(), 0, 100) / 100) , 10)
  100. draw.SimpleText(ply:Armor() .. " Armor", "hud_font_14", hudH + 20 + (hudW - hudH - 20) / 2, scrh - hudH + 85 + 5, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  101.  
  102. --Hunger:
  103. if ply:getDarkRPVar("Energy") != nil then
  104. surface.SetDrawColor(156, 123, 70, 50)
  105. surface.DrawRect(hudH + 20, scrh - hudH + 100, (hudW - hudH - 20), 10)
  106. surface.SetDrawColor(156, 123, 70, 255)
  107. surface.DrawRect(hudH + 20, scrh - hudH + 100, (hudW - hudH - 20) * (math.Clamp(ply:getDarkRPVar("Energy"), 0, 100) / 100) , 10)
  108. draw.SimpleText(math.Round(ply:getDarkRPVar("Energy")) .. "%", "hud_font_14", hudH + 20 + (hudW - hudH - 20) / 2, scrh - hudH + 100 + 5, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  109. end
  110.  
  111. end
  112.  
  113.  
  114. hook.Add("HUDPaint", "James_HUD", function()
  115.  
  116. drawBaseHUD()
  117. drawPlayerInfo()
  118. drawPlayerStats()
  119.  
  120. end)
  121.  
  122.  
  123. local hide = {
  124. CHudHealth = true,
  125. CHudBattery = true,
  126. CHudAmmo = true,
  127. }
  128.  
  129. local hideHUDElements = {
  130. -- if you DarkRP_HUD this to true, ALL of DarkRP's HUD will be disabled. That is the health bar and stuff,
  131. -- but also the agenda, the voice chat icons, lockdown text, player arrested text and the names above players' heads
  132. ["DarkRP_HUD"] = false,
  133.  
  134. -- DarkRP_EntityDisplay is the text that is drawn above a player when you look at them.
  135. -- This also draws the information on doors and vehicles
  136. ["DarkRP_EntityDisplay"] = false,
  137.  
  138. -- DarkRP_ZombieInfo draws information about zombies for admins who use /showzombie.
  139. ["DarkRP_ZombieInfo"] = false,
  140.  
  141. -- This is the one you're most likely to replace first
  142. -- DarkRP_LocalPlayerHUD is the default HUD you see on the bottom left of the screen
  143. -- It shows your health, job, salary and wallet, but NOT hunger (if you have hungermod enabled)
  144. ["DarkRP_LocalPlayerHUD"] = false,
  145.  
  146. -- If you have hungermod enabled, you will see a hunger bar in the DarkRP_LocalPlayerHUD
  147. -- This does not get disabled with DarkRP_LocalPlayerHUD so you will need to disable DarkRP_Hungermod too
  148. ["DarkRP_Hungermod"] = true,
  149.  
  150. -- Drawing the DarkRP agenda
  151. ["DarkRP_Agenda"] = false
  152. }
  153.  
  154. -- this is the code that actually disables the drawing.
  155. hook.Add("HUDShouldDraw", "HideDefaultDarkRPHud", function(name)
  156. if hideHUDElements[name] then return false end
  157. end)
  158.  
  159. hook.Add( "HUDShouldDraw", "HideHUD", function( name )
  160. if ( hide[ name ] ) then return false end
  161.  
  162. -- Don't return anything here, it may break other addons that rely on this hook.
  163. end )
  164.  
  165. hook.Add("HUDDrawTargetID", "NoTargetID", function()
  166. return false
  167.  
  168. end)
  169.  
  170.  
  171.  
  172. local function DisplayNotify(msg)
  173. local txt = msg:ReadString()
  174. GAMEMODE:AddNotify(txt, msg:ReadShort(), msg:ReadLong())
  175. surface.PlaySound("buttons/lightswitch2.wav")
  176.  
  177. MsgC(Color(255, 20, 20, 255), "[DarkRP] ", Color(200, 200, 200, 255), txt, "\n")
  178. end
  179. usermessage.Hook("_Notify", DisplayNotify)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement