pogh10

Untitled

May 25th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.54 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 CurTime = CurTime
  10. local cvars = cvars
  11. local DarkRP = DarkRP
  12. local draw = draw
  13. local GetConVar = GetConVar
  14. local hook = hook
  15. local IsValid = IsValid
  16. local Lerp = Lerp
  17. localplayer = LocalPlayer()
  18. local math = math
  19. local pairs = pairs
  20. local ScrW, ScrH = ScrW, ScrH
  21. local SortedPairs = SortedPairs
  22. local string = string
  23. local surface = surface
  24. local table = table
  25. local timer = timer
  26. local tostring = tostring
  27. local plyMeta = FindMetaTable("Player")
  28. LocalPlayer().MaxHealth = 100
  29. LocalPlayer().MaxArmor = 100
  30.  
  31.  
  32. local colors = {}
  33. colors.black = Color(0, 0, 0, 255)
  34. colors.blue = Color(0, 0, 255, 255)
  35. colors.brightred = Color(200, 30, 30, 255)
  36. colors.darkred = Color(0, 0, 70, 100)
  37. colors.darkblack = Color(0, 0, 0, 200)
  38. colors.gray1 = Color(0, 0, 0, 155)
  39. colors.gray2 = Color(51, 58, 51,100)
  40. colors.red = Color(255, 0, 0, 255)
  41. colors.white = Color(255, 255, 255, 255)
  42. colors.white1 = Color(255, 255, 255, 200)
  43.  
  44.  
  45.  
  46.  
  47.  
  48. local material = Material("vgui/ob_hudelements/statusbar.png", "smooth")
  49.  
  50. local Lerp = Lerp
  51.  
  52. local localplayer, bar, red, green, blue, orange
  53. local texCoords = {}
  54.  
  55. local stamina, maxStamina = 100, 100
  56.  
  57. local function SetupCoords()
  58. local texW, texH = 512, 96
  59.  
  60. texCoords[1] = {x = 0, y = 1, w = 348, h = 22}
  61. texCoords[2] = {x = 0, y = 58, w = 512, h = 16}
  62. texCoords[3] = {x = 0, y = 41, w = 512, h = 16}
  63. texCoords[4] = {x = 0, y = 32, w = 512, h = 8}
  64. texCoords[5] = {x = 0, y = 75, w = 512, h = 16}
  65.  
  66. for k,v in pairs(texCoords) do
  67. v.w = math.Round((v.w + v.x) / texW, 3)
  68. v.h = math.Round((v.h + v.y) / texH, 3)
  69. v.x = math.Round(v.x / texW, 3)
  70. v.y = math.Round(v.y / texH, 3)
  71. end
  72.  
  73. bar = texCoords[1]
  74. red = texCoords[2]
  75. green = texCoords[3]
  76. blue = texCoords[4]
  77. orange = texCoords[5]
  78. end
  79. SetupCoords()
  80.  
  81. local lastHealth, lastArmor, lastFood, lastStamina = 0, 0, 0, 0
  82.  
  83. hook.Add("HUDPaint", "SKYRIM_HUD", function()
  84. if(Inventory and Inventory.Open) then return end
  85. if GetConVarNumber("rynoxx_enabled") == 1 then return end
  86.  
  87. surface.SetMaterial(material)
  88. surface.SetDrawColor(color_white)
  89.  
  90. surface.DrawTexturedRectUV( 50, ScrH() * 0.95, 348, 22, bar.x, bar.y, bar.w, bar.h)
  91. surface.DrawTexturedRectUV( 72, ScrH() * 0.95 + 2, lastFood, 18, orange.x, orange.y, orange.w, orange.h)
  92.  
  93. surface.DrawTexturedRectUV( ScrW() * 0.5 - 174, ScrH() * 0.95, 348, 22, bar.x, bar.y, bar.w, bar.h)
  94. surface.DrawTexturedRectUV( ScrW() * 0.5 - 152, ScrH() * 0.95 + 3, lastHealth, 16, red.x, red.y, red.w, red.h)
  95. --surface.DrawTexturedRectUV( ScrW() * 0.5 - 152, ScrH() * 0.95 + 11, lastArmor, 8, blue.x, blue.y, blue.w, blue.h)
  96.  
  97. surface.DrawTexturedRectUV( ScrW() - 398, ScrH() * 0.95, 348, 22, bar.x, bar.y, bar.w, bar.h)
  98. surface.DrawTexturedRectUV( ScrW() - 377, ScrH() * 0.95 + 3, lastStamina, 16, blue.x, blue.y, blue.w, blue.h)
  99. end)
  100.  
  101.  
  102. hook.Add("Think", "SKYRIM_HUD", function()
  103. if(!IsValid(LocalPlayer())) then return end
  104. if GetConVarNumber("rynoxx_enabled") == 1 then return end
  105.  
  106. if(lastHealth != LocalPlayer():Health()) then
  107. local d = math.Clamp( LocalPlayer():Health(), 0, 100 ) / (LocalPlayer():GetMaxHealth())
  108. lastHealth = Lerp(FrameTime(), lastHealth, d * 305)
  109. red.w = math.Clamp( LocalPlayer():GetMaxHealth(), 0, 100 )
  110.  
  111. end
  112.  
  113.  
  114. if(lastArmor != LocalPlayer():Armor()) then
  115. local d = LocalPlayer():Armor() / (LocalPlayer().MaxArmor or 100)
  116. lastArmor = Lerp(FrameTime(), lastArmor, d * 305)
  117. blue.w = math.Clamp((lastArmor / (LocalPlayer().MaxArmor or 100)) / 3.05, 0, 200)
  118. end
  119.  
  120. local energy = math.ceil(LocalPlayer():getDarkRPVar("Energy") or 0)
  121. if(lastFood != energy) then
  122. local d = energy / 100
  123. lastFood = Lerp(FrameTime(), lastFood, d * 305)
  124. orange.w = math.Clamp( (lastFood / (energy or 100)) / 3.05, 0, 200)
  125. end
  126.  
  127. if(lastArmor != LocalPlayer():Armor()) then
  128. local d = LocalPlayer():Armor() / (LocalPlayer().MaxArmor or 100)
  129. lastStamina = Lerp(FrameTime(), lastArmor, d * 305)
  130. green.w = math.Clamp((lastArmor / (LocalPlayer().MaxArmor or 100)) / 3.05, 0, 200)
  131. end
  132. end)
  133.  
  134. net.Receive("HUD_Stamina", function(ply, length)
  135. stamina = net.ReadUInt(8)
  136. end)
  137.  
  138. net.Receive("HUD_MaxStamina", function(ply, length)
  139. maxStamina = net.ReadUInt(8)
  140. end)
  141.  
  142.  
  143.  
  144.  
  145.  
  146. hook.Add( "HUDPaint", "WhiteBox", function()
  147. if GetConVarNumber("rynoxx_enabled") == 1 then return end
  148. surface.SetDrawColor( Color( 0, 0, 0, 105 ) )
  149. surface.DrawRect( 0, 0, ScrW() / 1, ScrH() / 24 )
  150. end )
  151.  
  152.  
  153. --===============================================START OF SKYRIM HUD IS ABOVE ME FACK BOI LOL AND BELOW IS THE BAR IF YOU IZ NOT EFEX AND SEE DIS FUCK YA!@@! ENJOY M8
  154. local function bizzahud()
  155. if !IsValid(LocalPlayer()) then return end
  156. if GetConVarNumber("rynoxx_enabled") == 1 then return end
  157. local localplayer = LocalPlayer()
  158.  
  159. --HUNGER STATUS
  160. local hungerInt = LocalPlayer():getDarkRPVar("Energy")
  161.  
  162. local hungerStr, hungerCol = "Nourished", Color(0, 255, 0, 255)
  163.  
  164. if hungerInt < 25 then
  165. hungerStr = "Starving"
  166. elseif hungerInt <= 50 then
  167. hungerStr = "Famished"
  168. elseif hungerInt < 75 then
  169. hungerStr = "Hungry"
  170. end
  171.  
  172.  
  173.  
  174.  
  175. --draw.RoundedBox( 0, 0, ScrH() - 0, 1500, 25, Color( 0, 0, 0, 195 ) )
  176. -- OLD: draw.SimpleText( "[AG] Kingdom RP |", "SkyrimBAR", 30, ScrH() - 800, Color( 255, 255, 255, 25 ) )
  177. draw.SimpleText( "[AG] Kingdom RP |", "SkyrimBAR", ScrW() * 0.01, ScrH() * 0, Color( 255, 255, 255, 95 ) )
  178.  
  179. -- OLD: draw.SimpleText( localplayer:Nick(), "SkyrimBAR", 260, ScrH() - 800, Color( 255, 255, 255, 255 ))
  180. draw.SimpleText( "Name: " .. localplayer:Nick(), "SkyrimBAR", ScrW() * 0.14, ScrH() * 0, Color( 255, 255, 255, 255 ))
  181.  
  182. draw.SimpleText( "Life Style:", "SkyrimBAR", ScrW() * 0.3, ScrH() * 0, Color( 255, 255, 255, 255 ))
  183. draw.SimpleText(( localplayer:getDarkRPVar( "job" ) or 0 ), "SkyrimBAR", ScrW() * 0.36, ScrH() * 0, team.GetColor(localplayer:Team()))
  184. draw.SimpleText( "Salary: " .. ( localplayer:getDarkRPVar( "salary" ) or 0 ) .. " gold", "SkyrimBAR", ScrW() * 0.5, ScrH() * 0, Color( 255, 255, 255, 255 ) )
  185. draw.SimpleText( "Gold: " .. ( localplayer:getDarkRPVar( "money" ) or 0 ), "SkyrimBAR", ScrW() * 0.7, ScrH() * 0, Color( 255, 255, 255, 255 ) )
  186. draw.SimpleText( "Level: " .. ST_Level, "SkyrimBAR", ScrW() * 0.9, ScrH() * 0, Color( 255, 255, 255, 255 ) )
  187. draw.SimpleText( "HR: " .. hungerStr, "DarkRPHUD2", 80, ScrH() - 40, Color( 0, 0, 0, 240 ) )
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201. end
  202.  
  203. hook.Add("HUDPaint", "HUDByMrIbizza", bizzahud)
  204.  
  205.  
  206.  
  207. --=========================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  208.  
  209.  
  210. local function ReloadConVars()
  211. ConVars = {
  212. background = {0,0,0,100},
  213. Healthbackground = {0,0,0,200},
  214. Healthforeground = {140,0,0,180},
  215. HealthText = {255,255,255,200},
  216. Job1 = {0,0,150,200},
  217. Job2 = {0,0,0,255},
  218. salary1 = {0,150,0,200},
  219. salary2 = {0,0,0,255}
  220. }
  221.  
  222. for name, Colour in pairs(ConVars) do
  223. ConVars[name] = {}
  224. for num, rgb in SortedPairs(Colour) do
  225. local CVar = GetConVar(name..num) or CreateClientConVar(name..num, rgb, true, false)
  226. table.insert(ConVars[name], CVar:GetInt())
  227.  
  228. if not cvars.GetConVarCallbacks(name..num, false) then
  229. cvars.AddChangeCallback(name..num, function() timer.Simple(0,ReloadConVars) end)
  230. end
  231. end
  232. ConVars[name] = Color(unpack(ConVars[name]))
  233. end
  234.  
  235.  
  236. HUDWidth = (GetConVar("HudW") or CreateClientConVar("HudW", 240, true, false)):GetInt()
  237. HUDHeight = (GetConVar("HudH") or CreateClientConVar("HudH", 115, true, false)):GetInt()
  238.  
  239. if not cvars.GetConVarCallbacks("HudW", false) and not cvars.GetConVarCallbacks("HudH", false) then
  240. cvars.AddChangeCallback("HudW", function() timer.Simple(0,ReloadConVars) end)
  241. cvars.AddChangeCallback("HudH", function() timer.Simple(0,ReloadConVars) end)
  242. end
  243. end
  244. ReloadConVars()
  245.  
  246. local Scrw, Scrh, RelativeX, RelativeY
  247. /*---------------------------------------------------------------------------
  248. HUD Seperate Elements
  249. ---------------------------------------------------------------------------*/
  250.  
  251. local function DrawHealth()
  252. local maxHealth = localplayer:GetMaxHealth()
  253. local myHealth = localplayer:Health()
  254. Health = math.min(maxHealth, (Health == myHealth and Health) or Lerp(0.1, Health, myHealth))
  255.  
  256. local DrawHealth = math.Min(Health / maxHealth, 1)
  257. local rounded = math.Round(3*DrawHealth)
  258. local Border = math.Min(6, rounded * rounded)
  259. draw.RoundedBox(Border, RelativeX + 4, RelativeY - 30, HUDWidth - 8, 20, ConVars.Healthbackground)
  260. draw.RoundedBox(Border, RelativeX + 5, RelativeY - 29, (HUDWidth - 9) * DrawHealth, 18, ConVars.Healthforeground)
  261.  
  262. draw.DrawNonParsedText(math.Max(0, math.Round(myHealth)), "DarkRPHUD2", RelativeX + 4 + (HUDWidth - 8)/2, RelativeY - 32, ConVars.HealthText, 1)
  263.  
  264. -- Armor
  265. local armor = localplayer:Armor()
  266. if armor ~= 0 then
  267. draw.RoundedBox(2, RelativeX + 4, RelativeY - 15, (HUDWidth - 8) * armor / 100, 5, colors.blue)
  268. end
  269. end
  270.  
  271. local salaryText, JobWalletText
  272. local function DrawInfo()
  273. salaryText = salaryText or DarkRP.getPhrase("salary", DarkRP.formatMoney(localplayer:getDarkRPVar("salary")), "")
  274.  
  275. JobWalletText = JobWalletText or string.format("%s\n%s",
  276. DarkRP.getPhrase("job", localplayer:getDarkRPVar("job") or ""),
  277. DarkRP.getPhrase("wallet", DarkRP.formatMoney(localplayer:getDarkRPVar("money")), "")
  278. )
  279.  
  280. --draw.DrawNonParsedText(salaryText, "DarkRPHUD2", RelativeX + 5, RelativeY - HUDHeight + 6, ConVars.salary1, 0)
  281. --draw.DrawNonParsedText(salaryText, "DarkRPHUD2", RelativeX + 4, RelativeY - HUDHeight + 5, ConVars.salary2, 0)
  282.  
  283. surface.SetFont("DarkRPHUD2")
  284. local w, h = surface.GetTextSize(salaryText)
  285.  
  286. --draw.DrawNonParsedText(JobWalletText, "DarkRPHUD2", RelativeX + 5, RelativeY - HUDHeight + h + 6, ConVars.Job1, 0)
  287. --draw.DrawNonParsedText(JobWalletText, "DarkRPHUD2", RelativeX + 4, RelativeY - HUDHeight + h + 5, ConVars.Job2, 0)
  288. end
  289.  
  290. local Page = Material("icon16/page_white_text.png")
  291. local function GunLicense()
  292. if localplayer:getDarkRPVar("HasGunlicense") then
  293. surface.SetMaterial(Page)
  294. surface.SetDrawColor(0, 0, 0, 0)
  295. surface.DrawTexturedRect(RelativeX + HUDWidth, Scrh - 34, 32, 32)
  296. end
  297. end
  298.  
  299. local agendaText
  300. local function Agenda()
  301. local shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_Agenda")
  302. if shouldDraw == false then return end
  303.  
  304. local agenda = localplayer:getAgendaTable()
  305. if not agenda then return end
  306. agendaText = agendaText or DarkRP.textWrap((localplayer:getDarkRPVar("agenda") or ""):gsub("//", "\n"):gsub("\\n", "\n"), "DarkRPHUD1", 440)
  307.  
  308. draw.RoundedBox(10, 10, 10, 460, 110, colors.gray1)
  309. draw.RoundedBox(10, 12, 12, 456, 106, colors.gray2)
  310. draw.RoundedBox(10, 12, 12, 456, 20, colors.darkred)
  311.  
  312. draw.DrawNonParsedText(agenda.Title, "DarkRPHUD1", 30, 12, colors.red, 0)
  313. draw.DrawNonParsedText(agendaText, "DarkRPHUD1", 30, 35, colors.white, 0)
  314. end
  315.  
  316. hook.Add("DarkRPVarChanged", "agendaHUD", function(ply, var, _, new)
  317. if ply ~= localplayer then return end
  318. if var == "agenda" and new then
  319. agendaText = DarkRP.textWrap(new:gsub("//", "\n"):gsub("\\n", "\n"), "DarkRPHUD1", 440)
  320. else
  321. agendaText = nil
  322. end
  323.  
  324. if var == "salary" then
  325. salaryText = DarkRP.getPhrase("salary", DarkRP.formatMoney(new), "")
  326. end
  327.  
  328. if var == "job" or var == "money" then
  329. JobWalletText = string.format("%s\n%s",
  330. DarkRP.getPhrase("job", var == "job" and new or localplayer:getDarkRPVar("job") or ""),
  331. DarkRP.getPhrase("wallet", var == "money" and DarkRP.formatMoney(new) or DarkRP.formatMoney(localplayer:getDarkRPVar("money")), "")
  332. )
  333. end
  334. end)
  335.  
  336. local VoiceChatTexture = surface.GetTextureID("voice/icntlk_pl")
  337. local function DrawVoiceChat()
  338. if localplayer.DRPIsTalking then
  339. local chbxX, chboxY = chat.GetChatBoxPos()
  340.  
  341. local Rotating = math.sin(CurTime()*3)
  342. local backwards = 0
  343. if Rotating < 0 then
  344. Rotating = 1-(1+Rotating)
  345. backwards = 180
  346. end
  347. surface.SetTexture(VoiceChatTexture)
  348. surface.SetDrawColor(ConVars.Healthforeground)
  349. surface.DrawTexturedRectRotated(Scrw - 100, chboxY, Rotating*96, 96, backwards)
  350. end
  351. end
  352.  
  353. local function LockDown()
  354. local chbxX, chboxY = chat.GetChatBoxPos()
  355. if GetGlobalBool("DarkRP_LockDown") then
  356. local cin = (math.sin(CurTime()) + 1) / 2
  357. local chatBoxSize = math.floor(Scrh / 4)
  358. draw.DrawNonParsedText(DarkRP.getPhrase("lockdown_started"), "ScoreboardSubtitle", chbxX, chboxY + chatBoxSize, Color(cin * 255, 0, 255 - (cin * 255), 255), TEXT_ALIGN_LEFT)
  359. end
  360. end
  361.  
  362. local Arrested = function() end
  363.  
  364. usermessage.Hook("GotArrested", function(msg)
  365. local StartArrested = CurTime()
  366. local ArrestedUntil = msg:ReadFloat()
  367.  
  368. Arrested = function()
  369. if CurTime() - StartArrested <= ArrestedUntil and localplayer:getDarkRPVar("Arrested") then
  370. draw.DrawNonParsedText(DarkRP.getPhrase("youre_arrested", math.ceil(ArrestedUntil - (CurTime() - StartArrested))), "DarkRPHUD1", Scrw/2, Scrh - Scrh/12, colors.white, 1)
  371. elseif not localplayer:getDarkRPVar("Arrested") then
  372. Arrested = function() end
  373. end
  374. end
  375. end)
  376.  
  377. local AdminTell = function() end
  378.  
  379. usermessage.Hook("AdminTell", function(msg)
  380. timer.Destroy("DarkRP_AdminTell")
  381. local Message = msg:ReadString()
  382.  
  383. AdminTell = function()
  384. draw.RoundedBox(4, 10, 10, Scrw - 20, 110, colors.darkblack)
  385. draw.DrawNonParsedText(DarkRP.getPhrase("listen_up"), "GModToolName", Scrw / 2 + 10, 10, colors.white, 1)
  386. draw.DrawNonParsedText(Message, "ChatFont", Scrw / 2 + 10, 90, colors.brightred, 1)
  387. end
  388.  
  389. timer.Create("DarkRP_AdminTell", 10, 1, function()
  390. AdminTell = function() end
  391. end)
  392. end)
  393.  
  394. /*---------------------------------------------------------------------------
  395. Drawing the HUD elements such as Health etc.
  396. ---------------------------------------------------------------------------*/
  397. local function DrawHUD()
  398. localplayer = localplayer and IsValid(localplayer) and localplayer or LocalPlayer()
  399. if not IsValid(localplayer) then return end
  400.  
  401. local shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_HUD")
  402. if shouldDraw == false then return end
  403.  
  404. Scrw, Scrh = ScrW(), ScrH()
  405. RelativeX, RelativeY = 0, Scrh
  406.  
  407. shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_LocalPlayerHUD")
  408. shouldDraw = shouldDraw ~= false and (GAMEMODE.BaseClass.HUDShouldDraw(GAMEMODE, "DarkRP_LocalPlayerHUD") ~= false)
  409. if shouldDraw then
  410. --Background
  411. --draw.RoundedBox(6, 0, Scrh - HUDHeight, HUDWidth, HUDHeight, ConVars.background)
  412. --DrawHealth()
  413. DrawInfo()
  414. GunLicense()
  415. end
  416. --Agenda()
  417. DrawVoiceChat()
  418. LockDown()
  419.  
  420. Arrested()
  421. AdminTell()
  422. end
  423.  
  424.  
  425.  
  426. /*---------------------------------------------------------------------------
  427. Entity HUDPaint things
  428. ---------------------------------------------------------------------------*/
  429. -- Draw a player's name, health and/or job above the head
  430. -- This syntax allows for easy overriding
  431. plyMeta.drawPlayerInfo = plyMeta.drawPlayerInfo or function(self)
  432. local pos = self:EyePos()
  433.  
  434. pos.z = pos.z + 10 -- The position we want is a bit above the position of the eyes
  435. pos = pos:ToScreen()
  436. if not self:getDarkRPVar("wanted") then
  437. -- Move the text up a few pixels to compensate for the height of the text
  438. pos.y = pos.y - 50
  439. end
  440.  
  441. if GAMEMODE.Config.showname then
  442. local nick, plyTeam = self:Nick(), self:Team()
  443. draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x + 1, pos.y + 1, colors.black, 1)
  444. draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x, pos.y, RPExtraTeams[plyTeam] and RPExtraTeams[plyTeam].color or team.GetColor(plyTeam) , 1)
  445. end
  446.  
  447. if GAMEMODE.Config.showhealth then
  448. local health = DarkRP.getPhrase("health", self:Health())
  449. draw.DrawNonParsedText(health, "DarkRPHUD2", pos.x + 1, pos.y + 21, colors.black, 1)
  450. draw.DrawNonParsedText(health, "DarkRPHUD2", pos.x, pos.y + 20, colors.white1, 1)
  451. end
  452.  
  453. if GAMEMODE.Config.showjob then
  454. local teamname = self:getDarkRPVar("job") or team.GetName(self:Team())
  455. draw.DrawNonParsedText(teamname, "DarkRPHUD2", pos.x + 1, pos.y + 41, colors.black, 1)
  456. draw.DrawNonParsedText(teamname, "DarkRPHUD2", pos.x, pos.y + 40, colors.white1, 1)
  457. end
  458.  
  459. if self:getDarkRPVar("HasGunlicense") then
  460. surface.SetMaterial(Page)
  461. surface.SetDrawColor(0,0,0,0)
  462. surface.DrawTexturedRect(pos.x-16, pos.y + 60, 32, 32)
  463. end
  464. end
  465.  
  466. -- Draw wanted information above a player's head
  467. -- This syntax allows for easy overriding
  468. plyMeta.drawWantedInfo = plyMeta.drawWantedInfo or function(self)
  469. if not self:Alive() then return end
  470.  
  471. local pos = self:EyePos()
  472. if not pos:isInSight({localplayer, self}) then return end
  473.  
  474. pos.z = pos.z + 10
  475. pos = pos:ToScreen()
  476.  
  477. if GAMEMODE.Config.showname then
  478. local nick, plyTeam = self:Nick(), self:Team()
  479. draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x + 1, pos.y + 1, colors.black, 1)
  480. draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x, pos.y, RPExtraTeams[plyTeam] and RPExtraTeams[plyTeam].color or team.GetColor(plyTeam) , 1)
  481. end
  482.  
  483. local wantedText = DarkRP.getPhrase("wanted", tostring(self:getDarkRPVar("wantedReason")))
  484.  
  485. draw.DrawNonParsedText(wantedText, "DarkRPHUD2", pos.x, pos.y - 40, colors.white1, 1)
  486. draw.DrawNonParsedText(wantedText, "DarkRPHUD2", pos.x + 1, pos.y - 41, colors.red, 1)
  487. end
  488.  
  489. /*---------------------------------------------------------------------------
  490. The Entity display: draw HUD information about entities
  491. ---------------------------------------------------------------------------*/
  492. local function DrawEntityDisplay()
  493. local shouldDraw, players = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_EntityDisplay")
  494. if shouldDraw == false then return end
  495.  
  496. local shootPos = localplayer:GetShootPos()
  497. local aimVec = localplayer:GetAimVector()
  498.  
  499. for k, ply in pairs(players or player.GetAll()) do
  500. if ply == localplayer or not ply:Alive() or ply:GetNoDraw() then continue end
  501. local hisPos = ply:GetShootPos()
  502. if ply:getDarkRPVar("wanted") then ply:drawWantedInfo() end
  503.  
  504. if GAMEMODE.Config.globalshow then
  505. ply:drawPlayerInfo()
  506. -- Draw when you're (almost) looking at him
  507. elseif hisPos:DistToSqr(shootPos) < 160000 then
  508. local pos = hisPos - shootPos
  509. local unitPos = pos:GetNormalized()
  510. if unitPos:Dot(aimVec) > 0.95 then
  511. local trace = util.QuickTrace(shootPos, pos, localplayer)
  512. if trace.Hit and trace.Entity ~= ply then return end
  513. ply:drawPlayerInfo()
  514. end
  515. end
  516. end
  517.  
  518. local tr = localplayer:GetEyeTrace()
  519.  
  520. if IsValid(tr.Entity) and tr.Entity:isKeysOwnable() and tr.Entity:GetPos():DistToSqr(localplayer:GetPos()) < 40000 then
  521. tr.Entity:drawOwnableInfo()
  522. end
  523. end
  524.  
  525. /*---------------------------------------------------------------------------
  526. Drawing death notices
  527. ---------------------------------------------------------------------------*/
  528. function GM:DrawDeathNotice(x, y)
  529. if not GAMEMODE.Config.showdeaths then return end
  530. self.BaseClass:DrawDeathNotice(x, y)
  531. end
  532.  
  533. /*---------------------------------------------------------------------------
  534. Display notifications
  535. ---------------------------------------------------------------------------*/
  536. local function DisplayNotify(msg)
  537. local txt = msg:ReadString()
  538. GAMEMODE:AddNotify(txt, msg:ReadShort(), msg:ReadLong())
  539. surface.PlaySound("buttons/lightswitch2.wav")
  540.  
  541. -- Log to client console
  542. MsgC(Color(255, 20, 20, 255), "[DarkRP] ", Color(200, 200, 200, 255), txt, "\n")
  543. end
  544. usermessage.Hook("_Notify", DisplayNotify)
  545.  
  546. /*---------------------------------------------------------------------------
  547. Remove some elements from the HUD in favour of the DarkRP HUD
  548. ---------------------------------------------------------------------------*/
  549. function hidehud(name)
  550. for k, v in pairs({"CHudHealth", "CHudBattery", "CHudAmmo"})do
  551. if name == v then return false end
  552. end
  553. end
  554. hook.Add("HUDShouldDraw", "HideOurHud:D", hidehud)
  555.  
  556. /*---------------------------------------------------------------------------
  557. Disable players' names popping up when looking at them
  558. ---------------------------------------------------------------------------*/
  559. function GM:HUDDrawTargetID()
  560. return false
  561. end
  562. /*---------------------------------------------------------------------------
  563. Actual HUDPaint hook
  564. ---------------------------------------------------------------------------*/
  565. function GM:HUDPaint()
  566. DrawHUD()
  567. DrawEntityDisplay()
  568. self.BaseClass:HUDPaint()
  569. end
Advertisement
Add Comment
Please, Sign In to add comment