Advertisement
SlenderDaddy

Untitled

Aug 13th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.14 KB | None | 0 0
  1. local function Base()
  2.  
  3.  
  4. draw.RoundedBox(0, ScrW() / 2 - 950, ScrH () - 50 - 5, 350, 35, Color(40, 40, 40, 250))
  5.  
  6. draw.RoundedBox(0, ScrW() / 2 - 950, ScrH () - 50, 350, 25, Color(100, 100, 100, 255))
  7.  
  8. local DrawHealth = LocalPlayer():Health() or 0
  9. local EchoHealth = LocalPlayer():Health() or 0
  10.  
  11. if DrawHealth > 100 then DrawHealth = 100 end
  12. if DrawHealth < 0 then DrawHealth = 0 end
  13.  
  14. if DrawHealth != 0 then
  15. draw.RoundedBox(0, ScrW() / 2 - 950, ScrH () - 50, (350) * DrawHealth / 100, 25, Color(255,0,0, 255) )
  16.  
  17. end
  18.  
  19. draw.DrawText( "Health: "..EchoHealth, "Trebuchet24", ScrW() / 2 - 950, ScrH() / - 2 - 950, Color(0,0,0,255))
  20.  
  21. end
  22.  
  23.  
  24. local function Base1()
  25.  
  26.  
  27. draw.RoundedBox(0, ScrW() / 2 - 950, ScrH () - 75 - 5, 350, 35, Color(40, 40, 40, 250))
  28.  
  29. draw.RoundedBox(0, ScrW() / 2 - 950, ScrH () - 75, 350, 25, Color(100, 100, 100, 255))
  30.  
  31. local DrawArmor = LocalPlayer():Armor() or 0
  32. local EchoArmor = LocalPlayer():Armor() or 0
  33.  
  34. if DrawArmor > 100 then DrawArmor = 100 end
  35. if DrawArmor < 0 then DrawArmor = 0 end
  36.  
  37. if DrawArmor != 0 then
  38. draw.RoundedBox(0, ScrW() / 2 - 950, ScrH () - 75, (350) * DrawArmor / 100, 25, Color(255,0,0, 255) )
  39.  
  40. end
  41.  
  42. draw.DrawText( "Armor: "..EchoArmor, "Trebuchet24", ScrW() / 2 - 950, ScrH() / - 2 - 950, Color(0,0,0,255))
  43.  
  44. end
  45.  
  46. /*---------------------------------------------------------------------------
  47. HUD ConVars
  48. ---------------------------------------------------------------------------*/
  49. local ConVars = {}
  50. local HUDWidth
  51. local HUDHeight
  52.  
  53. local Color = Color
  54. local cvars = cvars
  55. local DarkRP = DarkRP
  56. local CurTime = CurTime
  57. local draw = draw
  58. local GetConVar = GetConVar
  59. local IsValid = IsValid
  60. local Lerp = Lerp
  61. local localplayer
  62. local math = math
  63. local pairs = pairs
  64. local ScrW, ScrH = ScrW, ScrH
  65. local SortedPairs = SortedPairs
  66. local string = string
  67. local surface = surface
  68. local table = table
  69. local timer = timer
  70. local tostring = tostring
  71.  
  72. CreateClientConVar("weaponhud", 0, true, false)
  73.  
  74. local colors = {}
  75. colors.black = Color(0, 0, 0, 255)
  76. colors.blue = Color(0, 0, 255, 255)
  77. colors.brightred = Color(200, 30, 30, 255)
  78. colors.darkred = Color(0, 0, 70, 100)
  79. colors.darkblack = Color(0, 0, 0, 200)
  80. colors.gray1 = Color(0, 0, 0, 155)
  81. colors.gray2 = Color(51, 58, 51,100)
  82. colors.red = Color(255, 0, 0, 255)
  83. colors.white = Color(255, 255, 255, 255)
  84. colors.white1 = Color(255, 255, 255, 200)
  85.  
  86. local function ReloadConVars()
  87. ConVars = {
  88. background = {0,0,0,100},
  89. Healthbackground = {0,0,0,200},
  90. Healthforeground = {140,0,0,180},
  91. HealthText = {255,255,255,200},
  92. Job1 = {0,0,150,200},
  93. Job2 = {0,0,0,255},
  94. salary1 = {0,150,0,200},
  95. salary2 = {0,0,0,255}
  96. }
  97.  
  98. for name, Colour in pairs(ConVars) do
  99. ConVars[name] = {}
  100. for num, rgb in SortedPairs(Colour) do
  101. local CVar = GetConVar(name..num) or CreateClientConVar(name..num, rgb, true, false)
  102. table.insert(ConVars[name], CVar:GetInt())
  103.  
  104. if not cvars.GetConVarCallbacks(name..num, false) then
  105. cvars.AddChangeCallback(name..num, function() timer.Simple(0,ReloadConVars) end)
  106. end
  107. end
  108. ConVars[name] = Color(unpack(ConVars[name]))
  109. end
  110.  
  111.  
  112. HUDWidth = (GetConVar("HudW") or CreateClientConVar("HudW", 240, true, false)):GetInt()
  113. HUDHeight = (GetConVar("HudH") or CreateClientConVar("HudH", 115, true, false)):GetInt()
  114.  
  115. if not cvars.GetConVarCallbacks("HudW", false) and not cvars.GetConVarCallbacks("HudH", false) then
  116. cvars.AddChangeCallback("HudW", function() timer.Simple(0,ReloadConVars) end)
  117. cvars.AddChangeCallback("HudH", function() timer.Simple(0,ReloadConVars) end)
  118. end
  119. end
  120. ReloadConVars()
  121.  
  122. local Scrw, Scrh, RelativeX, RelativeY
  123. /*---------------------------------------------------------------------------
  124. HUD Seperate Elements
  125. ---------------------------------------------------------------------------*/
  126.  
  127. local Page = Material("icon16/page_white_text.png")
  128. local function GunLicense()
  129. if localplayer:getDarkRPVar("HasGunlicense") then
  130. surface.SetMaterial(Page)
  131. surface.SetDrawColor(255, 255, 255, 255)
  132. surface.DrawTexturedRect(RelativeX + HUDWidth, ScrH() - 34, 32, 32)
  133. end
  134. end
  135.  
  136. local function Agenda()
  137. local ply = LocalPlayer()
  138.  
  139. local agenda = ply:getAgendaTable()
  140. if not agenda then return end
  141.  
  142. draw.RoundedBox(10, 10, 10, 460, 110, colors.gray1)
  143. draw.RoundedBox(10, 12, 12, 456, 106, colors.gray2)
  144. draw.RoundedBox(10, 12, 12, 456, 20, colors.darkred)
  145.  
  146. draw.DrawNonParsedText(agenda.Title, "DarkRPHUD1", 30, 12, colors.red, 0)
  147.  
  148. local text = ply:getDarkRPVar("agenda") or ""
  149.  
  150. text = text:gsub("//", "\n"):gsub("\\n", "\n")
  151. text = DarkRP.textWrap(text, "DarkRPHUD1", 440)
  152. draw.DrawNonParsedText(text, "DarkRPHUD1", 30, 35, colors.white, 0)
  153. end
  154.  
  155. local VoiceChatTexture = surface.GetTextureID("voice/icntlk_pl")
  156. local function DrawVoiceChat()
  157. if localplayer.DRPIsTalking then
  158. local chbxX, chboxY = chat.GetChatBoxPos()
  159.  
  160. local Rotating = math.sin(CurTime()*3)
  161. local backwards = 0
  162. if Rotating < 0 then
  163. Rotating = 1-(1+Rotating)
  164. backwards = 180
  165. end
  166. surface.SetTexture(VoiceChatTexture)
  167. surface.SetDrawColor(ConVars.Healthforeground)
  168. surface.DrawTexturedRectRotated(ScrW() - 100, chboxY, Rotating*96, 96, backwards)
  169. end
  170. end
  171.  
  172. CreateConVar("DarkRP_LockDown", 0, {FCVAR_REPLICATED, FCVAR_SERVER_CAN_EXECUTE})
  173. local function LockDown()
  174. local chbxX, chboxY = chat.GetChatBoxPos()
  175. if util.tobool(GetConVarNumber("DarkRP_LockDown")) then
  176. local cin = (math.sin(CurTime()) + 1) / 2
  177. local chatBoxSize = math.floor(ScrH() / 4)
  178. draw.DrawNonParsedText(DarkRP.getPhrase("lockdown_started"), "ScoreboardSubtitle", chbxX, chboxY + chatBoxSize, Color(cin * 255, 0, 255 - (cin * 255), 255), TEXT_ALIGN_LEFT)
  179. end
  180. end
  181.  
  182. local Arrested = function() end
  183.  
  184. usermessage.Hook("GotArrested", function(msg)
  185. local StartArrested = CurTime()
  186. local ArrestedUntil = msg:ReadFloat()
  187.  
  188. Arrested = function()
  189. if CurTime() - StartArrested <= ArrestedUntil and localplayer:getDarkRPVar("Arrested") then
  190. draw.DrawNonParsedText(DarkRP.getPhrase("youre_arrested", math.ceil(ArrestedUntil - (CurTime() - StartArrested))), "DarkRPHUD1", ScrW()/2, ScrH() - ScrH()/12, colors.white, 1)
  191. elseif not localplayer:getDarkRPVar("Arrested") then
  192. Arrested = function() end
  193. end
  194. end
  195. end)
  196.  
  197. local AdminTell = function() end
  198.  
  199. usermessage.Hook("AdminTell", function(msg)
  200. timer.Destroy("DarkRP_AdminTell")
  201. local Message = msg:ReadString()
  202.  
  203. AdminTell = function()
  204. draw.RoundedBox(4, 10, 10, ScrW() - 20, 100, colors.darkblack)
  205. draw.DrawNonParsedText(DarkRP.getPhrase("listen_up"), "GModToolName", ScrW() / 2 + 10, 10, colors.white, 1)
  206. draw.DrawNonParsedText(Message, "ChatFont", ScrW() / 2 + 10, 80, colors.brightred, 1)
  207. end
  208.  
  209. timer.Create("DarkRP_AdminTell", 10, 1, function()
  210. AdminTell = function() end
  211. end)
  212. end)
  213.  
  214. /*---------------------------------------------------------------------------
  215. Entity HUDPaint things
  216. ---------------------------------------------------------------------------*/
  217. local function DrawPlayerInfo(ply)
  218. local pos = ply:EyePos()
  219.  
  220. pos.z = pos.z + 10 -- The position we want is a bit above the position of the eyes
  221. pos = pos:ToScreen()
  222. pos.y = pos.y - 50 -- Move the text up a few pixels to compensate for the height of the text
  223.  
  224. if GAMEMODE.Config.showname and not ply:getDarkRPVar("wanted") then
  225. draw.DrawNonParsedText(ply:Nick(), "DarkRPHUD2", pos.x + 1, pos.y + 1, colors.black, 1)
  226. draw.DrawNonParsedText(ply:Nick(), "DarkRPHUD2", pos.x, pos.y, team.GetColor(ply:Team()), 1)
  227. end
  228.  
  229. if GAMEMODE.Config.showhealth and not ply:getDarkRPVar("wanted") then
  230. draw.DrawNonParsedText(DarkRP.getPhrase("health", ply:Health()), "DarkRPHUD2", pos.x + 1, pos.y + 21, colors.black, 1)
  231. draw.DrawNonParsedText(DarkRP.getPhrase("health", ply:Health()), "DarkRPHUD2", pos.x, pos.y + 20, colors.white1, 1)
  232. end
  233.  
  234. if GAMEMODE.Config.showjob then
  235. local teamname = team.GetName(ply:Team())
  236. draw.DrawNonParsedText(ply:getDarkRPVar("job") or teamname, "DarkRPHUD2", pos.x + 1, pos.y + 41, colors.black, 1)
  237. draw.DrawNonParsedText(ply:getDarkRPVar("job") or teamname, "DarkRPHUD2", pos.x, pos.y + 40, colors.white1, 1)
  238. end
  239.  
  240. if ply:getDarkRPVar("HasGunlicense") then
  241. surface.SetMaterial(Page)
  242. surface.SetDrawColor(255,255,255,255)
  243. surface.DrawTexturedRect(pos.x-16, pos.y + 60, 32, 32)
  244. end
  245. end
  246.  
  247. local function DrawWantedInfo(ply)
  248. if not ply:Alive() then return end
  249.  
  250. local pos = ply:EyePos()
  251. if not pos:isInSight({localplayer, ply}) then return end
  252.  
  253. pos.z = pos.z + 14
  254. pos = pos:ToScreen()
  255.  
  256. if GAMEMODE.Config.showname then
  257. draw.DrawNonParsedText(ply:Nick(), "DarkRPHUD2", pos.x + 1, pos.y + 1, colors.black, 1)
  258. draw.DrawNonParsedText(ply:Nick(), "DarkRPHUD2", pos.x, pos.y, team.GetColor(ply:Team()), 1)
  259. end
  260.  
  261. local wantedText = DarkRP.getPhrase("wanted", tostring(ply:getDarkRPVar("wantedReason")))
  262.  
  263. draw.DrawNonParsedText(wantedText, "DarkRPHUD2", pos.x, pos.y - 40, colors.white1, 1)
  264. draw.DrawNonParsedText(wantedText, "DarkRPHUD2", pos.x + 1, pos.y - 41, colors.red, 1)
  265. end
  266.  
  267. /*---------------------------------------------------------------------------
  268. The Entity display: draw HUD information about entities
  269. ---------------------------------------------------------------------------*/
  270. local function DrawEntityDisplay()
  271.  
  272. local shootPos = localplayer:GetShootPos()
  273. local aimVec = localplayer:GetAimVector()
  274.  
  275. for k, ply in pairs(players or player.GetAll()) do
  276. if not ply:Alive() or ply == localplayer then continue end
  277. local hisPos = ply:GetShootPos()
  278. if ply:getDarkRPVar("wanted") then DrawWantedInfo(ply) end
  279.  
  280. if GAMEMODE.Config.globalshow then
  281. DrawPlayerInfo(ply)
  282. -- Draw when you're (almost) looking at him
  283. elseif not GAMEMODE.Config.globalshow and hisPos:DistToSqr(shootPos) < 160000 then
  284. local pos = hisPos - shootPos
  285. local unitPos = pos:GetNormalized()
  286. if unitPos:Dot(aimVec) > 0.95 then
  287. local trace = util.QuickTrace(shootPos, pos, localplayer)
  288. if trace.Hit and trace.Entity ~= ply then return end
  289. DrawPlayerInfo(ply)
  290. end
  291. end
  292. end
  293.  
  294. local tr = localplayer:GetEyeTrace()
  295.  
  296. if IsValid(tr.Entity) and tr.Entity:isKeysOwnable() and tr.Entity:GetPos():Distance(localplayer:GetPos()) < 200 then
  297. tr.Entity:drawOwnableInfo()
  298. end
  299. end
  300.  
  301. /*---------------------------------------------------------------------------
  302. Drawing death notices
  303. ---------------------------------------------------------------------------*/
  304. function GAMEMODE:DrawDeathNotice(x, y)
  305. if not GAMEMODE.Config.showdeaths then return end
  306. self.BaseClass:DrawDeathNotice(x, y)
  307. end
  308.  
  309. /*---------------------------------------------------------------------------
  310. Display notifications
  311. ---------------------------------------------------------------------------*/
  312. local function DisplayNotify(msg)
  313. local txt = msg:ReadString()
  314. GAMEMODE:AddNotify(txt, msg:ReadShort(), msg:ReadLong())
  315. surface.PlaySound("buttons/lightswitch2.wav")
  316.  
  317. -- Log to client console
  318. print(txt)
  319. end
  320. usermessage.Hook("_Notify", DisplayNotify)
  321.  
  322. /*---------------------------------------------------------------------------
  323. Remove some elements from the HUD in favour of the DarkRP HUD
  324. ---------------------------------------------------------------------------*/
  325. function GAMEMODE:HUDShouldDraw(name)
  326. if name == "CHudHealth" or
  327. name == "CHudBattery" or
  328. name == "CHudSuitPower" or
  329. (HelpToggled and name == "CHudChat") then
  330. return false
  331. else
  332. return true
  333. end
  334. end
  335.  
  336. /*---------------------------------------------------------------------------
  337. Disable players' names popping up when looking at them
  338. ---------------------------------------------------------------------------*/
  339. function GAMEMODE:HUDDrawTargetID()
  340. return false
  341. end
  342.  
  343. /*---------------------------------------------------------------------------
  344. Actual HUDPaint hook
  345. ---------------------------------------------------------------------------*/
  346. function DrawHUD()
  347. localplayer = localplayer and IsValid(localplayer) and localplayer or LocalPlayer()
  348. if not IsValid(localplayer) then return end
  349.  
  350. -- Custom
  351. Base()
  352.  
  353. -- Default
  354. GunLicense()
  355. Agenda()
  356. DrawVoiceChat()
  357. LockDown()
  358. Arrested()
  359. AdminTell()
  360. DrawEntityDisplay()
  361.  
  362. end
  363. hook.Add("HUDPaint", "DrawHUD", DrawHUD)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement