kizaru335

Hud

Jun 24th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.15 KB | None | 0 0
  1. -----------------------------------------------------
  2. local formatMoney = DarkRP.formatMoney
  3. local getPhrase = DarkRP.getPhrase
  4. local drawSTextOutlined = draw.SimpleTextOutlined
  5. local drawSText = draw.SimpleText
  6. local drawText = draw.DrawText
  7. local teamGC=team.GetColor
  8. local Color=Color
  9. local GetGlobalBool=GetGlobalBool
  10. local CurTime=CurTime
  11. local FrameTime=FrameTime
  12. local surface=surface
  13. local math=math
  14.  
  15.  
  16. hook.Add("InitPostEntity","1337InitPostAvatar",function()
  17. surface.CreateFont( "TargetIDBG", {
  18. font = "roboto",
  19. size = 22,
  20. weight = 900,
  21. antialias = true,
  22. extended = true,
  23. })
  24.  
  25. surface.CreateFont( "TargetIDBG2", {
  26. font = "roboto",
  27. size = 26,
  28. weight = 900,
  29. antialias = true,
  30. extended = true,
  31. })
  32.  
  33. surface.CreateFont( "TargetIDBG2_SuperBig", {
  34. font = "roboto",
  35. size = 106,
  36. weight = 900,
  37. extended = true,
  38. antialias = true,
  39. })
  40.  
  41. surface.CreateFont( "TargetIDMN", {
  42. font = "roboto",
  43. size = 22,
  44. weight = 900,
  45. extended = true,
  46. antialias = true,
  47. })
  48.  
  49.  
  50. local VoiceChatTexture = surface.GetTextureID("voice/icntlk_pl")
  51. local Page = Material("icon64/tool.png")
  52. local grad2 = surface.GetTextureID('gui/gradient_down')
  53. local sw,sh = ScrW(),ScrH()
  54. local localplayer = LocalPlayer()
  55.  
  56. local avat = vgui.Create('AvatarImage')
  57. avat:SetPlayer(localplayer,64)
  58. avat:SetSize(50,50)
  59. avat:SetPos(5,sh-55)
  60.  
  61. local Arrested = function() end
  62. usermessage.Hook("GotArrested", function(msg)
  63. local StartArrested = CurTime()
  64. local ArrestedUntil = msg:ReadFloat()
  65.  
  66. Arrested = function()
  67. if CurTime() - StartArrested <= ArrestedUntil and localplayer:getDarkRPVar("Arrested") then
  68. drawSText(getPhrase("youre_arrested", math.ceil(ArrestedUntil - (CurTime() - StartArrested))), "TargetIDBG2", sw/2, sh - sh/12, Color(255,255,255), 1)
  69. elseif not localplayer:getDarkRPVar("Arrested") then
  70. Arrested = function() end
  71. end
  72. end
  73. end)
  74.  
  75. local money=0
  76. function GAMEMODE:HUDPaint()
  77. local mhel = localplayer:GetMaxHealth()
  78.  
  79. local h = localplayer:Health()
  80. local a = localplayer:Armor()
  81. local g = localplayer:getDarkRPVar("Energy")
  82. local m = localplayer:getDarkRPVar("money")
  83.  
  84. if h<0 then h=0 end
  85.  
  86.  
  87. if money!=m then
  88. local progress = 0
  89. local stat = math.abs(m-money) or 0
  90. local change = vgui.Create("DPanel")
  91. change:SetSize(250,25)
  92. change:SetPos(490,sh-30)
  93.  
  94. local color = money<m and Color(0,255,0) or Color(255,0,0)
  95. change.Paint = function(self,w,h)
  96. drawSTextOutlined(formatMoney(stat),"TargetIDBG2",0,h/2,color,TEXT_ALIGN_LEFT,TEXT_ALIGN_CENTER,1,Color(0,0,0))
  97. end
  98.  
  99. change.Think = function()
  100. progress=progress+FrameTime()
  101. if progress>1 then change:Remove() end
  102. change:SetPos(490,sh-30-progress*80)
  103. change:SetAlpha(255*(1-progress))
  104. end
  105.  
  106. money=m
  107. end
  108.  
  109. surface.SetDrawColor(Color(0,0,0,200))
  110. surface.DrawRect(60,sh-30,210,25)
  111. surface.DrawRect(275,sh-30,210,25)
  112.  
  113. surface.SetDrawColor(Color(200,141,0))
  114. surface.DrawRect(276,sh-29,208*g/100,23)
  115. surface.SetDrawColor(Color(255,0,0))
  116. surface.DrawRect(61,sh-29,208*math.Clamp(h/mhel,0,1),23)
  117.  
  118. drawSTextOutlined(math.Round(g).."%","TargetIDMN",380,sh-30+25/2,Color(255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,Color(0,0,0,150))
  119. drawSTextOutlined(h.."%","TargetIDMN",160,sh-30+25/2,Color(255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,Color(0,0,0,150))
  120.  
  121. if a>0 then
  122. surface.SetDrawColor(Color(0,0,0,200))
  123. surface.DrawRect(60,sh-5,210,5)
  124. surface.SetDrawColor(Color(0,0,255))
  125. surface.DrawRect(61,sh-6,208*math.Clamp(a/100,0,1),5)
  126. end
  127.  
  128. drawSTextOutlined(localplayer:getDarkRPVar("job").." | "..formatMoney(localplayer:getDarkRPVar("salary")),"TargetIDMN",60,sh-45,teamGC(localplayer:Team()),TEXT_ALIGN_LEFT,TEXT_ALIGN_CENTER,1,Color(0,0,0,150))
  129. drawSTextOutlined(formatMoney(money),"TargetIDBG2",490,sh-30+25/2,Color(255,255,255),TEXT_ALIGN_LEFT,TEXT_ALIGN_CENTER,1,Color(0,0,0,150))
  130.  
  131. if localplayer:getDarkRPVar("HasGunlicense") then
  132. surface.SetMaterial(Page)
  133. surface.SetDrawColor(Color(255,255,255))
  134. surface.DrawTexturedRect(14,sh-90,32,32)
  135. end
  136.  
  137. local agenda = localplayer:getAgendaTable()
  138. if agenda then
  139. local text = localplayer:getDarkRPVar("agenda")
  140. if text then
  141. surface.SetDrawColor(Color(40,40,40,220))
  142. surface.DrawRect( 10, 30, 460, 90 )
  143. surface.SetDrawColor(Color(80,80,80,220))
  144. surface.DrawRect( 10, 10, 460, 20)
  145. drawSText(agenda.Title, "DarkRPHUD1", 240, 12, Color(255,255,255),TEXT_ALIGN_CENTER)
  146. text = text:gsub("//", "\n"):gsub("\\n", "\n")
  147. text = DarkRP.textWrap(text, "DarkRPHUD1", 440)
  148. drawText(text, "DarkRPHUD1", 20, 35, Color(255,255,255), 0)
  149. end
  150. end
  151.  
  152. if localplayer.DRPIsTalking then
  153. local Rotating = math.sin(CurTime()*3)
  154. local backwards = 0
  155. if Rotating < 0 then
  156. Rotating = 1-(1+Rotating)
  157. backwards = 180
  158. end
  159. surface.SetTexture(VoiceChatTexture)
  160. surface.SetDrawColor(Color(255,0,0))
  161. surface.DrawTexturedRectRotated(sw - 100, 100--[[sh/2]], Rotating*96, 96, backwards)
  162. end
  163.  
  164. if GetGlobalBool("DarkRP_LockDown") then
  165. local sin = (math.sin(CurTime()) + 1) / 2
  166. surface.SetTexture(grad2)
  167. surface.SetDrawColor(0,0,0,255)
  168. surface.DrawTexturedRect(0,0,sw,40)
  169. drawSText(getPhrase("lockdown_started"), "TargetIDBG", sw/2, 10, Color(sin * 255, 0, 255 - (sin * 255), 255), TEXT_ALIGN_CENTER)
  170. end
  171.  
  172. if g==0 then
  173. local sin = (math.sin(CurTime()) + 1) / 2
  174. drawSText("Голодание", "TargetIDBG2_SuperBig",sw/2,sh-200, Color(sin * 255, 0, 255 - (sin * 255), 255), TEXT_ALIGN_CENTER)
  175. end
  176.  
  177. Arrested()
  178. self.BaseClass:HUDPaint()
  179. end
  180.  
  181.  
  182. hook.Remove("InitPostEntity","1337InitPostAvatar")
  183. end)
  184.  
  185. usermessage.Hook("_Notify",function(msg)
  186. GAMEMODE:AddNotify(msg:ReadString(), msg:ReadShort(), msg:ReadLong())
  187. surface.PlaySound("buttons/lightswitch2.wav")
  188. end)
  189.  
  190. function GM:HUDDrawTargetID()
  191. return false
  192. end
  193.  
  194. function GM:HUDShouldDraw(name)
  195. if name == "CHudHealth" or
  196. name == "CHudBattery" or
  197. name == "CHudSuitPower"
  198. then
  199. return false
  200. else
  201. return true
  202. end
  203. end
Advertisement
Add Comment
Please, Sign In to add comment