Advertisement
jordan3012000

cl_hooks.lua

Oct 26th, 2019
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.51 KB | None | 0 0
  1. hook.Add( "CalcView", "CalcView.MedicMod", function( ply, pos, ang, fov )
  2. if ( !IsValid( ply ) or !ply:Alive() or ply:GetViewEntity() != ply ) then return end
  3. if ply:GetMedicAnimation() == 0 then return end
  4.  
  5. local view = {}
  6.  
  7. view.origin = pos - ( ang:Forward()*20 )
  8. view.angles = ang
  9. view.fov = fov
  10. view.drawviewer = true
  11.  
  12. return view
  13.  
  14. end)
  15.  
  16. hook.Add("RenderScreenspaceEffects", "RenderScreenspaceEffects.MedicMod", function()
  17. if LocalPlayer():IsBleeding() then
  18. MedicMod.BleedingEffect()
  19. end
  20. if LocalPlayer():IsPoisoned() then
  21. MedicMod.PoisonEffect()
  22. end
  23. end)
  24.  
  25. local bleedingIcon = Material("materials/bleeding.png")
  26. local poisonedIcon = Material("materials/poisoned.png")
  27. local hattackIcon = Material("materials/heart_attack_icon.png")
  28. local morphIcon = Material("materials/morphine_icon.png")
  29. local breakIcon = Material("materials/break_icon.png")
  30. local notifIcon = Material("materials/heart_attack_icon.png")
  31.  
  32. local deathPanel = nil
  33.  
  34. hook.Add("HUDPaint", "HUDPaint.MedicMod", function()
  35.  
  36. if ConfigurationMedicMod.MedicTeams and table.HasValue(ConfigurationMedicMod.MedicTeams, LocalPlayer():Team()) then
  37. for k, v in pairs(ents.FindByClass("prop_ragdoll")) do
  38.  
  39. if not v:IsDeathRagdoll() then continue end
  40.  
  41. local pos = ( v:GetPos() + Vector(0,0,10) ):ToScreen()
  42. local dist = v:GetPos():Distance(LocalPlayer():GetPos())
  43.  
  44. surface.SetDrawColor( 255, 255, 255, 255 )
  45. surface.SetMaterial( notifIcon )
  46. surface.DrawTexturedRect( pos.x - 25, pos.y, 50, 50 )
  47.  
  48. draw.SimpleTextOutlined( math.floor(math.sqrt(dist/3)).."m", "MedicModFont30", pos.x, pos.y + 50, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 1, Color( 0, 0, 0, 255 ) )
  49.  
  50. end
  51. end
  52.  
  53. if not LocalPlayer():Alive() and not IsValid(deathPanel) and MedicMod.seconds then
  54. if MedicMod.seconds < CurTime() and MedicMod.seconds != -1 then return end
  55. local medicDistance
  56. deathPanel = vgui.Create("DFrame")
  57. deathPanel:SetSize(ScrW()*0.25, ScrH()*0.125)
  58. deathPanel:SetTitle("")
  59. deathPanel:SetAlpha(0)
  60. deathPanel:AlphaTo(255,1.2)
  61. deathPanel:Center()
  62. deathPanel:ShowCloseButton(false)
  63. deathPanel.Paint = function(s,w,h)
  64. draw.RoundedBox(0, 0, 0, w, h, Color(102, 207, 255))
  65. draw.RoundedBox(0, 0, 0, w, h*0.20, Color(0, 157, 230))
  66. draw.SimpleText(ConfigurationMedicMod.Sentences["Death Notice"][ConfigurationMedicMod.Language].." - Medic Mod", "MedicModFont17", w/2, h*0.20/2,Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  67. draw.SimpleText(ConfigurationMedicMod.Sentences["You have lost consciousness."][ConfigurationMedicMod.Language],"MedicModFont17",w/2,h/2-17.5,Color(255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  68. draw.SimpleText(ConfigurationMedicMod.Sentences["You must be rescued by a medic, or wait."][ConfigurationMedicMod.Language] ,"MedicModFont17",w/2,h/2,Color(255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  69. draw.SimpleText("The closest medic is " .. medicDistance .. "m away." ,"MedicModFont17",w/2,h/2+17.5,Color(255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  70. end
  71. deathPanel.Think = function(s)
  72. if LocalPlayer():Alive() then
  73. s:AlphaTo(0, 1.2, 0, function(data,pnl) pnl:Remove() end)
  74. end
  75. local medicYes = false
  76. local tempDistance
  77. for k, v in pairs( player.GetAll() ) do
  78. if table.HasValue(ConfigurationMedicMod.RespawnTeams, v:Team()) then
  79. if not medicYes then
  80. medicDistance = LocalPlayer():GetPos():Distance( v:GetPos() )/100
  81. medicYes = true
  82. else
  83. local tempDistance = LocalPlayer():GetPos():Distance( v:GetPos() )/100
  84. if tempDistance < medicDistance then medicDistance = tempDistance end
  85. end
  86. end
  87. end
  88. medicDistance = round( medicDistance, 0 )
  89. end
  90. local x,y = deathPanel:GetSize()
  91. local button1 = vgui.Create("DButton",deathPanel)
  92. button1:Dock(BOTTOM)
  93. button1:SetText("")
  94. button1:SetSize(0,y*0.25)
  95. button1.DoClick = function(s)
  96. if MedicMod.seconds and MedicMod.seconds-CurTime() > 0 then return end
  97. net.Start("MedicMod.Respawn")
  98. net.SendToServer()
  99. end
  100. button1.Paint = function(s,w,h)
  101. draw.RoundedBox(8, 0, 0, w, h, Color(0, 157, 230))
  102. if MedicMod.seconds-CurTime() > 0 then
  103. draw.SimpleText(ConfigurationMedicMod.Sentences["Please wait"][ConfigurationMedicMod.Language].." "..math.Round(MedicMod.seconds-CurTime()).." "..ConfigurationMedicMod.Sentences["seconds to respawn."][ConfigurationMedicMod.Language], "MedicModFont17", w/2, h/2,Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  104. elseif MedicMod.seconds == -1 then
  105. draw.SimpleText(ConfigurationMedicMod.Sentences["You're receiving CPR, you can't respawn."][ConfigurationMedicMod.Language], "MedicModFont17", w/2, h/2,Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  106. else
  107. draw.SimpleText(ConfigurationMedicMod.Sentences["Click to respawn."][ConfigurationMedicMod.Language], "MedicModFont17", w/2, h/2,Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  108. end
  109. end
  110. end
  111.  
  112. local nbStat = 1
  113.  
  114. if LocalPlayer():IsBleeding() then
  115. surface.SetDrawColor( 255, 255, 255, 255 )
  116. surface.SetMaterial( bleedingIcon )
  117. surface.DrawTexturedRect( ScrW() - 300, ScrH() - 150 - 50 * nbStat, 50, 50 )
  118.  
  119. draw.SimpleTextOutlined( ConfigurationMedicMod.Sentences["Bleeding"][ConfigurationMedicMod.Language], "MedicModFont30", ScrW() - 240, ScrH() - 140 - 50 * nbStat, Color( 255, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, Color( 0, 0, 0, 255 ) )
  120. nbStat = nbStat + 1
  121. end
  122. if LocalPlayer():IsPoisoned() then
  123. surface.SetDrawColor( 255, 255, 255, 255 )
  124. surface.SetMaterial( poisonedIcon )
  125. surface.DrawTexturedRect( ScrW() - 300, ScrH() - 150 - 50 * nbStat, 50, 50 )
  126.  
  127. draw.SimpleTextOutlined( ConfigurationMedicMod.Sentences["Poisoned"][ConfigurationMedicMod.Language], "MedicModFont30", ScrW() - 240, ScrH() - 140 - 50 * nbStat, Color( 153, 201, 158, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, Color( 0, 0, 0, 255 ) )
  128. nbStat = nbStat + 1
  129. end
  130. if LocalPlayer():GetHeartAttack() then
  131. surface.SetDrawColor( 255, 255, 255, 255 )
  132. surface.SetMaterial( hattackIcon )
  133. surface.DrawTexturedRect( ScrW() - 300, ScrH() - 150 - 50 * nbStat, 50, 50 )
  134.  
  135. draw.SimpleTextOutlined( ConfigurationMedicMod.Sentences["Heart Attack"][ConfigurationMedicMod.Language], "MedicModFont30", ScrW() - 240, ScrH() - 140 - 50 * nbStat , Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, Color( 0, 0, 0, 255 ) )
  136. nbStat = nbStat + 1
  137. end
  138. if LocalPlayer():IsMorphine() then
  139. surface.SetDrawColor( 255, 255, 255, 255 )
  140. surface.SetMaterial( morphIcon )
  141. surface.DrawTexturedRect( ScrW() - 300, ScrH() - 150 - 50 * nbStat, 50, 50 )
  142.  
  143. draw.SimpleTextOutlined( ConfigurationMedicMod.Sentences["Morphine"][ConfigurationMedicMod.Language], "MedicModFont30", ScrW() - 240, ScrH() - 140 - 50 * nbStat, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, Color( 0, 0, 0, 255 ) )
  144. nbStat = nbStat + 1
  145. end
  146. if LocalPlayer():IsFractured() then
  147. surface.SetDrawColor( 255, 255, 255, 255 )
  148. surface.SetMaterial( breakIcon )
  149. surface.DrawTexturedRect( ScrW() - 300, ScrH() - 150 - 50 * nbStat, 50, 50 )
  150.  
  151. draw.SimpleTextOutlined( ConfigurationMedicMod.Sentences["Fracture"][ConfigurationMedicMod.Language], "MedicModFont30", ScrW() - 240, ScrH() - 140 - 50 * nbStat, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, Color( 0, 0, 0, 255 ) )
  152. nbStat = nbStat + 1
  153. end
  154.  
  155. end)
  156.  
  157. function round(num, numDecimalPlaces)
  158. local mult = 10^(numDecimalPlaces or 0)
  159. return math.floor(num * mult + 0.5) / mult
  160. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement