Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. if SERVER then
  2. AddCSLuaFile()
  3. resource.AddFile("vgui/ttt/icon_tlh.vmt")
  4. resource.AddWorkshop("")
  5. end
  6. if CLIENT then
  7. TLHmaterialforhud = Material("vgui/ttt/perks/hud_tlh.png")
  8. hook.Add("HUDPaint", "TTTASC", function()
  9. if (LocalPlayer():HasEquipmentItem(EQUIP_TLH)) then
  10. surface.SetMaterial(TLHmaterialforhud)
  11. surface.SetDrawColor(255, 255, 255, 255)
  12. surface.DrawTexturedRect(100, ScrH() / 2 + 160, 64, 64)
  13. end
  14. end)
  15. end
  16.  
  17. EQUIP_TLH = 4096
  18.  
  19. local TheLittleHelper = {
  20. id = EQUIP_ASC,
  21. loadout = false,
  22. type = "item_passive",
  23. material = "vgui/ttt/icon_tlh",
  24. name = "The Little Helper",
  25. desc = "With this Item you get invincible for 10 seconds. \nPress your Use and Reload Key to activate. \nCAUTION: YOU CAN´T SHOT IN THAT PERIOD OF TIME. \nIt will recharge in 60 seconds."
  26. }
  27.  
  28. table.insert( EquipmentItems[ROLE_TRAITOR], TheLittleHelper )
  29. table.insert( EquipmentItems[ROLE_DETECTIVE], TheLittleHelper )
  30.  
  31. hook.Add("TTTOrderedEquipment", "TTTTLH", function(ply)
  32. if ply:HasEquipmentItem(EQUIP_TLH) then
  33. ply:SetNWBool("TLH", true)
  34. end
  35. end)
  36.  
  37. if SERVER then
  38. function tlhthink()
  39. for key,ply in pairs(player.GetAll()) do
  40. if ply:KeyPressed( IN_USE ) and ply:KeyPressed( IN_RELOAD ) and ply:IsValid() and ply:GetNWBool("TLH", true) and ply:GetNWBool("TLHInvincible", false) then
  41. ply:TheLittleHelper()
  42. end
  43. if ply:GetNWBool("TLHInvincible", true) then
  44. for _, v in pairs(p:GetWeapons()) do
  45. v:SetNextPrimaryFire(CurTime() + 0.2)
  46. v:SetNextSecondaryFire(CurTime() +0.2)
  47. end
  48. end
  49. end
  50. end
  51. function ply:TheLittleHelper(ply)
  52. if ply:GetNWBool("TLH", true) then
  53. ply:SetNWBool("CanAttack", false)
  54. ply:SetNWBool("TLHInvincible", true)
  55. hook.Add("EntityTakeDamage", "TTTTLH", function(ent, dmg)
  56. if IsValid(ply) and ply:IsPlayer() and ply:HasEquipmentItem(EQUIP_TLH) and ply:GetNWBool("TLH", true) then
  57. dmg:ScaleDamage(0)
  58. end
  59. end)
  60. timer.Create("TLHReset", 10,1, function()
  61. if ply:IsValid() then
  62. TLHmaterialforhud = Material("vgui/ttt/perks/hud_tlh2.png")
  63. ply:SetNWBool("CanAttack", true)
  64. ply:SetNWBool("TLH", false)
  65. ply:SetNWBool("TLHInvincible", false)
  66. end
  67. end)
  68. timer.Create("TLHReload", 70,1, ply:TLHReloaded())
  69. end
  70. end
  71. function ply:TLHReloaded()
  72. if ply:IsValid() then
  73. TLHmaterialforhud = Material("vgui/ttt/perks/hud_tlh.png")
  74. ply:SetNWBool("TLH", true)
  75. end
  76. end
  77. hook.Add( "Think", "TTTTLH", tlhthink)
  78. end
  79.  
  80.  
  81. local function ResettinTlh()
  82. for k,v in pairs(player.GetAll()) do
  83. v:SetNWBool("CanAttack", true)
  84. ply:SetNWBool("TLH", false)
  85. ply:SetNWBool("TLHInvincible", false)
  86. end
  87. end
  88.  
  89. hook.Add( "TTTPrepareRound", "ASCRESET", ResettinTlh )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement