Advertisement
Guest User

Gmod CLoaking device title

a guest
Feb 13th, 2012
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1.  
  2. if SERVER then
  3. AddCSLuaFile( "shared.lua" )
  4. end
  5.  
  6. SWEP.HoldType = "knife"
  7.  
  8. if CLIENT then
  9.  
  10. SWEP.PrintName = "CLOAK"
  11. SWEP.Slot = 6
  12.  
  13. SWEP.ViewModelFlip = false
  14.  
  15. SWEP.EquipMenuData = {
  16. type = "item_weapon",
  17. desc = "knife_desc"
  18. };
  19.  
  20. SWEP.Icon = "VGUI/ttt/icon_knife"
  21. end
  22.  
  23. SWEP.Base = "weapon_tttbase"
  24.  
  25. SWEP.ViewModel = "models/weapons/v_knife_t.mdl"
  26. SWEP.WorldModel = "models/weapons/w_knife_t.mdl"
  27.  
  28. SWEP.DrawCrosshair = false
  29. SWEP.Primary.Damage = 50
  30. SWEP.Primary.ClipSize = -1
  31. SWEP.Primary.DefaultClip = -1
  32. SWEP.Primary.Automatic = true
  33. SWEP.Primary.Delay = 1.1
  34. SWEP.Primary.Ammo = "none"
  35. SWEP.Secondary.ClipSize = -1
  36. SWEP.Secondary.DefaultClip = -1
  37. SWEP.Secondary.Automatic = true
  38. SWEP.Secondary.Ammo = "none"
  39. SWEP.Secondary.Delay = 1.4
  40.  
  41. SWEP.Kind = WEAPON_EQUIP
  42. SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
  43. SWEP.LimitedStock = true -- only buyable once
  44. SWEP.WeaponID = AMMO_KNIFE
  45.  
  46. SWEP.IsSilent = true
  47.  
  48. -- Pull out faster than standard guns
  49. SWEP.DeploySpeed = 2
  50.  
  51. local swepCanActivate = 1
  52. local Timer = timer.Create( "RemoveCloak", 30, 0, removeCloak )
  53.  
  54. function SWEP:PrimaryAttack()
  55. self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  56. self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
  57.  
  58. self.Owner:LagCompensation(true)
  59.  
  60. if swepCanActivate == 1 then
  61.  
  62. startCloak()
  63. swepCanActivate = 0
  64.  
  65. end
  66.  
  67. self.Owner:LagCompensation(false)
  68. end
  69.  
  70. function SWEP:SecondaryAttack()
  71. self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  72. self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
  73.  
  74. self.Owner:LagCompensation(true)
  75.  
  76. if swepCanActivate == 1 then
  77.  
  78. startCloak()
  79. swepCanActivate = 0
  80. timer.Start( "RemoveCloak" )
  81.  
  82. end
  83.  
  84. self.Owner:LagCompensation(false)
  85. end
  86.  
  87. function startCloak()
  88. local owner = self.Owner()
  89.  
  90. if owner:IsPlayer() and ValidEntity(owner) then
  91.  
  92. owner:SetAlpha( 20 )
  93. timer.Start( "RemoveCloak" )
  94.  
  95. end
  96. end
  97.  
  98. function removeCloak()
  99. local owner = self.Owner()
  100.  
  101. if owner:IsPlayer() then
  102.  
  103. owner:SetColor( 255, 255, 255, 255 )
  104. Entity:SetMaterial( "" )
  105. timer.Remove( "RemoveCloak" )
  106. self:Remove()
  107.  
  108. end
  109. end
  110.  
  111. function SWEP:Equip()
  112. self.Weapon:SetNextPrimaryFire( CurTime() + (self.Primary.Delay * 1.5) )
  113. self.Weapon:SetNextSecondaryFire( CurTime() + (self.Secondary.Delay * 1.5) )
  114. end
  115.  
  116. function SWEP:PreDrop()
  117. -- for consistency, dropped knife should not have DNA/prints
  118. self.fingerprints = {}
  119. end
  120.  
  121. function SWEP:OnRemove()
  122. if CLIENT and ValidEntity(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
  123. RunConsoleCommand("lastinv")
  124. end
  125. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement