Guest User

Untitled

a guest
Aug 10th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.76 KB | None | 0 0
  1. local function Base()
  2.  
  3.  
  4. local width1 = ScrW()
  5. local height1 = ScrH()
  6. local DrawHealth = LocalPlayer():Health() or 0
  7. local EchoHealth = LocalPlayer():Health() or 0
  8. local drawHealth2 = (width1 / 5) / 100 * DrawHealth
  9. local DrawArmour = LocalPlayer():Armor() or 0
  10. local EchoArmour = LocalPlayer():Armor() or 0
  11. local drawArmour2 = (width1 / 5) / 100 * DrawArmour or 0
  12. local NickName = LocalPlayer():Nick()
  13. draw.RoundedBox(6,width1 / 80,height1 / 1.2765,width1 / 4.266666667 ,height1 / 5.142857 ,Color(135,206,235,245)) --Main box
  14. draw.RoundedBox(6,width1 / 35.55555556,height1 / 1.2 ,width1 / 4.923076923,height1 / 52.94117647,Color(0,0,0,255)) --Health outer box
  15. draw.RoundedBox(6,45,height1 - 130 ,325,17,Color(0,0,0,255)) --Armourouterbox 751
  16.  
  17.  
  18.  
  19. if DrawHealth > 100 then DrawHealth = 100 end
  20. if DrawHealth < 0 then DrawHealth = 0 end
  21. if DrawArmour >= 1 then
  22. draw.RoundedBox(6,width1 / 33.4,height1 - (height1 / 6.976744186) ,drawArmour2,height1 / 64.2857,Color(0,0,255,255)) --Health
  23. end
  24. if DrawHealth >= 1 then
  25. draw.RoundedBox(6,width1 / 33.4,height1 / 1.1989 ,drawHealth2,height1 / 64.2857,Color(255,0,0,255)) --Health
  26. end
  27. draw.DrawText( "Armour:"..EchoArmour, Trebuchet24, width1 - 1545, height1 - 130,Color(255,255,255))
  28. draw.DrawText( "Health:"..EchoHealth, Trebuchet24, width1 - 1545, height1 - 150,Color(255,255,255))
  29. surface.SetTextColor( 255, 255, 255)
  30.  
  31. draw.DrawText(NickName,EquisFont,width1 - 1545,height1 - 170,Color(255,255,255))
  32. draw.DrawText("Money $"..LocalPlayer():getDarkRPVar( "money" ),EquisFont,width1 - 1545,height1 - 100,Color(255,255,255))
  33. draw.DrawText("Salary:"..LocalPlayer():getDarkRPVar( "salary" ),EquisFont,width1 - 1545,height1 - 80,Color(255,255,255))
  34. draw.DrawText("Job:"..LocalPlayer():getDarkRPVar( "job" ),EquisFont,width1 - 1400,height1 - 100,Color(255,255,255))
  35. draw.DrawText("Steam ID:"..LocalPlayer():SteamID(),EquisFont,width1 - 1400,height1 - 60,Color(255,255,255))
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. end
  50.  
  51. --[[---------------------------------------------------------------------------
  52. HUD ConVars
  53. ---------------------------------------------------------------------------]]
  54. local ConVars = {}
  55. local HUDWidth
  56. local HUDHeight
  57. local Color = Color
  58. local CurTime = CurTime
  59. local cvars = cvars
  60. local DarkRP = DarkRP
  61. local draw = draw
  62. local GetConVar = GetConVar
  63. local hook = hook
  64. local IsValid = IsValid
  65. local Lerp = Lerp
  66. local localplayer
  67. local math = math
  68. local pairs = pairs
  69. local ScrW, ScrH = ScrW, ScrH
  70. local SortedPairs = SortedPairs
  71. local string = string
  72. local surface = surface
  73. local table = table
  74. local timer = timer
  75. local tostring = tostring
  76. local plyMeta = FindMetaTable("Player")
  77. local DrawPicture = false
  78. local ply = LocalPlayer()
  79.  
  80. local colors = {}
  81. colors.black = Color(0, 0, 0, 255)
  82. colors.blue = Color(0, 0, 255, 255)
  83. colors.brightred = Color(200, 30, 30, 255)
  84. colors.darkred = Color(0, 0, 70, 100)
  85. colors.darkblack = Color(0, 0, 0, 200)
  86. colors.gray1 = Color(0, 0, 0, 155)
  87. colors.gray2 = Color(51, 58, 51,100)
  88. colors.red = Color(255, 0, 0, 255)
  89. colors.white = Color(255, 255, 255, 255)
  90. colors.white1 = Color(255, 255, 255, 200)
  91.  
  92. surface.CreateFont( "EquisFont", {
  93. font = "Arial", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
  94. extended = false,
  95. size = 400,
  96. weight = 500,
  97. blursize = 0,
  98. scanlines = 0,
  99. antialias = true,
  100. underline = false,
  101. italic = false,
  102. strikeout = false,
  103. symbol = false,
  104. rotary = false,
  105. shadow = false,
  106. additive = false,
  107. outline = false,
  108. } )
  109. local function ReloadConVars()
  110. ConVars = {
  111. background = {0,0,0,100},
  112. Healthbackground = {0,0,0,200},
  113. Healthforeground = {140,0,0,180},
  114. HealthText = {255,255,255,200},
  115. Job1 = {0,0,150,200},
  116. Job2 = {0,0,0,255},
  117. salary1 = {0,150,0,200},
  118. salary2 = {0,0,0,255}
  119. }
  120.  
  121. for name, Colour in pairs(ConVars) do
  122. ConVars[name] = {}
  123. for num, rgb in SortedPairs(Colour) do
  124. local CVar = GetConVar(name .. num) or CreateClientConVar(name .. num, rgb, true, false)
  125. table.insert(ConVars[name], CVar:GetInt())
  126.  
  127. if not cvars.GetConVarCallbacks(name .. num, false) then
  128. cvars.AddChangeCallback(name .. num, function()
  129. timer.Simple(0, ReloadConVars)
  130. end)
  131. end
  132. end
  133. ConVars[name] = Color(unpack(ConVars[name]))
  134. end
  135.  
  136.  
  137. HUDWidth = (GetConVar("HudW") or CreateClientConVar("HudW", 240, true, false)):GetInt()
  138. HUDHeight = (GetConVar("HudH") or CreateClientConVar("HudH", 115, true, false)):GetInt()
  139.  
  140. if not cvars.GetConVarCallbacks("HudW", false) and not cvars.GetConVarCallbacks("HudH", false) then
  141. cvars.AddChangeCallback("HudW", function() timer.Simple(0,ReloadConVars) end)
  142. cvars.AddChangeCallback("HudH", function() timer.Simple(0,ReloadConVars) end)
  143. end
  144. end
  145. ReloadConVars()
  146.  
  147. local Scrw, Scrh, RelativeX, RelativeY
  148. --[[---------------------------------------------------------------------------
  149. HUD separate Elements
  150. ---------------------------------------------------------------------------]]
  151.  
  152. local function GunLicense()
  153. if LocalPlayer():getDarkRPVar("HasGunlicense") then
  154. surface.SetMaterial(Page)
  155. surface.SetDrawColor(255, 255, 255, 255)
  156. surface.DrawTexturedRect(RelativeX + HUDWidth, Scrh - 34, 32, 32)
  157. end
  158. end
  159. local agendaText
  160. local function Agenda()
  161.  
  162. local agenda = LocalPlayer():getAgendaTable()
  163. if not agenda then return end
  164. agendaText = agendaText or DarkRP.textWrap((localplayer:getDarkRPVar("agenda") or ""):gsub("//", "\n"):gsub("\\n", "\n"), "DarkRPHUD1", 440)
  165.  
  166. draw.RoundedBox(10, 10, 10, 460, 110, colors.gray1)
  167. draw.RoundedBox(10, 12, 12, 456, 106, colors.gray2)
  168. draw.RoundedBox(10, 12, 12, 456, 20, colors.darkred)
  169.  
  170. draw.DrawNonParsedText(agenda.Title, "DarkRPHUD1", 30, 12, colors.red, 0)
  171. draw.DrawNonParsedText(agendaText, "DarkRPHUD1", 30, 35, colors.white, 0)
  172. end
  173.  
  174. hook.Add("DarkRPVarChanged", "agendaHUD", function(ply, var, _, new)
  175. if ply ~= localplayer then return end
  176. if var == "agenda" and new then
  177. agendaText = DarkRP.textWrap(new:gsub("//", "\n"):gsub("\\n", "\n"), "DarkRPHUD1", 440)
  178. else
  179. agendaText = nil
  180. end
  181.  
  182. if var == "salary" then
  183. salaryText = DarkRP.getPhrase("salary", DarkRP.formatMoney(new), "")
  184. end
  185.  
  186. if var == "job" or var == "money" then
  187. JobWalletText = string.format("%s\n%s",
  188. DarkRP.getPhrase("job", var == "job" and new or localplayer:getDarkRPVar("job") or ""),
  189. DarkRP.getPhrase("wallet", var == "money" and DarkRP.formatMoney(new) or DarkRP.formatMoney(localplayer:getDarkRPVar("money")), "")
  190. )
  191. end
  192. end)
  193.  
  194. local VoiceChatTexture = surface.GetTextureID("voice/icntlk_pl")
  195. local function DrawVoiceChat()
  196. if LocalPlayer().DRPIsTalking then
  197. local _, chboxY = chat.GetChatBoxPos()
  198.  
  199. local Rotating = math.sin(CurTime() * 3)
  200. local backwards = 0
  201.  
  202. if Rotating < 0 then
  203. Rotating = 1 - (1 + Rotating)
  204. backwards = 180
  205. end
  206.  
  207. surface.SetTexture(VoiceChatTexture)
  208. surface.SetDrawColor(ConVars.Healthforeground)
  209. surface.DrawTexturedRectRotated(Scrw - 100, chboxY, Rotating * 96, 96, backwards)
  210. end
  211. end
  212.  
  213. local function LockDown()
  214. local chbxX, chboxY = chat.GetChatBoxPos()
  215. if GetGlobalBool("DarkRP_LockDown") then
  216. local shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_LockdownHUD")
  217. if shouldDraw == false then return end
  218. local cin = (math.sin(CurTime()) + 1) / 2
  219. local chatBoxSize = math.floor(Scrh / 4)
  220. draw.DrawNonParsedText(DarkRP.getPhrase("lockdown_started"), "ScoreboardSubtitle", chbxX, chboxY + chatBoxSize, Color(cin * 255, 0, 255 - (cin * 255), 255), TEXT_ALIGN_LEFT)
  221. end
  222. end
  223.  
  224. local Arrested = function() end
  225.  
  226. usermessage.Hook("GotArrested", function(msg)
  227. local StartArrested = CurTime()
  228. local ArrestedUntil = msg:ReadFloat()
  229.  
  230. Arrested = function()
  231. local shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_ArrestedHUD")
  232. if shouldDraw == false then return end
  233.  
  234. if CurTime() - StartArrested <= ArrestedUntil and localplayer:getDarkRPVar("Arrested") then
  235. draw.DrawNonParsedText(DarkRP.getPhrase("youre_arrested", math.ceil((ArrestedUntil - (CurTime() - StartArrested)) * 1 / game.GetTimeScale())), "DarkRPHUD1", Scrw / 2, Scrh - Scrh / 12, colors.white, 1)
  236. elseif not localplayer:getDarkRPVar("Arrested") then
  237. Arrested = function() end
  238. end
  239. end
  240. end)
  241.  
  242. local AdminTell = function() end
  243.  
  244. usermessage.Hook("AdminTell", function(msg)
  245. timer.Remove("DarkRP_AdminTell")
  246. local Message = msg:ReadString()
  247.  
  248. AdminTell = function()
  249. draw.RoundedBox(4, 10, 10, Scrw - 20, 110, colors.darkblack)
  250. draw.DrawNonParsedText(DarkRP.getPhrase("listen_up"), "GModToolName", Scrw / 2 + 10, 10, colors.white, 1)
  251. draw.DrawNonParsedText(Message, "ChatFont", Scrw / 2 + 10, 90, colors.brightred, 1)
  252. end
  253.  
  254. timer.Create("DarkRP_AdminTell", 10, 1, function()
  255. AdminTell = function() end
  256. end)
  257. end)
  258.  
  259.  
  260.  
  261. --[[---------------------------------------------------------------------------
  262. Entity HUDPaint things
  263. ---------------------------------------------------------------------------]]
  264. -- Draw a player's name, health and/or job above the head
  265. -- This syntax allows for easy overriding
  266. plyMeta.drawPlayerInfo = plyMeta.drawPlayerInfo or function(self)
  267. local pos = self:EyePos()
  268.  
  269. pos.z = pos.z + 10 -- The position we want is a bit above the position of the eyes
  270. pos = pos:ToScreen()
  271. if not self:getDarkRPVar("wanted") then
  272. -- Move the text up a few pixels to compensate for the height of the text
  273. pos.y = pos.y - 50
  274. end
  275.  
  276. if GAMEMODE.Config.showname then
  277. local nick, plyTeam = self:Nick(), self:Team()
  278. draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x + 1, pos.y + 1, colors.black, 1)
  279. draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x, pos.y, RPExtraTeams[plyTeam] and RPExtraTeams[plyTeam].color or team.GetColor(plyTeam) , 1)
  280. end
  281.  
  282. if GAMEMODE.Config.showhealth then
  283. local health = DarkRP.getPhrase("health", self:Health())
  284. draw.DrawNonParsedText(health, "DarkRPHUD2", pos.x + 1, pos.y + 21, colors.black, 1)
  285. draw.DrawNonParsedText(health, "DarkRPHUD2", pos.x, pos.y + 20, colors.white1, 1)
  286. end
  287.  
  288. if GAMEMODE.Config.showjob then
  289. local teamname = self:getDarkRPVar("job") or team.GetName(self:Team())
  290. draw.DrawNonParsedText(teamname, "DarkRPHUD2", pos.x + 1, pos.y + 41, colors.black, 1)
  291. draw.DrawNonParsedText(teamname, "DarkRPHUD2", pos.x, pos.y + 40, colors.white1, 1)
  292. end
  293.  
  294. if self:getDarkRPVar("HasGunlicense") then
  295. surface.SetMaterial(Page)
  296. surface.SetDrawColor(255,255,255,255)
  297. surface.DrawTexturedRect(pos.x-16, pos.y + 60, 32, 32)
  298. end
  299. end
  300.  
  301. -- Draw wanted information above a player's head
  302. -- This syntax allows for easy overriding
  303. plyMeta.drawWantedInfo = plyMeta.drawWantedInfo or function(self)
  304. if not self:Alive() then return end
  305.  
  306. local pos = self:EyePos()
  307. if not pos:isInSight({localplayer, self}) then return end
  308.  
  309. pos.z = pos.z + 10
  310. pos = pos:ToScreen()
  311.  
  312. if GAMEMODE.Config.showname then
  313. local nick, plyTeam = self:Nick(), self:Team()
  314. draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x + 1, pos.y + 1, colors.black, 1)
  315. draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x, pos.y, RPExtraTeams[plyTeam] and RPExtraTeams[plyTeam].color or team.GetColor(plyTeam) , 1)
  316. end
  317.  
  318. local wantedText = DarkRP.getPhrase("wanted", tostring(self:getDarkRPVar("wantedReason")))
  319.  
  320. draw.DrawNonParsedText(wantedText, "DarkRPHUD2", pos.x, pos.y - 40, colors.white1, 1)
  321. draw.DrawNonParsedText(wantedText, "DarkRPHUD2", pos.x + 1, pos.y - 41, colors.red, 1)
  322. end
  323.  
  324. --[[---------------------------------------------------------------------------
  325. The Entity display: draw HUD information about entities
  326. ---------------------------------------------------------------------------]]
  327. local function DrawEntityDisplay()
  328.  
  329.  
  330. local shootPos = localplayer:GetShootPos()
  331. local aimVec = localplayer:GetAimVector()
  332.  
  333. for k, ply in pairs(players or player.GetAll()) do
  334. if ply == localplayer or not ply:Alive() or ply:GetNoDraw() then continue end
  335. local hisPos = ply:GetShootPos()
  336. if ply:getDarkRPVar("wanted") then ply:drawWantedInfo() end
  337.  
  338. if GAMEMODE.Config.globalshow then
  339. ply:drawPlayerInfo()
  340. -- Draw when you're (almost) looking at him
  341. elseif hisPos:DistToSqr(shootPos) < 160000 then
  342. local pos = hisPos - shootPos
  343. local unitPos = pos:GetNormalized()
  344. if unitPos:Dot(aimVec) > 0.95 then
  345. local trace = util.QuickTrace(shootPos, pos, localplayer)
  346. if trace.Hit and trace.Entity ~= ply then break end
  347. ply:drawPlayerInfo()
  348. end
  349. end
  350. end
  351.  
  352. local tr = localplayer:GetEyeTrace()
  353.  
  354. if IsValid(tr.Entity) and tr.Entity:isKeysOwnable() and tr.Entity:GetPos():DistToSqr(localplayer:GetPos()) < 40000 then
  355. tr.Entity:drawOwnableInfo()
  356. end
  357. end
  358.  
  359. --[[---------------------------------------------------------------------------
  360. Drawing death notices
  361. ---------------------------------------------------------------------------]]
  362. function GAMEMODE:DrawDeathNotice(x, y)
  363. if not GAMEMODE.Config.showdeaths then return end
  364. self.Sandbox.DrawDeathNotice(self, x, y)
  365. end
  366.  
  367. --[[---------------------------------------------------------------------------
  368. Display notifications
  369. ---------------------------------------------------------------------------]]
  370. local function DisplayNotify(msg)
  371. local txt = msg:ReadString()
  372. GAMEMODE:AddNotify(txt, msg:ReadShort(), msg:ReadLong())
  373. surface.PlaySound("buttons/lightswitch2.wav")
  374.  
  375. -- Log to client console
  376. MsgC(Color(255, 20, 20, 255), "[DarkRP] ", Color(200, 200, 200, 255), txt, "\n")
  377. end
  378. usermessage.Hook("_Notify", DisplayNotify)
  379.  
  380. --[[---------------------------------------------------------------------------
  381. Remove some elements from the HUD in favour of the DarkRP HUD
  382. ---------------------------------------------------------------------------]]
  383. function GAMEMODE:HUDShouldDraw(name)
  384. if name == "CHudHealth" or
  385. name == "CHudBattery" or
  386. name == "CHudSuitPower" or
  387. (HelpToggled and name == "CHudChat") then
  388. return false
  389. else
  390. return self.Sandbox.HUDShouldDraw(self, name)
  391. end
  392. end
  393.  
  394. --[[---------------------------------------------------------------------------
  395. Disable players' names popping up when looking at them
  396. ---------------------------------------------------------------------------]]
  397. function GAMEMODE:HUDDrawTargetID()
  398. return false
  399. end
  400.  
  401. --[[---------------------------------------------------------------------------
  402. Actual HUDPaint hook
  403. ---------------------------------------------------------------------------]]
  404. function DrawHUD()
  405.  
  406.  
  407. local shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_HUD")
  408. if shouldDraw == false then return end
  409.  
  410. --cust2om
  411.  
  412.  
  413. Base()
  414. --default
  415.  
  416. GunLicense()
  417. Agenda()
  418. DrawVoiceChat()
  419. LockDown()
  420. Arrested()
  421. AdminTell()
  422.  
  423. DrawHUD()
  424. DrawEntityDisplay()
  425.  
  426. self.Sandbox.HUDPaint(self)
  427. end
  428.  
  429. hook.Add("HUDPaint", "DrawHUD", DrawHUD)
  430.  
  431. --You steal this hud your a dick from Ambient
Add Comment
Please, Sign In to add comment