Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.15 KB | None | 0 0
  1. /*---------------------------------------------------------------------------
  2. HUD ConVars
  3. ---------------------------------------------------------------------------*/
  4. local ConVars = {}
  5. local HUDWidth
  6. local HUDHeight
  7.  
  8. local Color = Color
  9. local cvars = cvars
  10. local draw = draw
  11. local GetConVar = GetConVar
  12. local Lerp = Lerp
  13. local localplayer
  14. local pairs = pairs
  15. local SortedPairs = SortedPairs
  16. local string = string
  17. local surface = surface
  18. local table = table
  19. local tostring = tostring
  20.  
  21. CreateClientConVar("weaponhud", 0, true, false)
  22.  
  23. local function ReloadConVars()
  24. ConVars = {
  25. background = {0,0,0,100},
  26. Healthbackground = {0,0,0,200},
  27. Healthforeground = {140,0,0,180},
  28. HealthText = {255,255,255,200},
  29. Job1 = {0,0,150,200},
  30. Job2 = {0,0,0,255},
  31. salary1 = {0,150,0,200},
  32. salary2 = {0,0,0,255}
  33. }
  34.  
  35. for name, Colour in pairs(ConVars) do
  36. ConVars[name] = {}
  37. for num, rgb in SortedPairs(Colour) do
  38. local CVar = GetConVar(name..num) or CreateClientConVar(name..num, rgb, true, false)
  39. table.insert(ConVars[name], CVar:GetInt())
  40.  
  41. if not cvars.GetConVarCallbacks(name..num, false) then
  42. cvars.AddChangeCallback(name..num, function() timer.Simple(0,ReloadConVars) end)
  43. end
  44. end
  45. ConVars[name] = Color(unpack(ConVars[name]))
  46. end
  47.  
  48.  
  49. HUDWidth = (GetConVar("HudW") or CreateClientConVar("HudW", 240, true, false)):GetInt()
  50. HUDHeight = (GetConVar("HudH") or CreateClientConVar("HudH", 115, true, false)):GetInt()
  51.  
  52. if not cvars.GetConVarCallbacks("HudW", false) and not cvars.GetConVarCallbacks("HudH", false) then
  53. cvars.AddChangeCallback("HudW", function() timer.Simple(0,ReloadConVars) end)
  54. cvars.AddChangeCallback("HudH", function() timer.Simple(0,ReloadConVars) end)
  55. end
  56. end
  57. ReloadConVars()
  58.  
  59. local function formatNumber(n)
  60. if not n then return "" end
  61. if n >= 1e14 then return tostring(n) end
  62. n = tostring(n)
  63. local sep = sep or ","
  64. local dp = string.find(n, "%.") or #n+1
  65. for i=dp-4, 1, -3 do
  66. n = n:sub(1, i) .. sep .. n:sub(i+1)
  67. end
  68. return n
  69. end
  70.  
  71.  
  72. local Scrw, Scrh, RelativeX, RelativeY
  73. /*---------------------------------------------------------------------------
  74. HUD Seperate Elements
  75. ---------------------------------------------------------------------------*/
  76. surface.CreateFont( "Info", {
  77. font = "Bebas Neue",
  78. size = 25,
  79. weight = 800,
  80. antialias = true
  81. })
  82.  
  83. surface.CreateFont( "Info2", {
  84. font = "Bebas Neue",
  85. size = 21,
  86. weight = 800,
  87. antialias = true
  88. })
  89.  
  90. surface.CreateFont( "Ammo", {
  91. font = "Bebas",
  92. size = 65,
  93. weight = 800,
  94. antialias = true
  95. })
  96.  
  97. local function DrawLine(x,y,w,h,x2,y2,w2,h2)
  98. surface.SetDrawColor(0,0,0,255)
  99. surface.DrawLine(x,ScrH()-y,w,ScrH()-h)
  100. surface.SetDrawColor(61,61,61,255)
  101. surface.DrawLine(x2,ScrH()-y2,w2,ScrH()-h2)
  102. end
  103.  
  104. local function DrawPlayerModel()
  105.  
  106. draw.RoundedBox(0,20,ScrH()-25,150,15,Color(38,38,38,255)) -- Bottom
  107. draw.RoundedBox(0,20,ScrH()-160,15,135,Color(38,38,38,255)) -- Left
  108. draw.RoundedBox(0,155,ScrH()-160,15,135,Color(38,38,38,255)) -- Right
  109. draw.RoundedBox(0,20,ScrH()-175,150,15,Color(38,38,38,255)) -- Top
  110.  
  111. draw.RoundedBox(0,35,ScrH()-160,120,135,Color(54,54,54,255))
  112.  
  113. //Inside Box
  114. // Top
  115. DrawLine(35,160,155,160,35,159,155,159)
  116.  
  117. // Bottom
  118. DrawLine(35,25,155,25,35,26,155,26)
  119.  
  120. // Right
  121. DrawLine(155,26,155,160,154,26,154,160)
  122.  
  123. // Left
  124. DrawLine(35,25,35,160,36,26,36,160)
  125.  
  126. end
  127.  
  128. hook.Add("InitPostEntity", "DrawPlayerModel", function()
  129. iconmodel = vgui.Create("DModelPanel")
  130. iconmodel:SetModel( LocalPlayer():GetModel())
  131. function iconmodel:LayoutEntity( Entity ) return end
  132. iconmodel:SetPos(35, ScrH()-145)
  133. iconmodel:SetAnimated(false)
  134. iconmodel:SetSize(120,120)
  135. iconmodel:SetCamPos( Vector( 20, -5, 65))
  136. iconmodel:SetLookAt( Vector( 0, 0, 66.5 ) )
  137.  
  138. timer.Create("RefreshAvatar", 0.1, 0, function()
  139. if LocalPlayer():GetModel() ~= iconmodel.Entity:GetModel() then
  140. iconmodel:Remove()
  141. iconmodel = vgui.Create("DModelPanel")
  142. iconmodel:SetPos(35, ScrH()-145)
  143. iconmodel:SetModel( LocalPlayer():GetModel())
  144. function iconmodel:LayoutEntity( Entity ) return end
  145. iconmodel:SetAnimated(false)
  146. iconmodel:SetSize(120,120)
  147. iconmodel:SetCamPos( Vector( 20, -5, 65))
  148. iconmodel:SetLookAt( Vector( 0, 0, 66.5 ) )
  149. end
  150. end)
  151. end)
  152.  
  153. local hp = Material("icon16/heart.png")
  154. local ar = Material("icon16/shield.png")
  155. local csh = Material("icon16/money_dollar.png")
  156. local sal = Material("icon16/money.png")
  157. local jo = Material("icon16/user.png")
  158. local hun = Material("icon16/pill.png")
  159.  
  160. local function DrawInfo()
  161.  
  162. local ply = LocalPlayer()
  163. local health,armor = ply:Health(),ply:Armor()
  164. local money = formatNumber(ply:getDarkRPVar("money") or 0)
  165. local salary = (ply:getDarkRPVar("salary") or 0)
  166. local job = ply:getDarkRPVar("job") or ""
  167. local hunger = math.Round(ply:getDarkRPVar( "Energy" ) or 0)
  168.  
  169. y = 29
  170. if armor > 0 then
  171. y = 0
  172. end
  173.  
  174. draw.RoundedBox(0,170,ScrH()-35,25,25,Color(38,38,38,255)) // HP Icon
  175. draw.RoundedBox(0,195,ScrH()-35,225,25,Color(54,54,54,255)) // Health background
  176. if health > 0 then
  177. draw.RoundedBox(0,200,ScrH()-30,math.Clamp(health,0,100)*2.15,15,Color(255,50,50,220)) // Health Bar
  178. end
  179. draw.DrawText(health.." %","Info2",210,ScrH()-32,color_white,TEXT_ALIGN_LEFT)
  180. // Health Front
  181. DrawLine(195,11,195,35,196,11,196,35)
  182. surface.SetMaterial(hp)
  183. surface.SetDrawColor(255,255,255,255)
  184. surface.DrawTexturedRect(175,ScrH()-30,16,16)
  185.  
  186. if armor > 0 then
  187. draw.RoundedBox(0,170,ScrH()-63,25,25,Color(38,38,38,255)) // AR Icon
  188. draw.RoundedBox(0,195,ScrH()-63,225,25,Color(54,54,54,255)) // Armor background
  189. draw.RoundedBox(0,200,ScrH()-58,math.Clamp(armor,0,100)*2.15,15,Color(0,100,250,220)) // Health Bar
  190. draw.DrawText(armor.." %","Info2",210,ScrH()-60,color_white,TEXT_ALIGN_LEFT)
  191.  
  192. // Armor Front
  193. DrawLine(195,11,195,35,196,11,196,35)
  194. surface.SetMaterial(ar)
  195. surface.SetDrawColor(255,255,255,255)
  196. surface.DrawTexturedRect(175,ScrH()-58,16,16)
  197. end
  198.  
  199. draw.RoundedBox(0,170,ScrH()-91+y,25,25,Color(38,38,38,255)) // CS Icon
  200. draw.RoundedBox(0,195,ScrH()-91+y,225,25,Color(54,54,54,255)) // Cash background
  201. draw.DrawText("Wallet: $"..money,"Info",200,ScrH()-90+y,color_white,TEXT_ALIGN_LEFT)
  202.  
  203. // Cash Front
  204. DrawLine(195,11,195,35,196,11,196,35)
  205. surface.SetMaterial(csh)
  206. surface.SetDrawColor(255,255,255,255)
  207. surface.DrawTexturedRect(175,ScrH()-87+y,16,16)
  208.  
  209. draw.RoundedBox(0,170,ScrH()-119+y,25,25,Color(38,38,38,255)) // Sal Icon
  210. draw.RoundedBox(0,195,ScrH()-119+y,225,25,Color(54,54,54,255)) // Sal background
  211. draw.DrawText("Sallary: $"..salary,"Info",200,ScrH()-117+y,color_white,TEXT_ALIGN_LEFT)
  212.  
  213. // Salary Front
  214. DrawLine(195,11,195,35,196,11,196,35)
  215. surface.SetMaterial(sal)
  216. surface.SetDrawColor(255,255,255,255)
  217. surface.DrawTexturedRect(175,ScrH()-114+y,16,16)
  218.  
  219. draw.RoundedBox(0,170,ScrH()-147+y,25,25,Color(38,38,38,255)) // Job Icon
  220. draw.RoundedBox(0,195,ScrH()-147+y,225,25,Color(54,54,54,255)) // Job background
  221. draw.DrawText("Job: "..job,"Info",200,ScrH()-145+y,color_white,TEXT_ALIGN_LEFT)
  222.  
  223. // Job Front
  224. DrawLine(195,11,195,35,196,11,196,35)
  225. surface.SetMaterial(jo)
  226. surface.SetDrawColor(255,255,255,255)
  227. surface.DrawTexturedRect(175,ScrH()-142+y,16,16)
  228.  
  229. if hunger > 0 then
  230. draw.RoundedBox(0,170,ScrH()-175+y,25,25,Color(38,38,38,255)) // Hunger Icon
  231. draw.RoundedBox(0,195,ScrH()-175+y,225,25,Color(54,54,54,255)) // Hunger background
  232. draw.RoundedBox(0,200,ScrH()-170+y,math.Clamp(hunger,0,100)*2.15,15,Color(250,200,0,220)) // Hunger Bar
  233. draw.DrawText(hunger.." %","Info2",210,ScrH()-172,color_white,TEXT_ALIGN_LEFT)
  234. // Hunger Front
  235. DrawLine(195,11,195,35,196,11,196,35)
  236. surface.SetMaterial(hun)
  237. surface.SetDrawColor(255,255,255,255)
  238. surface.DrawTexturedRect(175,ScrH()-170+y,16,16)
  239. end
  240.  
  241. end
  242.  
  243. local function DrawLine2(x,y,w,h,x2,y2,w2,h2)
  244. surface.SetDrawColor(0,0,0,255)
  245. surface.DrawLine(ScrW()-x,ScrH()-y,ScrW()-w,ScrH()-h)
  246. surface.SetDrawColor(61,61,61,255)
  247. surface.DrawLine(ScrW()-x2,ScrH()-y2,ScrW()-w2,ScrH()-h2)
  248. end
  249.  
  250. local function DrawAmmo()
  251. local ply = LocalPlayer()
  252.  
  253. if !IsValid(ply:GetActiveWeapon()) then return end
  254. if (ply:GetActiveWeapon():Clip1() == NULL or ply:GetActiveWeapon() == "Camera") then return end
  255. local mag_left = LocalPlayer():GetActiveWeapon():Clip1()
  256. local mag_extra = LocalPlayer():GetAmmoCount(ply:GetActiveWeapon():GetPrimaryAmmoType()) // Current Ammunition outside the mag
  257.  
  258. if (ply:GetActiveWeapon():GetClass() == "weapon_physcannon") then
  259. return false
  260. elseif mag_left == -1 then
  261. return false
  262. elseif mag_extra >= 0 then
  263. draw.RoundedBox(0,ScrW()-300,ScrH()-90,220,80,Color(38,38,38,255)) // Background
  264. draw.RoundedBox(0,ScrW()-290,ScrH()-80,95,60,Color(54,54,54,255)) // Mag Left
  265. draw.DrawText(mag_left,"Ammo",ScrW()-240,ScrH()-85,color_white,TEXT_ALIGN_CENTER)
  266.  
  267. // Left
  268. DrawLine2(290,80,290,20,289,80,289,20)
  269.  
  270. // Right
  271. DrawLine2(195,80,195,20,196,80,196,20)
  272.  
  273. // Top
  274. DrawLine2(290,80,195,80,288,79,195,79)
  275.  
  276. // Bottom
  277. DrawLine2(290,20,195,20,288,21,195,21)
  278.  
  279. draw.RoundedBox(0,ScrW()-185,ScrH()-80,95,60,Color(54,54,54,255)) // Mag Extra
  280. draw.DrawText(mag_extra,"Ammo",ScrW()-135,ScrH()-85,color_white,TEXT_ALIGN_CENTER)
  281.  
  282. // Left
  283. DrawLine2(185,80,185,20,184,80,184,20)
  284.  
  285. // Right
  286. DrawLine2(90,80,90,20,91,80,91,20)
  287.  
  288. // Top
  289. DrawLine2(185,80,90,80,183,79,90,79)
  290.  
  291. // Bottom
  292. DrawLine2(185,20,90,20,183,21,90,21)
  293. end
  294. end
  295.  
  296. local wanted = Material("icon16/star.png")
  297. local Page = Material("icon16/page_white_text.png")
  298. CreateConVar("DarkRP_LockDown", 0, {FCVAR_REPLICATED, FCVAR_SERVER_CAN_EXECUTE})
  299.  
  300. local function DrawInportantInfo()
  301.  
  302. // Wanted
  303. if LocalPlayer():isWanted() then
  304. color = Color( math.sin( CurTime() * 2 ) * 255,math.sin( CurTime() * 2 ) * 255,math.sin( CurTime() * 2 ) * 255 )
  305. else
  306. color = color_black
  307. end
  308.  
  309. for i=1,5 do
  310. surface.SetMaterial(wanted)
  311. surface.SetDrawColor(color)
  312. surface.DrawTexturedRect(38+(40*i/2),ScrH()-154,14,14)
  313. end
  314.  
  315. // Gun Licence
  316. if LocalPlayer():getDarkRPVar("HasGunlicense") then
  317. color = color_white
  318.  
  319. else
  320. color = color_black
  321. end
  322.  
  323. surface.SetMaterial(Page)
  324. surface.SetDrawColor(color)
  325. surface.DrawTexturedRect(38, ScrH() - 155, 16, 16)
  326.  
  327. // LockDown
  328. if util.tobool(GetConVarNumber("DarkRP_LockDown")) then
  329. draw.RoundedBox(0,ScrW()/2-275,0,550,30,Color(38,38,38,math.sin( CurTime() * 2 ) * 255))
  330. draw.RoundedBox(0,ScrW()/2-265,5,530,20,Color(54,54,54,math.sin( CurTime() * 2 ) * 255))
  331. local cin = (math.sin(CurTime()) + 1) / 2
  332. local chatBoxSize = math.floor(ScrH() / 4)
  333. draw.DrawText(DarkRP.getPhrase("lockdown_started"), "ScoreboardSubtitle", ScrW()/2,5, Color(255,cin * 255,cin * 255,math.sin( CurTime() * 2 ) * 255), TEXT_ALIGN_CENTER)
  334. end
  335.  
  336. end
  337.  
  338. local function Agenda()
  339. local shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_Agenda")
  340. if shouldDraw == false then return end
  341. local ply = LocalPlayer()
  342.  
  343. local agenda = ply:getAgendaTable()
  344. if not agenda then return end
  345. draw.RoundedBox(0, 10, 10, 460, 110, Color(54,54,54,255))
  346. draw.RoundedBox(0, 12, 12, 456, 20, Color(38,38,38,255))
  347.  
  348. surface.SetDrawColor(0,0,0,255)
  349. surface.DrawLine(10,30,470,30)
  350. surface.SetDrawColor(61,61,61,255)
  351. surface.DrawLine(10,30,470,30)
  352.  
  353. draw.DrawText(agenda.Title, "DarkRPHUD1", 20, 12, color_white)
  354.  
  355. draw.RoundedBox(10, 10, 10, 460, 110, Color(0, 0, 0, 155))
  356. draw.RoundedBox(10, 12, 12, 456, 106, Color(51, 58, 51,100))
  357. draw.RoundedBox(10, 12, 12, 456, 20, Color(0, 0, 70, 100))
  358.  
  359. local text = ply:getDarkRPVar("agenda") or ""
  360.  
  361. text = text:gsub("//", "\n"):gsub("\\n", "\n")
  362. text = DarkRP.textWrap(text, "DarkRPHUD1", 440)
  363. draw.DrawText(text, "DarkRPHUD1", 20, 12, color_white)
  364. end
  365.  
  366. local function Agenda()
  367. local shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_Agenda")
  368. if shouldDraw == false then return end
  369. local DrawAgenda, AgendaManager = DarkRPAgendas[localplayer:Team()], localplayer:Team()
  370. if not DrawAgenda then
  371. for k,v in pairs(DarkRPAgendas) do
  372. if table.HasValue(v.Listeners or {}, localplayer:Team()) then
  373. DrawAgenda, AgendaManager = DarkRPAgendas[k], k
  374. break
  375. end
  376. end
  377. end
  378. if DrawAgenda then
  379. draw.RoundedBox(0, 10, 10, 460, 110, Color(54,54,54,255))
  380. draw.RoundedBox(0, 12, 12, 456, 20, Color(38,38,38,255))
  381.  
  382. surface.SetDrawColor(0,0,0,255)
  383. surface.DrawLine(10,30,470,30)
  384. surface.SetDrawColor(61,61,61,255)
  385. surface.DrawLine(10,30,470,30)
  386.  
  387. draw.DrawText(DrawAgenda.Title, "DarkRPHUD1", 20, 12, color_white)
  388.  
  389.  
  390. local AgendaText = {}
  391. for k,v in pairs(team.GetPlayers(AgendaManager)) do
  392. if not v.DarkRPVars then continue end
  393. table.insert(AgendaText, v:getDarkRPVar("agenda"))
  394. end
  395.  
  396. local text = table.concat(AgendaText, "\n")
  397. text = text:gsub("//", "\n"):gsub("\\n", "\n")
  398. text = DarkRP.textWrap(text, "DarkRPHUD1", 440)
  399. draw.DrawText(text, "DarkRPHUD1", 30, 35, Color(255,255,255,255),0)
  400. end
  401. end
  402.  
  403. local VoiceChatTexture = surface.GetTextureID("voice/icntlk_pl")
  404. local function DrawVoiceChat()
  405. if localplayer.DRPIsTalking then
  406. local chbxX, chboxY = chat.GetChatBoxPos()
  407.  
  408. local Rotating = math.sin(CurTime()*3)
  409. local backwards = 0
  410. if Rotating < 0 then
  411. Rotating = 1-(1+Rotating)
  412. backwards = 180
  413. end
  414. surface.SetTexture(VoiceChatTexture)
  415. surface.SetDrawColor(ConVars.Healthforeground)
  416. surface.DrawTexturedRectRotated(ScrW() - 100, chboxY, Rotating*96, 96, backwards)
  417. end
  418. end
  419.  
  420. local Arrested = function() end
  421.  
  422. usermessage.Hook("GotArrested", function(msg)
  423. local StartArrested = CurTime()
  424. local ArrestedUntil = msg:ReadFloat()
  425.  
  426. Arrested = function()
  427. if CurTime() - StartArrested <= ArrestedUntil and localplayer:getDarkRPVar("Arrested") then
  428. draw.DrawText(DarkRP.getPhrase("youre_arrested", math.ceil(ArrestedUntil - (CurTime() - StartArrested))), "DarkRPHUD1", ScrW()/2, ScrH() - ScrH()/12, Color(255,255,255,255), 1)
  429. elseif not localplayer:getDarkRPVar("Arrested") then
  430. Arrested = function() end
  431. end
  432. end
  433. end)
  434.  
  435. local AdminTell = function() end
  436.  
  437. usermessage.Hook("AdminTell", function(msg)
  438. timer.Destroy("DarkRP_AdminTell")
  439. local Message = msg:ReadString()
  440.  
  441. AdminTell = function()
  442. draw.RoundedBox(4, 10, 10, ScrW() - 20, 100, Color(0, 0, 0, 200))
  443. draw.DrawText(DarkRP.getPhrase("listen_up"), "GModToolName", ScrW() / 2 + 10, 10, Color(255, 255, 255, 255), 1)
  444. draw.DrawText(Message, "ChatFont", ScrW() / 2 + 10, 80, Color(200, 30, 30, 255), 1)
  445. end
  446.  
  447. timer.Create("DarkRP_AdminTell", 10, 1, function()
  448. AdminTell = function() end
  449. end)
  450. end)
  451.  
  452. /*---------------------------------------------------------------------------
  453. Drawing the HUD elements such as Health etc.
  454. ---------------------------------------------------------------------------*/
  455. local function DrawHUD()
  456. localplayer = localplayer and IsValid(localplayer) and localplayer or LocalPlayer()
  457. if not IsValid(localplayer) then return end
  458.  
  459. Scrw, Scrh = ScrW(), ScrH()
  460. RelativeX, RelativeY = 0, Scrh
  461.  
  462. DrawInfo()
  463. DrawAmmo()
  464. DrawPlayerModel()
  465. DrawInportantInfo()
  466.  
  467. Agenda()
  468. DrawVoiceChat()
  469.  
  470. Arrested()
  471. AdminTell()
  472. end
  473.  
  474. /*---------------------------------------------------------------------------
  475. Entity HUDPaint things -- ZONE DU PROBLEME
  476. ---------------------------------------------------------------------------*/
  477. local function DrawPlayerInfo(ply)
  478. local pos = ply:EyePos()
  479.  
  480. pos.z = pos.z + 10 -- The position we want is a bit above the position of the eyes
  481. pos = pos:ToScreen()
  482. pos.y = pos.y - 50 -- Move the text up a few pixels to compensate for the height of the text
  483.  
  484. if GAMEMODE.Config.showname then
  485. draw.RoundedBox(0, pos.x-125, pos.y, 250, 72, Color(38,38,38,255))
  486. draw.RoundedBox(0, pos.x-122.5, pos.y + 2.5, 245, 20, Color(54,54,54,255)) // First
  487. draw.RoundedBox(0, pos.x-122.5, pos.y + 25.5, 245, 20, Color(54,54,54,255)) // Secondsa
  488. draw.RoundedBox(0, pos.x-122.5, pos.y + 48.5, 245, 20, Color(54,54,54,255)) // Third
  489.  
  490. draw.DrawText(ply:Nick().." / "..ply:GetNWString("usergroup"), "DarkRPHUD2", pos.x + 1, pos.y + 3, Color(0, 0, 0, 255),1)
  491. draw.DrawText(ply:Nick().." / "..ply:GetNWString("usergroup"), "DarkRPHUD2", pos.x, pos.y + 2, team.GetColor(ply:Team()), 1)
  492. draw.DrawText(DarkRP.getPhrase("health", ply:Health()), "DarkRPHUD2", pos.x + 1, pos.y + 25, Color(0, 0, 0, 255), 1)
  493. draw.DrawText(DarkRP.getPhrase("health", ply:Health()), "DarkRPHUD2", pos.x, pos.y + 25, Color(255,255,255,200), 1)
  494. end
  495.  
  496. if GAMEMODE.Config.showjob then
  497. local teamname = team.GetName(ply:Team())
  498. draw.DrawText(ply:getDarkRPVar("job") or teamname, "DarkRPHUD2", pos.x + 1, pos.y + 48, Color(0, 0, 0, 255), 1)
  499. draw.DrawText(ply:getDarkRPVar("job") or teamname, "DarkRPHUD2", pos.x, pos.y + 48, Color(255, 255, 255, 200), 1)
  500. end
  501.  
  502. if ply:getDarkRPVar("HasGunlicense") then
  503. surface.SetMaterial(Page)
  504. surface.SetDrawColor(255,255,255,255)
  505. surface.DrawTexturedRect(pos.x-120, pos.y + 50, 16, 16)
  506. end
  507.  
  508. // Wanted
  509. if ply:isWanted() then
  510. color = Color( math.sin( CurTime() * 2 ) * 255,math.sin( CurTime() * 2 ) * 255,math.sin( CurTime() * 2 ) * 255 )
  511. for i=1,5 do
  512. surface.SetMaterial(wanted)
  513. surface.SetDrawColor(color)
  514. surface.DrawTexturedRect(pos.x-65+(40*i/2), pos.y-15,14,14)
  515. end
  516. end
  517.  
  518. end
  519.  
  520.  
  521. /*---------------------------------------------------------------------------
  522. The Entity display: draw HUD information about entities
  523. ---------------------------------------------------------------------------*/
  524. local function DrawEntityDisplay()
  525. local shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_EntityDisplay")
  526. if shouldDraw == false then return end
  527.  
  528. local shootPos = localplayer:GetShootPos()
  529. local aimVec = localplayer:GetAimVector()
  530.  
  531. for k, ply in pairs(player.GetAll()) do
  532. if not ply:Alive() then continue end
  533. local hisPos = ply:GetShootPos()
  534.  
  535. if GAMEMODE.Config.globalshow and ply ~= localplayer then
  536. DrawPlayerInfo(ply)
  537. -- Draw when you're (almost) looking at him
  538. elseif not GAMEMODE.Config.globalshow and hisPos:Distance(shootPos) < 300 then
  539. local pos = hisPos - shootPos
  540. local unitPos = pos:GetNormalized()
  541. if unitPos:Dot(aimVec) > 0.95 then
  542. local trace = util.QuickTrace(shootPos, pos, localplayer)
  543. if trace.Hit and trace.Entity ~= ply then return end
  544. DrawPlayerInfo(ply)
  545. end
  546. end
  547. end
  548.  
  549. local tr = localplayer:GetEyeTrace()
  550.  
  551. if IsValid(tr.Entity) and tr.Entity:isKeysOwnable() and tr.Entity:GetPos():Distance(localplayer:GetPos()) < 200 then
  552. tr.Entity:drawOwnableInfo()
  553. end
  554. end
  555.  
  556. /*---------------------------------------------------------------------------
  557. Drawing death notices
  558. ---------------------------------------------------------------------------*/
  559. function GM:DrawDeathNotice(x, y)
  560. if not GAMEMODE.Config.showdeaths then return end
  561. self.BaseClass:DrawDeathNotice(x, y)
  562. end
  563.  
  564. /*---------------------------------------------------------------------------
  565. Display notifications
  566. ---------------------------------------------------------------------------*/
  567. local function DisplayNotify(msg)
  568. local txt = msg:ReadString()
  569. GAMEMODE:AddNotify(txt, msg:ReadShort(), msg:ReadLong())
  570. surface.PlaySound("buttons/lightswitch2.wav")
  571.  
  572. -- Log to client console
  573. print(txt)
  574. end
  575. usermessage.Hook("_Notify", DisplayNotify)
  576.  
  577. /*---------------------------------------------------------------------------
  578. Remove some elements from the HUD in favour of the DarkRP HUD
  579. ---------------------------------------------------------------------------*/
  580. function GM:HUDShouldDraw(name)
  581. if name == "CHudHealth" or
  582. name == "CHudBattery" or
  583. name == "CHudSuitPower" or
  584. name == "CHudAmmo" or
  585. name == "CHudSecondaryAmmo" or
  586. (HelpToggled and name == "CHudChat") then
  587. return false
  588. else
  589. return true
  590. end
  591. end
  592.  
  593. /*---------------------------------------------------------------------------
  594. Disable players' names popping up when looking at them
  595. ---------------------------------------------------------------------------*/
  596. function GM:HUDDrawTargetID()
  597. return false
  598. end
  599.  
  600. /*---------------------------------------------------------------------------
  601. Actual HUDPaint hook
  602. ---------------------------------------------------------------------------*/
  603. function GM:HUDPaint()
  604. DrawHUD()
  605. DrawEntityDisplay()
  606.  
  607. self.BaseClass:HUDPaint()
  608. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement