Advertisement
Epilepsys

Untitled

Dec 11th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.07 KB | None | 0 0
  1. /**************************
  2. ********Informations*******
  3. ***************************/
  4.  
  5. --[[
  6.  
  7. Createur : Epilesys
  8.  
  9. Pour le serveur : KlytherLife
  10.  
  11. Steam : https://steamcommunity.com/id/Epilepsys/
  12. Discord : Epilepsys#2284
  13.  
  14. Merci pour votre achat.
  15.  
  16. --]]
  17.  
  18.  
  19.  
  20. -----------------------------------------------------------------------------
  21. -- Which default HUD elements should be hidden?
  22. -----------------------------------------------------------------------------
  23.  
  24. local hideHUDElements = {
  25. -- if you DarkRP_HUD this to true, ALL of DarkRP's HUD will be disabled. That is the health bar and stuff,
  26. -- but also the agenda, the voice chat icons, lockdown text, player arrested text and the names above players' heads
  27. ["DarkRP_HUD"] = false,
  28.  
  29. -- DarkRP_EntityDisplay is the text that is drawn above a player when you look at them.
  30. -- This also draws the information on doors and vehicles
  31. ["DarkRP_EntityDisplay"] = true,
  32.  
  33. -- DarkRP_ZombieInfo draws information about zombies for admins who use /showzombie.
  34. ["DarkRP_ZombieInfo"] = false,
  35.  
  36. -- This is the one you're most likely to replace first
  37. -- DarkRP_LocalPlayerHUD is the default HUD you see on the bottom left of the screen
  38. -- It shows your health, job, salary and wallet
  39. ["DarkRP_LocalPlayerHUD"] = false,
  40. ["DarkRP_Hungermod"] = true,
  41.  
  42. -- Drawing the DarkRP agenda
  43. ["DarkRP_Agenda"] = false,
  44. ["CHudAmmo"] = true,
  45. }
  46. hook.Add( "HUDShouldDraw", "DefautHUD", function( name )
  47. if ( name == "CHudHealth" or name == "CHudBattery" ) then
  48. return false
  49. end
  50. end)
  51.  
  52. local scale = ScrW() >= 2560 and 2 or 1
  53.  
  54. local shadow_x = 1*scale
  55. local shadow_y = 1*scale
  56.  
  57. local col_face = Color(255,255,255,255)
  58. local col_shadow = Color(0,0,0,255)
  59. local col_half_shadow = Color(0,0,0,200)
  60.  
  61. hook.Add("HUDShouldDraw", "HideDefaultDarkRPHud", function(name)
  62. if hideHUDElements[name] then return false end
  63. end)
  64.  
  65.  
  66.  
  67.  
  68.  
  69. surface.CreateFont("abs_hud_time", {
  70. size = 35 * scale,
  71. weight = 350 * scale,
  72. antialias = true,
  73. font = "Roboto"})
  74.  
  75. surface.CreateFont("abs_hud_time_shadow", {
  76. size = 35 * scale,
  77. weight = 350 * scale,
  78. antialias = true,
  79. blursize = 3 * scale,
  80. font = "Roboto"})
  81.  
  82. surface.CreateFont("abs_hud_ammo", {
  83. size = 42 * scale,
  84. weight = 350 * scale,
  85. antialias = true,
  86. font = "Roboto"})
  87.  
  88. surface.CreateFont("abs_hud_ammo_shadow", {
  89. size = 42 * scale,
  90. weight = 350 * scale,
  91. antialias = true,
  92. blursize = 3 * scale,
  93. font = "Roboto"})
  94.  
  95. surface.CreateFont("abs_hud", {
  96. size = 22 * scale,
  97. weight = 350 * scale,
  98. antialias = true,
  99. font = "Tahoma"})
  100.  
  101. surface.CreateFont("abs_hud_shadow", {
  102. size = 22 * scale,
  103. weight = 350 * scale,
  104. antialias = true,
  105. blursize = 3 * scale,
  106. font = "Tahoma"})
  107.  
  108. local ALIGN_LEFT = 0
  109. local ALIGN_CENTER = 0.5
  110. local ALIGN_RIGHT = 1
  111. local ALIGN_TOP = 1
  112. local ALIGN_BOTTOM = 0
  113.  
  114.  
  115. local function SimpleText(str, font, ...)
  116. draw.SimpleText(str, font, ...)
  117. return surface.GetTextSize(str)
  118. end
  119.  
  120.  
  121.  
  122.  
  123. local function BeautyText( str, font, font_shadow, x, y, color, xalign, yalign )
  124. font = font or "abs_hud"
  125. surface.SetFont( font )
  126. local tw, th = surface.GetTextSize( str )
  127. x = (x or 0) - tw * (xalign or 0)
  128. y = (y or 0) - th * (yalign or 0)
  129. surface.SetTextPos( x, y )
  130.  
  131. -- sorf shadow:
  132. if font_shadow then
  133. surface.SetTextPos( x, y+3 )
  134. surface.SetTextColor( col_shadow )
  135. surface.SetFont( font_shadow )
  136. surface.DrawText( str )
  137. surface.SetTextPos( x, y )
  138. end
  139. -- sharp shadow:
  140. surface.SetTextPos( x + shadow_x , y + shadow_y )
  141. surface.SetTextColor( col_half_shadow )
  142. surface.SetFont( font )
  143. surface.DrawText( str )
  144. -- text itself:
  145. surface.SetTextColor( color or col_face )
  146. surface.SetTextPos( x, y )
  147. surface.DrawText( str )
  148.  
  149. return tw,th
  150. end
  151.  
  152. local function WideBar(num, max, w, color, x, y)
  153. local h = 22 * scale
  154.  
  155. local o = BeautyText(num .. "%", "abs_hud", "abs_hud_shadow", x, y, color, ALIGN_LEFT, ALIGN_TOP) + 4 * scale
  156. x = x + o
  157.  
  158. surface.SetDrawColor(ColorAlpha(color, 64))
  159. surface.DrawRect(x, y - h + h/4, w * scale, h/2)
  160.  
  161. surface.SetDrawColor(color)
  162. surface.DrawRect(x, y - h + h/4, w * math.max(0, math.min(1, num/max)) * scale, h/2)
  163.  
  164. return o + w * scale, h
  165. end
  166.  
  167. local x, y, i_am_the_greatest, seen_anything = 0, 0, 0
  168.  
  169. local function yield(w, h)
  170. x = x + w
  171. i_am_the_greatest = math.max(i_am_the_greatest, h)
  172. seen_anything = true
  173. end
  174.  
  175. local function space()
  176. x = x + 8 * scale
  177. end
  178.  
  179. local hud = {}
  180. local function Row(...)
  181. table.insert(hud, {...})
  182. end
  183.  
  184.  
  185.  
  186. local hunger_alpha = 0
  187.  
  188.  
  189. -- local entVehicle = IsValid(LocalPlayer()) and LocalPlayer():GetVehicle() or Entity(0);
  190.  
  191.  
  192.  
  193. -- local intSpeed, strMPH
  194.  
  195.  
  196.  
  197. -- intSpeed = math.floor( entVehicle:GetVelocity():Length() * 0.09144 )
  198.  
  199.  
  200.  
  201. -- strMPH = 'KMH'
  202. -- if intSpeed < 10 then intSpeed = '0' .. intSpeed end
  203.  
  204.  
  205. Row ( -- Character info
  206.  
  207.  
  208.  
  209. function() -- Life
  210. yield(BeautyText( Epi_life.. ": ", "abs_hud", "abs_hud_shadow", x, y, color_white, ALIGN_LEFT, ALIGN_TOP))
  211.  
  212. yield(WideBar(LocalPlayer():Health(), LocalPlayer():GetMaxHealth(), 100, HSVToColor(math.Clamp(LocalPlayer():Health(), 0, LocalPlayer():GetMaxHealth()) / LocalPlayer():GetMaxHealth() * 120, 1, 1), x, y))
  213. end,
  214.  
  215. function() -- Armor
  216. if LocalPlayer():Armor() > 0 then
  217. yield(BeautyText(Epi_armor..": ", "abs_hud", "abs_hud_shadow", x, y, color_white, ALIGN_LEFT, ALIGN_TOP))
  218.  
  219. yield(WideBar(LocalPlayer():Armor(), 100, 100, HSVToColor(math.Clamp(LocalPlayer():Armor(), 0, 100) * 1.2, 1, 1), x, y))
  220.  
  221.  
  222. end
  223.  
  224.  
  225.  
  226.  
  227. end,
  228. function() -- Hunger
  229. local energy = LocalPlayer():getDarkRPVar("Energy") or 0
  230. if energy > 0 then
  231. local a = 1 - math.max(0, (hunger_alpha + 1) - RealTime())
  232. yield(BeautyText(Epi_hunger..": ", "abs_hud", "abs_hud_shadow", x, y, Color(255 * a, 255, 255 * a), ALIGN_LEFT, ALIGN_TOP))
  233. yield(WideBar((energy), 100, 100, HSVToColor(energy * 1.2, 1, 1), x, y))
  234. else
  235. yield(BeautyText(Epi_famished, "abs_hud", "abs_hud_shadow", x, y, RealTime()%0.3 < 0.15 and Color(255, 0, 0) or color_black, ALIGN_LEFT, ALIGN_TOP))
  236. end
  237. end
  238. or nil
  239. )
  240.  
  241. local money_last = 0
  242. local money_alpha = 0
  243. local money_alpha_positive = true
  244. local color_blend = Color(64, 128, 64)
  245.  
  246. local function getmoney()
  247. if LocalPlayer():GetNWBool("fun_money111") then
  248. return 0
  249. else
  250. return LocalPlayer():getDarkRPVar("money", 0)
  251. end
  252. end
  253. Row ( -- Wallet
  254. function()
  255. yield(BeautyText(LocalPlayer():getDarkRPVar("job") or "", "abs_hud", "abs_hud_shadow", x, y, team.GetColor(LocalPlayer():Team()), ALIGN_LEFT, ALIGN_TOP))
  256.  
  257. space()
  258.  
  259. if money_last ~= getmoney() then
  260. color_blend.r = 0
  261. color_blend.g = 255
  262. color_blend.b = 0
  263. money_last = getmoney()
  264. end
  265.  
  266. local dt = FrameTime() * 0.5
  267. color_blend.r = Lerp(dt, color_blend.r, 0)
  268. color_blend.g = Lerp(dt, color_blend.g, 128)
  269. color_blend.b = Lerp(dt, color_blend.b, 255)
  270.  
  271. yield(BeautyText(DarkRP.formatMoney(getmoney()), "abs_hud", "abs_hud_shadow", x, y, color_blend, ALIGN_LEFT, ALIGN_TOP))
  272. end
  273. )
  274.  
  275. Row ( -- Time
  276. function()
  277.  
  278. yield(BeautyText(texthrmin, "abs_hud_time", "abs_hud_time_shadow", x, y, Color(150, 200, 255), ALIGN_LEFT, ALIGN_TOP))
  279.  
  280. end,
  281. function()
  282.  
  283. yield(BeautyText(daytimeday, "abs_hud_time", "abs_hud_time_shadow", x, y, Color(150, 200, 255), ALIGN_LEFT, ALIGN_TOP))
  284. end
  285.  
  286.  
  287. )
  288. -- Row (
  289. -- function()
  290. -- if LocalPlayer():InVehicle() then
  291.  
  292.  
  293. -- yield(BeautyText(intSpeed.." " ..strMPH , "abs_hud_time", "abs_hud_time_shadow", x, y, Color(150, 200, 255), ALIGN_LEFT, ALIGN_TOP))
  294.  
  295. -- end
  296. -- )
  297.  
  298. Row ( -- Wanted
  299. function()
  300. if LocalPlayer():getDarkRPVar("wanted") then
  301. local sin = math.sin(RealTime() * 8)
  302. local flash = HSVToColor(sin > 0 and 0 or 240, math.abs(sin), 1)
  303.  
  304. yield(BeautyText(Epi_wanted..": " .. LocalPlayer():getDarkRPVar("wantedReason"), "abs_hud", "abs_hud_shadow", x, y, flash, ALIGN_LEFT, ALIGN_TOP))
  305. end
  306. end
  307. )
  308.  
  309.  
  310.  
  311. Row ( -- Arrested
  312. function()
  313. if LocalPlayer():isArrested() then
  314. local arrest = LocalPlayer():getDarkRPVar("ArrestReason")
  315. yield(BeautyText(Epi_arrest, "abs_hud", "abs_hud_shadow", x, y, color_white, ALIGN_LEFT, ALIGN_TOP))
  316. end
  317. end
  318. )
  319.  
  320.  
  321. Row ( -- License
  322. function()
  323. if LocalPlayer():getDarkRPVar("HasGunlicense") then -- cps supposed to have license amirite?? write a workaround
  324. yield(BeautyText(Epi_license, "abs_hud", "abs_hud_shadow", x, y, color_white, ALIGHN_LEFT, ALIGN_TOP))
  325. end
  326. end
  327. )
  328.  
  329. Row ( -- Lockdown
  330. function()
  331. if GetGlobalBool("LockDown1") then
  332. local cin = (math.sin(CurTime()) + 1) / 2
  333. yield(BeautyText(Epi_lockdown..": " .. GetGlobalString("ReasonLockDown"), "abs_hud", "abs_hud_shadow", x, y, Color(cin * 255, 0, 255 - (cin * 255)), 0, ALIGN_TOP))
  334. end
  335. end
  336. )
  337.  
  338. hook.Add("HUDPaint", "DarkRP_Mod_HUDPaint", function()
  339. if hook.Run("HUDShouldDraw", "Noiwex HUD") == false then
  340. return
  341. end
  342.  
  343. local offy, offx, space_width = ScrH() - 8, 8, 8
  344.  
  345. x, y = offx, offy
  346.  
  347. for _, row in pairs(hud) do
  348. for _, fn in pairs(row) do
  349. seen_anything = false
  350. xpcall(fn, Error)
  351. if seen_anything then
  352. space()
  353. end
  354. end
  355. offy = offy - i_am_the_greatest
  356. i_am_the_greatest = 0
  357. y = offy
  358. x = offx
  359. end
  360. end)
  361.  
  362. local insuff_ammo1, insuff_ammo2 = 1, 1
  363. hook.Add("HUDPaint", "DarkRP_Mod_HUDPaint_Ammo", function()
  364. if hook.Run("HUDShouldDraw", "Epi HUD Ammo") == false then
  365. return
  366. end
  367.  
  368. local wep = LocalPlayer():GetActiveWeapon()
  369.  
  370. if not IsValid(wep) or wep:GetPrimaryAmmoType() < 0 then
  371. return
  372. end
  373.  
  374. local ammo1 = wep:Clip1()
  375. local ammo2 = LocalPlayer():GetAmmoCount(wep:GetPrimaryAmmoType())
  376.  
  377. if ammo1 < 0 then
  378. ammo1 = nil
  379. end
  380.  
  381. local offy, offx, space_width = ScrH() - 8, ScrW() - 256 - 24, 8
  382.  
  383. if ammo1 == 0 then
  384. insuff_ammo1 = math.max(insuff_ammo1 - FrameTime(), 0)
  385. else
  386. insuff_ammo1 = math.min(insuff_ammo1 + FrameTime(), 1)
  387. end
  388.  
  389. if ammo2 == 0 then
  390. insuff_ammo2 = math.max(insuff_ammo2 - FrameTime(), 0)
  391. else
  392. insuff_ammo2 = math.min(insuff_ammo2 + FrameTime(), 1)
  393. end
  394.  
  395. offx = offx - BeautyText((ammo1 and " / " or "") .. ammo2, "abs_hud_ammo", "abs_hud_ammo_shadow", offx, offy, Color(255, insuff_ammo2 * 255, insuff_ammo2 * 255), ALIGN_RIGHT, ALIGN_TOP)
  396. offx = offx - BeautyText(ammo1 or "", "abs_hud_time", "abs_hud_time_shadow", offx, offy - 3, Color(255, insuff_ammo1 * 255, insuff_ammo1 * 255), ALIGN_RIGHT, ALIGN_TOP)
  397. end)
  398.  
  399. usermessage.Hook("AteFoodIcon", function()
  400. hunger_alpha = RealTime()
  401. end)
  402.  
  403.  
  404. local function DisplayNotify(msg)
  405.  
  406. local txt = msg:ReadString()
  407.  
  408. GAMEMODE:AddNotify( txt, msg:ReadShort(), msg:ReadLong() )
  409.  
  410. surface.PlaySound( 'buttons/lightswitch2.wav' )
  411.  
  412.  
  413.  
  414. MsgC( Color(255, 20, 20, 255), '[DarkRP] ', Color(200, 200, 200, 255), txt, '\n' )
  415.  
  416. end
  417.  
  418. usermessage.Hook( '_Notify', DisplayNotify )
  419.  
  420.  
  421.  
  422.  
  423.  
  424. hook.Add( "PlayerCanHearPlayersVoice", "GServ:Player:Speak", function( listener, talker )
  425.  
  426. if listener:GetPos():Distance( talker:GetPos() ) > 750 then return false end
  427.  
  428.  
  429.  
  430. local tr = util.TraceLine({
  431.  
  432. start = talker:GetPos() + Vector( 0, 0, 50 ),
  433.  
  434. endpos = listener:GetPos() + Vector( 0, 0, 50 ),
  435.  
  436. mask = 131083,
  437.  
  438. })
  439.  
  440.  
  441.  
  442. if tr.HitWorld then
  443.  
  444. return false
  445.  
  446. else
  447.  
  448. return true
  449.  
  450. end
  451.  
  452. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement