Advertisement
pogh10

Untitled

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