Guest User

Untitled

a guest
Oct 12th, 2013
92
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local tblFonts = { }
  2. tblFonts["DebugFixed"] = {
  3. font = "Courier New",
  4. size = 10,
  5. weight = 500,
  6. antialias = true,
  7. }
  8.  
  9. tblFonts["DebugFixedSmall"] = {
  10. font = "Courier New",
  11. size = 7,
  12. weight = 500,
  13. antialias = true,
  14. }
  15.  
  16. tblFonts["DefaultFixedOutline"] = {
  17. font = "Lucida Console",
  18. size = 10,
  19. weight = 0,
  20. outline = true,
  21. }
  22.  
  23. tblFonts["MenuItem"] = {
  24. font = "Tahoma",
  25. size = 12,
  26. weight = 500,
  27. }
  28.  
  29. tblFonts["Default"] = {
  30. font = "Tahoma",
  31. size = 13,
  32. weight = 500,
  33. }
  34.  
  35. tblFonts["TabLarge"] = {
  36. font = "Tahoma",
  37. size = 13,
  38. weight = 700,
  39. shadow = true,
  40. }
  41.  
  42. tblFonts["DefaultBold"] = {
  43. font = "Tahoma",
  44. size = 13,
  45. weight = 1000,
  46. }
  47.  
  48. tblFonts["DefaultUnderline"] = {
  49. font = "Tahoma",
  50. size = 13,
  51. weight = 500,
  52. underline = true,
  53. }
  54.  
  55. tblFonts["DefaultSmall"] = {
  56. font = "Tahoma",
  57. size = 1,
  58. weight = 0,
  59. }
  60.  
  61. tblFonts["DefaultSmallDropShadow"] = {
  62. font = "Tahoma",
  63. size = 11,
  64. weight = 0,
  65. shadow = true,
  66. }
  67.  
  68. tblFonts["DefaultVerySmall"] = {
  69. font = "Tahoma",
  70. size = 10,
  71. weight = 0,
  72. }
  73.  
  74. tblFonts["DefaultLarge"] = {
  75. font = "Tahoma",
  76. size = 16,
  77. weight = 0,
  78. }
  79.  
  80. tblFonts["UiBold"] = {
  81. font = "Tahoma",
  82. size = 12,
  83. weight = 1000,
  84. }
  85.  
  86. tblFonts["MenuLarge"] = {
  87. font = "Verdana",
  88. size = 15,
  89. weight = 600,
  90. antialias = true,
  91. }
  92.  
  93. tblFonts["ConsoleText"] = {
  94. font = "Lucida Console",
  95. size = 10,
  96. weight = 500,
  97. }
  98.  
  99. tblFonts["Marlett"] = {
  100. font = "Marlett",
  101. size = 13,
  102. weight = 0,
  103. symbol = true,
  104. }
  105.  
  106. tblFonts["Trebuchet24"] = {
  107. font = "Trebuchet MS",
  108. size = 24,
  109. weight = 900,
  110. }
  111.  
  112. tblFonts["Trebuchet22"] = {
  113. font = "Trebuchet MS",
  114. size = 22,
  115. weight = 900,
  116. }
  117.  
  118. tblFonts["Trebuchet20"] = {
  119. font = "Trebuchet MS",
  120. size = 20,
  121. weight = 900,
  122. }
  123.  
  124. tblFonts["Trebuchet19"] = {
  125. font = "Trebuchet MS",
  126. size = 19,
  127. weight = 900,
  128. }
  129.  
  130. tblFonts["Trebuchet18"] = {
  131. font = "Trebuchet MS",
  132. size = 18,
  133. weight = 900,
  134. }
  135.  
  136. tblFonts["HUDNumber"] = {
  137. font = "Trebuchet MS",
  138. size = 40,
  139. weight = 900,
  140. }
  141.  
  142. tblFonts["HUDNumber1"] = {
  143. font = "Trebuchet MS",
  144. size = 41,
  145. weight = 900,
  146. }
  147.  
  148. tblFonts["HUDNumber2"] = {
  149. font = "Trebuchet MS",
  150. size = 42,
  151. weight = 900,
  152. }
  153.  
  154. tblFonts["HUDNumber3"] = {
  155. font = "Trebuchet MS",
  156. size = 43,
  157. weight = 900,
  158. }
  159.  
  160. tblFonts["HUDNumber4"] = {
  161. font = "Trebuchet MS",
  162. size = 44,
  163. weight = 900,
  164. }
  165.  
  166. tblFonts["HUDNumber5"] = {
  167. font = "Trebuchet MS",
  168. size = 45,
  169. weight = 900,
  170. }
  171.  
  172. tblFonts["HudHintTextLarge"] = {
  173. font = "Verdana",
  174. size = 14,
  175. weight = 1000,
  176. antialias = true,
  177. additive = true,
  178. }
  179.  
  180. tblFonts["HudHintTextSmall"] = {
  181. font = "Verdana",
  182. size = 11,
  183. weight = 0,
  184. antialias = true,
  185. additive = true,
  186. }
  187.  
  188. tblFonts["CenterPrintText"] = {
  189. font = "Trebuchet MS",
  190. size = 18,
  191. weight = 900,
  192. antialias = true,
  193. additive = true,
  194. }
  195.  
  196. tblFonts["DefaultFixed"] = {
  197. font = "Lucida Console",
  198. size = 10,
  199. weight = 0,
  200. }
  201.  
  202. tblFonts["DefaultFixedDropShadow"] = {
  203. font = "Lucida Console",
  204. size = 10,
  205. weight = 0,
  206. shadow = true,
  207. }
  208.  
  209. tblFonts["CloseCaption_Normal"] = {
  210. font = "Tahoma",
  211. size = 16,
  212. weight = 500,
  213. }
  214.  
  215. tblFonts["CloseCaption_Italic"] = {
  216. font = "Tahoma",
  217. size = 16,
  218. weight = 500,
  219. italic = true,
  220. }
  221.  
  222. tblFonts["CloseCaption_Bold"] = {
  223. font = "Tahoma",
  224. size = 16,
  225. weight = 900,
  226. }
  227.  
  228. tblFonts["CloseCaption_BoldItalic"] = {
  229. font = "Tahoma",
  230. size = 16,
  231. weight = 900,
  232. italic = true,
  233. }
  234.  
  235. tblFonts["TargetID"] = {
  236. font = "Trebuchet MS",
  237. size = 22,
  238. weight = 900,
  239. antialias = true,
  240. }
  241.  
  242. tblFonts["TargetIDSmall"] = {
  243. font = "Trebuchet MS",
  244. size = 18,
  245. weight = 900,
  246. antialias = true,
  247. }
  248.  
  249. tblFonts["BudgetLabel"] = {
  250. font = "Courier New",
  251. size = 14,
  252. weight = 400,
  253. outline = true,
  254. }
  255.  
  256.  
  257. for k,v in SortedPairs( tblFonts ) do
  258. surface.CreateFont( k, tblFonts[k] );
  259.  
  260. --print( "Added font '"..k.."'" );
  261. end
  262.  
  263. local nodrawWeps = {"CHudDeathNotice", "CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo", "CHudCrosshair", "CHudDamageIndicator"}
  264. function JB:HUDShouldDraw(name)
  265. if table.HasValue(nodrawWeps, name) then
  266. return false;
  267. end
  268. return true;
  269. end
  270.  
  271.  
  272. local clamp,sin,cos,rad =math.Clamp,math.sin,math.cos,math.rad;
  273. local deg2rad = math.pi / 180;
  274. local screenpos = Vector( 90, 90, 0 );
  275. local portraitpos = screenpos;
  276. local displayportrait = false;
  277. local pos;
  278. local target;
  279. local ang;
  280. local newpos;
  281. local fov = 85;
  282. local CharacterPortrait;
  283. local h_old = 0;
  284. local h_color = Color(200,0,0);
  285. local x_id = 135;
  286. local y_id = 40;
  287. local x_info = x_id+15;
  288. local y_info = y_id+24;
  289. local x_team,y_team = x_info,y_info + 2;
  290. -- Poly stuff...
  291. local circle = {}
  292. for i=1,15 do
  293. circle[i] = {x = portraitpos.x + cos(rad(i*360)/15)*60,y = portraitpos.y + sin(rad(i*360)/15)*60};
  294. end
  295.  
  296. local idpanel = {{x=x_id,y=y_id},{x=x_id+170,y=y_id},{x=x_id+180,y=y_id+10},{x=x_id+180,y=y_id+23},{x=x_id+15,y=y_id+23}}
  297. local idpanel_outline = {{x=x_id-1,y=y_id-1},{x=x_id+170.5,y=y_id-1},{x=x_id+181,y=y_id+9.5},{x=x_id+181,y=y_id+24},{x=x_id+15-2,y=y_id+24}}
  298. local teampanel_outline = {{x=x_team-1,y=y_team-1},{x=x_team+140,y=y_team},{x=x_team+140,y=y_team+10.5},{x=x_team+130,y=y_team+21},{x=x_team,y=y_team+21}}
  299.  
  300. local ammopanel = {{x=ScrW()-160,y=y_id},{x=ScrW()-40,y=y_id},{x=ScrW()-40,y=y_id+23},{x=ScrW()-170,y=y_id+23},{x=ScrW()-170,y=y_id+10}}
  301. local ammopanel_outline = {{x=ScrW()-160,y=y_id-1},{x=ScrW()-39,y=y_id-1},{x=ScrW()-39,y=y_id+24},{x=ScrW()-171,y=y_id+24},{x=ScrW()-171,y=y_id+10}}
  302.  
  303. local av = {{x=169,y=89},{x=x_id+180,y=89},{x=x_id+180,y=106},{x=x_id+163,y=123},{x=169,y=123}}
  304. local av_outline = {{x=168,y=88},{x=x_id+181,y=88},{x=x_id+181,y=106},{x=x_id+163,y=124},{x=168,y=124}}
  305.  
  306. local tri = {{x=ScrW()/2,y=ScrH()/2},{x=ScrW()/2+18,y=ScrH()/2-9},{x=ScrW()/2+18,y=ScrH()/2+9}}
  307. local tri_outline = {{x=ScrW()/2-1,y=ScrH()/2},{x=ScrW()/2+19,y=ScrH()/2-10},{x=ScrW()/2+19,y=ScrH()/2+10}}
  308. local function CreateCharPortrait()
  309. local m;
  310. if LocalPlayer() and LocalPlayer():IsValid() then
  311. m = LocalPlayer():GetModel() or "models/Humans/Group02/Male_04.mdl";
  312. else
  313. m = "models/Humans/Group02/Male_04.mdl"
  314. end
  315.  
  316. if CharacterPortrait and CharacterPortrait:IsValid() then
  317. CharacterPortrait:Remove();
  318. end
  319.  
  320. CharacterPortrait = ClientsideModel(m, RENDERGROUP_OPAQUE);
  321. CharacterPortrait:SetNoDraw( true )
  322. local bone = CharacterPortrait:LookupBone("ValveBiped.Bip01_Head1");
  323.  
  324. if bone then
  325. pos, ang = CharacterPortrait:GetBonePosition( bone )
  326. local target = CharacterPortrait:GetPos()+Vector(0,0,66)
  327. local newpos = ang:Forward() * 2 + ang:Right() * 10 + ang:Up() * 13
  328. pos = target + newpos
  329. ang = (target-pos):Angle()
  330. fov = 85
  331. else
  332. CharacterPortrait:SetAngles( Angle( 0, 180, 0 ) )
  333. local mn, mx = CharacterPortrait:GetRenderBounds()
  334. local size = 0
  335. size = math.max( size, math.abs(mn.x) + math.abs(mx.x) )
  336. size = math.max( size, math.abs(mn.y) + math.abs(mx.y) )
  337. size = math.max( size, math.abs(mn.z) + math.abs(mx.z) )
  338. size = size * (1 - ( size / 900 ))
  339. ang = Angle( 25, 40, 0 )
  340. pos = CharacterPortrait:GetPos() + ang:Forward() * size * -15 + (mn + mx) * 0.5
  341. fov = 10
  342. end
  343. end
  344. CreateCharPortrait()
  345. timer.Create( "RefreshPortrait", 5, 0, function()
  346. CreateCharPortrait()
  347. end)
  348.  
  349. local function DisplayCharPortrait( bool )
  350. if bool then
  351. portraitpos = Vector( Lerp( 0.2, portraitpos.x, screenpos.x ), screenpos.y, screenpos.z )
  352. for i=1,15 do
  353. circle[i] = {x = portraitpos.x + cos(rad(i*360)/15)*60,y = portraitpos.y + sin(rad(i*360)/15)*60}
  354. end
  355. displayportrait = true
  356. else
  357. portraitpos = Vector( Lerp( 0.2, portraitpos.x, -500 ), screenpos.y, screenpos.z )
  358. if portraitpos.x < 0 then
  359. displayportrait = false
  360. end
  361. end
  362. end
  363.  
  364.  
  365. function DrawPartialCircle( x, y, radius, linewidth, startangle, endangle, aa )
  366. -- Thanks for getting me started on how to do this python1320 <3
  367. aa = aa or 1;
  368. startangle = clamp( startangle or 0, 0, 360 );
  369. endangle = clamp( endangle or 360, 0, 360 );
  370.  
  371. if endangle < startangle then
  372. local temp = endangle;
  373. endangle = startangle;
  374. startangle = temp;
  375. end
  376.  
  377. for i=startangle, endangle, aa do
  378. local _i = i * deg2rad;
  379. surface.DrawTexturedRectRotated(cos( _i ) * (radius - linewidth) + x,sin( _i ) * (radius - linewidth) + y, linewidth, aa*2, -i );
  380. end
  381. end
  382.  
  383. hook.Add( "Think", "JBDisplayPortrait",function()
  384. local localplayer = LocalPlayer()
  385. if (localplayer:Team() ~= TEAM_PRISONER and localplayer:Team() ~= TEAM_GUARD) then return end
  386.  
  387. DisplayCharPortrait( true );
  388. end)
  389.  
  390. local wAv;
  391. local awP;
  392.  
  393. local count = 0;
  394. local count_start = CurTime();
  395. local count_g = 200;
  396. local color_r = 0
  397. local count_cir = 360
  398. local count_title = "No title set."
  399. function JB:HUDStartTimer(t,n)
  400. count = t;
  401. count_start = CurTime();
  402. count_g = 200;
  403. color_r = 0
  404. count_cir = 360
  405. count_title = n;
  406. end
  407. hook.Add("HUDPaint","JBCircleHealthDisplay", function()
  408. local localplayer = LocalPlayer();
  409. local w = JB.wardenPlayer;
  410. if not localplayer or not localplayer:IsValid() or (localplayer:Team() ~= TEAM_PRISONER and localplayer:Team() ~= TEAM_GUARD) then
  411. if wAv and wAv:IsValid() then
  412. wAv:Remove();
  413. end
  414. return
  415. end
  416.  
  417. if (not wAv or not wAv:IsValid()) and w and w:IsValid() then
  418. wAv = vgui.Create("AvatarImage", frame)
  419. wAv:SetPos(170,90)
  420. wAv:SetSize(32, 32)
  421. wAv:SetPlayer(w, 32 )
  422. awP = w;
  423. elseif wAv and wAv:IsValid() and (not w or not w:IsValid()) then
  424. wAv:Remove();
  425. end
  426.  
  427. if awP ~= w and wAv and wAv:IsValid() and w and w:IsValid() then
  428. wAv:SetPlayer(w,32)
  429. awP = w;
  430. end
  431.  
  432.  
  433. surface.SetTexture(surface.GetTextureID("vgui/background_texture"));
  434. surface.SetDrawColor(0,0,0,255);
  435. if w and w:IsValid() then
  436. surface.DrawPoly(av_outline);
  437. end
  438. surface.DrawPoly(idpanel_outline);
  439. surface.DrawPoly(ammopanel_outline);
  440. surface.DrawRect(ScrW()-171,y_id+23,132,18)
  441. surface.DrawRect(x_info, y_info, 166,17);
  442. surface.DrawRect(x_id+183, y_id+10, 4,31);
  443. surface.DrawRect(x_id+189, y_id+10, 4,31);
  444. surface.DrawRect(ScrW()-170-6, y_id+10, 4,31);
  445. surface.DrawRect(ScrW()-170-6-6, y_id+10, 4,31);
  446.  
  447. --surfavce.DrawPoly(teampanel_outline);
  448.  
  449. surface.SetDrawColor(200,200,200,200);
  450. if w and w:IsValid() then
  451. surface.DrawPoly(av)
  452. local t = "Warden"
  453. if not w:Alive() then
  454. t = t.." (dead)"
  455. end
  456. draw.SimpleText(t, "DefaultBold", 205,90,Color(0,0,0),0,0);
  457.  
  458. draw.SimpleText(JB.wardenPlayer:Nick(), "Default", 205,105,Color(0,0,0),0,0);
  459. end
  460. surface.DrawPoly(idpanel);
  461. draw.SimpleText(localplayer:Nick(), "TargetID", 160,41,Color(0,0,0),0,0);
  462. surface.DrawPoly(ammopanel);
  463.  
  464.  
  465.  
  466. surface.SetDrawColor( 230,230,230,200 );
  467.  
  468. surface.DrawRect(ScrW()-170,y_id+24,130,16)
  469.  
  470. surface.DrawRect(x_info, y_info, 165,16);
  471. if localplayer:Team() == TEAM_GUARD then
  472. local s= "Guard";
  473. if JB.wardenPlayer and JB.wardenPlayer == localplayer then
  474. s= "Warden";
  475. end
  476. draw.SimpleText(s, "Default", x_info+12, y_info+1,Color(0,0,0));
  477. elseif localplayer:Team() == TEAM_PRISONER then
  478. local c = "Loading...";
  479. if localplayer.character then
  480. c = localplayer.character.name.." \""..localplayer.character.nick.."\" "..localplayer.character.surname;
  481. end
  482. draw.SimpleText(c, "Default", x_info+12, y_info+1,Color(0,0,0));
  483. end
  484.  
  485. local ammo = "none";
  486. if LocalPlayer():GetActiveWeapon() and LocalPlayer():GetActiveWeapon().Primary and LocalPlayer():GetActiveWeapon().Primary.ClipSize and LocalPlayer():GetActiveWeapon():Clip1() >= 0 then
  487. ammo = LocalPlayer():GetActiveWeapon():Clip1().."/"..LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon().Ammo or "none");
  488. end
  489. local credits = LocalPlayer():GetCredits() or 0
  490. draw.SimpleText(credits, "Default", ScrW()-50, y_info+1,Color(0,0,0),2);
  491.  
  492. draw.SimpleText("Credits:", "DefaultBold", ScrW()-160, y_info+1,Color(0,0,0));
  493.  
  494. draw.SimpleText(JB:RoundTimeToString(), "TargetID", ScrW()-50, 41,Color(0,0,0),2);
  495.  
  496. surface.SetDrawColor( 100,100,100, 150 );
  497.  
  498.  
  499. render.ClearStencil();
  500. render.SetStencilEnable( true );
  501. render.SetStencilFailOperation( STENCILOPERATION_KEEP );
  502. render.SetStencilZFailOperation( STENCILOPERATION_REPLACE );
  503. render.SetStencilPassOperation( STENCILOPERATION_REPLACE );
  504. render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_ALWAYS );
  505. render.SetStencilReferenceValue( 1 );
  506. if displayportrait then
  507. surface.SetDrawColor( 0,0,0, 155 );
  508. surface.DrawPoly( circle );
  509. end
  510. render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL );
  511. render.SetStencilPassOperation( STENCILOPERATION_REPLACE );
  512. cam.Start3D( pos, ang, fov, portraitpos.x-80,portraitpos.y-80 , 150 , 150 );
  513. cam.IgnoreZ( true );
  514. render.SuppressEngineLighting( true );
  515. render.SetLightingOrigin( CharacterPortrait:GetPos() );
  516. render.ResetModelLighting( 1,1,1 );
  517. render.SetColorModulation( 1,1,1 );
  518. render.SetBlend( 1 );
  519. render.SetLightingOrigin( CharacterPortrait:GetPos() );
  520. CharacterPortrait:DrawModel();
  521. render.SuppressEngineLighting( false );
  522. cam.IgnoreZ( false );
  523. cam.End3D();
  524. render.SetStencilEnable( false );
  525.  
  526. if h_old > localplayer:Health() then
  527. h_old = h_old-1;
  528. elseif h_old < localplayer:Health() then
  529. h_old = h_old+1;
  530. end
  531.  
  532. local add = 0
  533. if h_old < 30 then
  534. add = 50*math.sin(CurTime()*4);
  535. end
  536.  
  537.  
  538.  
  539.  
  540. -- Timers.
  541. local n = (count_start+count) - CurTime();
  542.  
  543. if n < 0 then return end
  544.  
  545. count_g = (n/count)*200;
  546. count_r = (1-(n/count))*200
  547.  
  548. count_cir = (n/count)*360
  549.  
  550. surface.SetDrawColor(Color(10,10,10,255));
  551. DrawPartialCircle( ScrW()/2-37, ScrH()/2, 60 ,12, 0, 360, 2 );
  552. surface.SetDrawColor(Color(count_r,count_g,0,255));
  553. DrawPartialCircle( ScrW()/2-37, ScrH()/2, 59 ,11, 0, count_cir, 2 );
  554.  
  555. surface.SetDrawColor(Color(0,0,0,255));
  556. surface.DrawPoly(tri_outline);
  557. surface.SetDrawColor(Color(200,200,200,255));
  558. surface.DrawPoly(tri);
  559.  
  560. draw.SimpleTextOutlined(math.Round(n), "HUDNumber5", ScrW()/2-37, ScrH()/2,Color(255,255,255),1,1,1,Color(0,0,0));
  561. draw.SimpleTextOutlined(count_title, "TargetID", ScrW()/2+25, ScrH()/2,Color(255,255,255),0,1,1,Color(0,0,0));
  562.  
  563. end);
  564.  
  565. /*
  566. Eagle Predator Heads-Up Display
  567. Version 1.3
  568. © Night-Eagle 2007
  569. gmail sedhdi
  570.  
  571. Console commands:
  572. ehud_unit
  573. MPH or KM/H
  574. */
  575.  
  576.  
  577.  
  578. ephud = {}
  579. ephud.maxammo = {}
  580. ephud.shownames = true
  581. ephud.lastang = Angle(0,0,0)
  582. ephud.lasthealth = 0
  583. ephud.lastflicker = 1
  584. ephud.flicker = 1
  585. ephud.flickerend = CurTime()
  586. ephud.hudlag = 1
  587. ephud.white = surface.GetTextureID("humanhead") //vgui/white
  588. ephud.white = surface.GetTextureID("vgui/white")
  589. ephud.quarter256h = surface.GetTextureID("client/quarter256h")
  590.  
  591. for i=12, 64 do
  592. surface.CreateFont("lcd"..i, {name = "lcd"..i, size = i, weight = 2, additive = false, antialias = true})
  593. end
  594. ephud.font12 = "lcd12"
  595. ephud.font24 = "lcd24"
  596. ephud.font36 = "lcd36"
  597.  
  598. ephud.usrskipright = false
  599.  
  600. function ephud.rect(x,y,w,h,orx,ory,u1,v1,u2,v2)
  601. local ox = orx or ScrW()*.5
  602. local oy = ory or ScrH()*.5
  603. u1 = u1 or 0
  604. u2 = u2 or 1
  605. v1 = v1 or 0
  606. v2 = v2 or 1
  607.  
  608. //surface.SetTexture(tex)
  609. //surface.SetDrawColor(0,0,255,150*hf.a)
  610.  
  611. local points = {
  612. {
  613. x=x,
  614. y=y,
  615. u=u1,
  616. v=v1,
  617. },
  618. {
  619. x=x+w,
  620. y=y,
  621. u=u2,
  622. v=v1,
  623. },
  624. {
  625. x=x+w,
  626. y=y+h,
  627. u=u2,
  628. v=v2,
  629. },
  630. {
  631. x=x,
  632. y=y+h,
  633. u=u1,
  634. v=v2,
  635. },
  636. }
  637. for k,v in ipairs(points) do
  638. v.x = (v.x-ox)
  639. v.y = (v.y-oy)
  640.  
  641. v.x = v.x*(1+math.sin(v.y/(ScrW()))^2)
  642. v.y = v.y*(1+math.sin(v.x/(ScrH()))^2)
  643.  
  644. v.x = v.x+ox
  645. v.y = v.y+oy
  646. end
  647.  
  648. surface.DrawPoly(points)
  649. end
  650.  
  651. function ephud.DrawRect(x,y,w,h,uix,uiy,ow,oh)
  652. ix = uix - 1
  653. iy = uiy - 1
  654. ixt = ix
  655. iyt = iy
  656. local dx = w/uix
  657. local dy = h/uiy
  658. for ix = 0,ix do
  659. for iy = 0,iy do
  660. ephud.rect(x+ix*dx,y+iy*dy,dx,dy,ow,oh,ix/math.max(ixt,1),iy/math.max(iyt,1))
  661. end
  662. end
  663. end
  664.  
  665. function ephud.DrawText(ox,oy,text,font,x,y,color,xalign)
  666. ox = ox or ScrW()*.5
  667. oy = oy or ScrH()*.5
  668.  
  669. x = x-ox
  670. y = y-oy
  671.  
  672. x = x*(1+math.sin(y/(ScrW()))^2)
  673. y = y*(1+math.sin(x/(ScrH()))^2)
  674.  
  675. x = x+ox
  676. y = y+oy
  677.  
  678. draw.DrawText(text,font,x,y,color,xalign)
  679. end
  680.  
  681. function ephud.load()
  682. function ephud.draw()
  683. if not LocalPlayer() or not LocalPlayer():IsValid() or (LocalPlayer():Team() ~= TEAM_PRISONER and LocalPlayer():Team() ~= TEAM_GUARD) then
  684. return
  685. end
  686. //Start get vars
  687. if not (LocalPlayer():IsValid() or LocalPlayer():Alive()) then return end
  688. //EHUD Compat
  689.  
  690. local SWEP = LocalPlayer():GetActiveWeapon()
  691. local val = {}
  692. val.crx = .5*ScrW()
  693. val.cry = .5*ScrH()
  694. if SWEP:IsValid() then
  695. val.clip1type = SWEP:GetPrimaryAmmoType() or ""
  696. val.clip1 = tonumber(SWEP:Clip1()) or 0
  697. val.clip1left = LocalPlayer():GetAmmoCount(val.clip1type)
  698. val.clip2type = SWEP:GetSecondaryAmmoType() or ""
  699. val.clip2 = tonumber(SWEP:Clip2()) or 0
  700. val.clip2left = LocalPlayer():GetAmmoCount(val.clip2type)
  701.  
  702. //LEGACY, REMOVE
  703. if type(SWEP:GetTable().mode) == "string" and type(SWEP:GetTable().data) == "table" and type(SWEP:GetTable().data[SWEP:GetTable().mode]) == "table" then
  704. val.firemode = SWEP:GetTable().data[SWEP:GetTable().mode].label or ""
  705. elseif SWEP:GetNWInt("firemode") then
  706. val.firemode = SWEP:GetNWInt("firemode")
  707. end
  708.  
  709. else
  710. val.clip1 = 0
  711. val.clip1left = 0
  712. val.clip2 = 0
  713. val.clip2left = 0
  714. val.firemode = ""
  715. end
  716. if not ephud.maxammo[SWEP] then
  717. ephud.maxammo[SWEP] = val.clip1
  718. elseif val.clip1 > ephud.maxammo[SWEP] then
  719. ephud.maxammo[SWEP] = val.clip1
  720. end
  721.  
  722. val.clip1max = tonumber(ephud.maxammo[SWEP]) or 1
  723.  
  724. if SWEP:IsValid() then
  725. for k,v in pairs(SWEP:GetTable().huddata or {}) do
  726. val[k] = v
  727. end
  728. end
  729.  
  730. //EHUD Compass
  731. // Compass
  732. val.pitch = LocalPlayer():EyeAngles()
  733. val.pitch, val.yaw, val.roll = LocalPlayer():EyeAngles().p, LocalPlayer():EyeAngles().y, LocalPlayer():EyeAngles().r
  734. // Vehicle + Compass
  735. if LocalPlayer():InVehicle() then
  736. local veh = LocalPlayer():GetVehicle()
  737. local vang = veh:EyeAngles()
  738. val.pitch, val.yaw, val.roll = val.pitch + vang.pitch, val.yaw + vang.yaw, val.roll + vang.roll
  739.  
  740. val.vehicle = 1
  741. val.vehiclespeed = veh:GetVelocity():Length()
  742. else
  743. val.vehicle = 0
  744. val.vehiclespeed = -1
  745. end
  746. // More compass
  747. val.compass = math.Round((val.yaw+90)/90)
  748. if val.compass == 1 or val.compass == -3 then
  749. val.compass = "E"
  750. elseif val.compass == 2 or val.compass == -2 then
  751. val.compass = "N"
  752. elseif val.compass == 3 or val.compass == -1 then
  753. val.compass = "W"
  754. else
  755. val.compass = "S"
  756. end
  757.  
  758. //Range finder
  759. do
  760. local trace = util.TraceLine({
  761. start = LocalPlayer():GetShootPos(),
  762. endpos = LocalPlayer():GetShootPos() + LocalPlayer():EyeAngles():Forward() * 40960,
  763. filter = LocalPlayer()
  764. })
  765. val.distance = trace.Fraction * 40960
  766. end
  767.  
  768. //Team color
  769. local tcol = team.GetColor(LocalPlayer():Team())
  770.  
  771.  
  772. //End get vars
  773. --
  774. //Draw the HUD and get more vars
  775.  
  776. //HUD lag
  777. local hl = {}
  778. hl.la = ephud.lastang
  779. hl.ca = LocalPlayer():EyeAngles()
  780.  
  781. if hl.la.y < -90 and hl.ca.y > 90 then
  782. hl.la.y = hl.la.y + 360
  783. elseif hl.la.y > 90 and hl.ca.y < -90 then
  784. hl.la.y = hl.la.y - 360
  785. end
  786.  
  787. hl.x = 0
  788. hl.y = 0
  789. hl.nm = 1/ephud.hudlag --Lag speed Default is 1/10, my new default is 1/5
  790. hl.na = Angle((hl.ca.p*hl.nm+hl.la.p)/(hl.nm+1),(hl.ca.y*hl.nm+hl.la.y)/(hl.nm+1), 0)
  791. ephud.lastang = hl.na
  792.  
  793. //HUD flicker
  794. local hf = {}
  795. hf.ch = LocalPlayer():Health()+LocalPlayer():Armor()
  796. hf.lh = ephud.lasthealth
  797. hf.a = ephud.lastflicker
  798.  
  799. if hf.ch < hf.lh then
  800. hf.a = math.Clamp(((hf.lh - hf.ch)/100)*(math.random(1,20)/10),0,1)
  801. ephud.flicker = hf.a
  802. if ephud.flickerend < CurTime() then
  803. ephud.flickerend = CurTime()+(hf.lh-hf.ch)/4
  804. else
  805. ephud.flickerend = ephud.flickerend+(hf.lh-hf.ch)/15
  806. end
  807. ephud.flickerend = math.Min(ephud.flickerend,CurTime()+2)
  808. elseif CurTime() < ephud.flickerend then
  809. hf.a = math.random(math.Max((1-ephud.flickerend+CurTime())*100,0),100)/100
  810. else
  811. hf.a = 1
  812. end
  813.  
  814. ephud.lasthealth = hf.ch
  815.  
  816. //Global
  817. surface.SetTexture(ephud.white)
  818. surface.SetDrawColor(0,0,255,150*hf.a)
  819. local yorigin = ScrH()*.5+64
  820.  
  821. //Left
  822. surface.SetTexture(ephud.white)
  823. surface.SetDrawColor(0,0,0,150*hf.a)
  824. ephud.DrawRect(hl.x + 64,hl.y + ScrH()-252,256,56,16,1,nil,yorigin)
  825.  
  826. local var
  827. local HP
  828. local imax
  829. //Health
  830. HP = math.Clamp(LocalPlayer():Health(),0,1000000000)
  831. var = math.Clamp(LocalPlayer():Health(),0,100)
  832. surface.SetDrawColor(255,0,0,150*hf.a)
  833. ephud.DrawRect(hl.x + 72,hl.y + ScrH()-244,240*var/100,16,16,1,nil,yorigin)
  834. surface.SetDrawColor(255,0,0,30*hf.a)
  835. ephud.DrawRect(hl.x + 72+(240*var/100),hl.y + ScrH()-244,240*(1-(var/100)),16,16,1,nil,yorigin)
  836. ephud.DrawText(nil,yorigin,HP,"lcd36",hl.x + 72,hl.y + ScrH()-252,Color(255,255,255,255*hf.a),0)
  837.  
  838. //Armor
  839. var = math.Clamp(LocalPlayer():Armor(),0,100)
  840. surface.SetDrawColor(135,206,255,150*hf.a)
  841. ephud.DrawRect(hl.x + 72,hl.y + ScrH()-220,240*var/100,16,16,1,nil,yorigin)
  842. surface.SetDrawColor(135,206,255,30*hf.a)
  843. ephud.DrawRect(hl.x + 72+(240*var/100),hl.y + ScrH()-220,240*(1-(var/100)),16,16,1,nil,yorigin)
  844. if LocalPlayer():Armor() and LocalPlayer():Armor() > 0 then
  845. ephud.DrawText(nil,yorigin,LocalPlayer():Armor(),"lcd36",hl.x + 72,hl.y + ScrH()-228,Color(255,255,255,255*hf.a),0)
  846. end
  847.  
  848.  
  849. //Right
  850. if not ephud.usrskipright then
  851. surface.SetTexture(ephud.white)
  852. surface.SetDrawColor(0,0,0,150*hf.a)
  853. ephud.DrawRect(hl.x + ScrW()-320,hl.y + ScrH()-252,256,56,16,1,nil,yorigin)
  854. end
  855.  
  856. //Secondary Ammo
  857.  
  858. ephud.usrskipright = true
  859.  
  860.  
  861.  
  862. if val.clip2left > 0 then
  863. surface.SetDrawColor(255,0,0,255*hf.a)
  864. ephud.DrawRect(hl.x + ScrW()-312+(232*(CurTime()*val.clip2left*.1%1)),hl.y + ScrH()-244,8,16,3,1,nil,yorigin)
  865. ephud.DrawText(nil,yorigin,val.clip2left,"lcd36",hl.x + ScrW()-306,hl.y + ScrH()-246.5,Color(255,255,255,255*hf.a),0)
  866. ephud.usrskipright = false
  867. end
  868.  
  869. //Offset: -6,+6
  870.  
  871. //Primary Ammo
  872. if val.clip1 > 0 then
  873. surface.SetDrawColor(30,200,30,150*hf.a)
  874. ephud.DrawRect(hl.x + ScrW()-312+(240*(1-val.clip1/val.clip1max)),hl.y + ScrH()-220,240*val.clip1/val.clip1max,16,16,1,nil,yorigin)
  875. end
  876. surface.SetDrawColor(0,255,0,30*hf.a)
  877. ephud.DrawRect(hl.x + ScrW()-312,hl.y + ScrH()-220,240*(1-(val.clip1/val.clip1max)),16,16,1,nil,yorigin)
  878. if val.clip1 >= 0 then
  879. ephud.DrawText(nil,yorigin,val.clip1,"lcd36",hl.x + ScrW()-74,hl.y + ScrH()-226,Color(255,255,255,255*hf.a),2)
  880. if val.clip1 == 0 then
  881. surface.SetDrawColor(30,200,30,255*hf.a)
  882. ephud.DrawRect(hl.x + ScrW()-312+(232*(CurTime()*50*.1%1)),hl.y + ScrH()-220,8,16,3,1,nil,yorigin)
  883. end
  884. if val.clip1left > 0 then
  885. --ephud.DrawText(nil,origin,val.clip1left,"lcd36",hl.x + ScrW()-270,hl.y + ScrH()-248,Color(255,255,255,255*hf.a),2)
  886. end
  887. ephud.usrskipright = false
  888. elseif val.clip1left > 0 then
  889. surface.SetDrawColor(30,200,30,255*hf.a)
  890. ephud.DrawRect(hl.x + ScrW()-312+(232*(CurTime()*val.clip1left*.1%1)),hl.y + ScrH()-220,8,16,3,1,nil,yorigin)
  891. ephud.DrawText(nil,yorigin,val.clip1left,"lcd36",hl.x + ScrW()-80,hl.y + ScrH()-226,Color(255,255,255,255*hf.a),2)
  892. ephud.usrskipright = false
  893. end
  894.  
  895.  
  896. end
  897.  
  898. hook.Add("HUDPaint","ephud.draw",ephud.draw)
  899.  
  900.  
  901. function ephud.HideHUD(name)
  902. if name == "CHudHealth" then return false end
  903. if name == "CHudBattery" then return false end
  904. if name == "CHudAmmo" then return false end
  905. if name == "CHudSecondaryAmmo" then return false end
  906. end
  907. hook.Add("HUDShouldDraw","ephud.HideHUD",ephud.HideHUD)
  908. end
  909. ephud.load()
RAW Paste Data