Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.97 KB | None | 0 0
  1. local function GetAmmoForCurrentWeapon( ply )
  2. if ( !IsValid( ply ) ) then return -1 end
  3.  
  4. local wep = ply:GetActiveWeapon()
  5. if ( !IsValid( wep ) ) then return -1 end
  6.  
  7. return ply:GetAmmoCount( wep:GetPrimaryAmmoType() )
  8. end
  9.  
  10. local function DrawZenHud()
  11.  
  12. --============================================================================--
  13. --=== LEWY GÓRNY PASEK HP + ARMOR
  14. --============================================================================--
  15.  
  16. // kordynaty dla lewego górnego huda
  17. local ZenHudShape1 = {
  18. { x = 0, y = 0 },
  19. { x = 180, y = 0 },
  20. { x = 180, y = 50 },
  21. { x = 100, y = 100 },
  22. { x = 0, y = 100 }
  23. }
  24.  
  25. local ZenHudShape1_Padding = 1 + 2 * math.sin(ZenHudAnimTimer - CurTime() / 2)
  26. local ZenHudShape1_Detail = {
  27. { x = 0, y = 0 },
  28. { x = 180 + ZenHudShape1_Padding, y = 0 },
  29. { x = 180 + ZenHudShape1_Padding, y = 50 + ZenHudShape1_Padding },
  30. { x = 100 + ZenHudShape1_Padding, y = 100 + ZenHudShape1_Padding },
  31. { x = 0, y = 100 + ZenHudShape1_Padding }
  32. }
  33.  
  34. local ZenHudBackground = Color(40,40,40,255)
  35. local ZenHudDetail = Color(40,40,40,128)
  36.  
  37. --surface.DrawRect( 0, 0, 128, 128 )
  38.  
  39. surface.SetDrawColor( ZenHudDetail )
  40.  
  41. // lewa strona u góry - background
  42. surface.DrawPoly( ZenHudShape1_Detail )
  43.  
  44. surface.SetDrawColor( ZenHudBackground )
  45.  
  46. // lewa strona u góry
  47. surface.DrawPoly( ZenHudShape1 )
  48.  
  49. // Pasek zdrowia
  50. local ZenHPPos = 12
  51.  
  52. surface.SetDrawColor( 255,255,255,255 )
  53. surface.SetMaterial( ZenHudHPIcon )
  54. surface.DrawTexturedRectUV( 12, ZenHPPos, 14, 14, 0, 0, 1, 1 )
  55.  
  56. --draw.SimpleText("HP:" , "Trebuchet18", 12, ZenHPPos , Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
  57.  
  58. draw.RoundedBox( 4, 35, ZenHPPos, 100, 15, Color( 55, 55, 55, 255 ) )
  59. draw.RoundedBox( 4, 35, ZenHPPos, math.Clamp( LocalPlayer():Health() , 0 , 100 ) , 15, Color( 255, 255, 255, 255 ) )
  60.  
  61. local ZenHPAnimFactor = math.Clamp( LocalPlayer():Health() , 0 , 100 )
  62. local ZenHPTextAnim = math.sin(ZenHudAnimTimer - CurTime()*(ZenHPAnimFactor-100)/50)
  63.  
  64. draw.SimpleText( tostring( LocalPlayer():Health() ) , "Trebuchet18", math.Clamp(12 + ZenHPAnimFactor, 35 , 150 ), ZenHPPos , Color( 255, 60, 50, 255 - 100 * ZenHPTextAnim ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
  65.  
  66.  
  67. // Pasek pancerza
  68. local ZenArmPos = 42
  69.  
  70. surface.SetMaterial( ZenHudArmorIcon )
  71. surface.DrawTexturedRectUV( 12, ZenArmPos, 14, 14, 0, 0, 1, 1 )
  72.  
  73. --draw.SimpleText("Armor:" , "Trebuchet18", 4, ZenArmPos , Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
  74.  
  75. draw.RoundedBox( 4, 35, ZenArmPos, 100, 15, Color( 55, 55, 55, 255 ) )
  76. draw.RoundedBox( 4, 35, ZenArmPos, math.Clamp( LocalPlayer():Armor() , 0 , 100 ) , 15, Color( 255, 255, 255, 255 ) )
  77.  
  78. local ZenHPAnimFactor = math.Clamp( LocalPlayer():Armor() , 0 , 100 )
  79. local ZenHPTextAnim = math.sin(ZenHudAnimTimer - CurTime() * (ZenHPAnimFactor - 100) / 50)
  80.  
  81. draw.SimpleText( tostring( LocalPlayer():Armor() ) , "Trebuchet18", math.Clamp(12 + ZenHPAnimFactor, 35 , 150 ), ZenArmPos , Color( 255, 60, 50, 255 - 100 * ZenHPTextAnim ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
  82.  
  83.  
  84. --============================================================================--
  85. --=== PRAWY GÓRNY PASEK AMUNICJA
  86. --============================================================================--
  87.  
  88. // kordynaty dla lewego górnego huda
  89.  
  90. local ZenHudShape2 = {
  91. { x = ScrW()/2, y = ScrH()/2 },
  92. { x = ScrW()-180, y = 0 },
  93. { x = ScrW()-180, y = 50 },
  94. { x = ScrW()-100, y = 100 },
  95. { x = ScrW(), y = 100 },
  96. }
  97.  
  98. local ZenHudShape2_Padding = 1 + 2 * math.sin(ZenHudAnimTimer - CurTime() / 2)
  99. local ZenHudShape2_Detail = {
  100. { x = ScrW(), y = 0 },
  101. { x = ScrW()-180 + ZenHudShape2_Padding, y = 0 },
  102. { x = ScrW()-180 + ZenHudShape2_Padding, y = 50+ZenHudShape2_Padding },
  103. { x = ScrW()-100 + ZenHudShape2_Padding, y = 100+ZenHudShape2_Padding },
  104. { x = ScrW(), y = 100 + ZenHudShape2_Padding },
  105. }
  106.  
  107. surface.SetDrawColor( Color(255,255,255,255) )
  108.  
  109. --surface.SetDrawColor( ZenHudDetail )
  110.  
  111. // Prawa strona u góry - background
  112. surface.DrawPoly( ZenHudShape2_Detail )
  113.  
  114. --surface.SetDrawColor( ZenHudBackground )
  115.  
  116. // Prawa strona u góry
  117. surface.DrawPoly( ZenHudShape2 )
  118.  
  119. local PlayerAmmo = GetAmmoForCurrentWeapon( LocalPlayer() )
  120. if (PlayerAmmo != -1) then
  121. draw.SimpleText( "Amunicja: "..tostring( PlayerAmmo ) , "Trebuchet18", ScrW() - 100, 20 , Color( 255, 60, 50, 255 - 100 * ZenHPTextAnim ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
  122. end
  123.  
  124. end
  125.  
  126. if CLIENT then
  127. local ZenHudHPIcon = Material( "icon16/heart.png", "noclamp" )
  128. local ZenHudArmorIcon = Material( "icon16/shield.png", "noclamp" )
  129.  
  130. local ZenHudAnimTimer = CurTime()
  131.  
  132. // Doczepiamy się do hooka HUDPaint i dodajemy do niego funkcje HUDPaint_ZenHud
  133. hook.Add( "HUDPaint", "HUDPaint_ZenHud", DrawZenHud() )
  134.  
  135. end
  136.  
  137. print("ZENHUD ZAŁADOWANY POPRAWNIE - SERVER + CLIENT SIDE")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement