Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.15 KB | None | 0 0
  1.  
  2. if SERVER then
  3.    AddCSLuaFile( "shared.lua" )
  4.    
  5. end
  6.  
  7. SWEP.HoldType           = "pistol"
  8.  
  9. if CLIENT then
  10.    SWEP.PrintName = "Pepper Spray"
  11.    SWEP.Slot = 7
  12.  
  13.    SWEP.EquipMenuData = {
  14.       type="Weapon",
  15.       model="models/weapons/w_defuser.mdl",
  16.       desc="Used to blind enemies.\nThis cannot damage enemies."
  17.    };
  18.  
  19.    SWEP.Icon = "VGUI/ttt/icon_spray"
  20. end
  21.  
  22. SWEP.Base = "weapon_tttbase"
  23.  
  24. SWEP.ViewModel = "models/weapons/v_pepperspray.mdl"
  25. SWEP.WorldModel = "models/weapons/w_pepperspray.mdl"
  26.  
  27. SWEP.DrawCrosshair      = false
  28. SWEP.Primary.Cone = 0.10
  29. SWEP.Primary.ClipSize       = -1
  30. SWEP.Primary.DefaultClip    = -1
  31. SWEP.Primary.Automatic      = true
  32. SWEP.Primary.Delay = 0.1
  33. SWEP.Primary.Ammo       = "none"
  34. SWEP.Primary.Automatic  = true
  35. SWEP.Primary.Ammo = ""
  36.  
  37. SWEP.Kind = WEAPON_EQUIP2
  38. SWEP.CanBuy = {ROLE_DETECTIVE} -- only detectives can buy
  39. SWEP.WeaponID = AMMO_SPRAY
  40.  
  41. SWEP.Primary.Sound = Sound("weapons/pepper_spray/spray.wav")
  42.  
  43. --SWEP.AllowDrop = true
  44.  
  45. function SWEP:Initialize()
  46.         self:SetWeaponHoldType("pistol")
  47. end
  48.  
  49. function SWEP:CanPrimaryAttack ( ) return true; end
  50.  
  51. function SWEP:PrimaryAttack()  
  52.     if self:GetTable().LastNoise == nil then self:GetTable().LastNoise = true; end
  53.     if self:GetTable().LastNoise then
  54.         self.Weapon:EmitSound(self.Primary.Sound)
  55.         self:GetTable().LastNoise = false;
  56.     else
  57.         self:GetTable().LastNoise = true;
  58.     end
  59.    
  60.     self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
  61.     self.Weapon:SetNextPrimaryFire(CurTime() + .1)
  62.    
  63.     if CLIENT or (SinglePlayer() and SERVER) then      
  64.         local ED = EffectData();
  65.             ED:SetEntity(self.Owner);
  66.         util.Effect('extinguish', ED);
  67.     end
  68.    
  69.     if SERVER then
  70.         local Trace2 = {};
  71.         Trace2.start = self.Owner:GetShootPos();
  72.         Trace2.endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 150;
  73.         Trace2.filter = self.Owner;
  74.  
  75.         local Trace = util.TraceLine(Trace2);
  76.                
  77.         local CloseEnts = ents.FindInSphere(Trace.HitPos, 50)
  78.        
  79.         for k, v in pairs(CloseEnts) do
  80.             if v:GetClass() == 'prop_fire' then
  81.                 v:HitByExtinguisher(self.Owner)
  82.             end
  83.            
  84.             if v:IsOnFire() then v:Extinguish() end
  85.         end
  86.     end
  87. end
  88.  
  89. function SWEP:SecondaryAttack()
  90.     self:PrimaryAttack();
  91. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement