Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. f SERVER then
  2. AddCSLuaFile("shared.lua")
  3. end
  4.  
  5. if CLIENT then
  6. SWEP.PrintName = "Fire Extinguisher"
  7. SWEP.Slot = 2
  8. SWEP.SlotPos = 1
  9. SWEP.DrawAmmo = false
  10. SWEP.DrawCrosshair = false
  11. end
  12.  
  13. SWEP.Author = "Crap-Head"
  14. SWEP.Instructions = "Left Click: Extinguish Fires"
  15. SWEP.Category = "DarkRP Fire System"
  16.  
  17. SWEP.ViewModelFOV = 75
  18. SWEP.ViewModelFlip = false
  19.  
  20. SWEP.Spawnable = false
  21. SWEP.AdminSpawnable = true
  22.  
  23. SWEP.UseHands = true
  24. SWEP.Primary.ClipSize = -1
  25. SWEP.Primary.DefaultClip = 0
  26. SWEP.Primary.Automatic = true
  27. SWEP.Primary.Ammo = ""
  28.  
  29. SWEP.Secondary.ClipSize = -1
  30. SWEP.Secondary.DefaultClip = 0
  31. SWEP.Secondary.Ammo = ""
  32.  
  33. SWEP.ViewModel = "models/craphead_scripts/ocrp2/props_meow/weapons/c_extinguisher.mdl"
  34. SWEP.WorldModel = "models/craphead_scripts/ocrp2/props_meow/weapons/w_extinguisher.mdl"
  35.  
  36. function SWEP:Initialize()
  37. self:SetWeaponHoldType( "normal" ) -- else use "normal"
  38. local Len = self:SequenceDuration( self:SelectWeightedSequence( ACT_VM_DRAW ) )
  39.  
  40. self:SendWeaponAnim( ACT_VM_DRAW )
  41. self:SetNextPrimaryFire( CurTime() + Len )
  42.  
  43. if CLIENT then
  44. local Vm = self.Owner:GetViewModel()
  45. Vm:SetModel( self.ViewModel )
  46. end
  47. end
  48.  
  49. function SWEP:PrimaryAttack()
  50. if SERVER then
  51. if not table.HasValue( FIRE_AllowedTeams, team.GetName(self.Owner:Team()) ) then
  52. if not self.HasBeenActivated then
  53. timer.Simple( FIREEXTCITZ_RemoveTimer, function()
  54. if IsValid(self.Owner) then
  55. if self.Owner:HasWeapon( "fire_extinguisher" ) then
  56. self.Owner:StripWeapon( "fire_extinguisher" )
  57. DarkRP.notify( self.Owner, 1, 5, "Your citizen fire extinguisher has expired." )
  58. end
  59. end
  60. end)
  61. DarkRP.notify(self.Owner, 1, 5, "Your citizen fire extinguisher has been activated. You can use it for "..FIREEXTCITZ_RemoveTimer.." seconds.")
  62. end
  63. self.HasBeenActivated = true
  64. end
  65. end
  66.  
  67. self.Weapon:EmitSound( Sound("ambient/wind/wind_hit2.wav") )
  68. self.Attacking = true
  69.  
  70. local Len = self:SequenceDuration( self:SelectWeightedSequence( ACT_VM_PRIMARYATTACK ) )
  71.  
  72. timer.Simple( Len, function()
  73. if IsValid( self.Owner ) then
  74. if self.Owner:KeyDown( IN_ATTACK ) then
  75. self:SendWeaponAnim( ACT_VM_RECOIL1 )
  76. end
  77. end
  78. end )
  79.  
  80. self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
  81. self:SetNextPrimaryFire( CurTime() + Len )
  82.  
  83. self.Weapon:SendWeaponAnim( ACT_VM_RECOIL1 )
  84. self.Weapon:SetNextPrimaryFire( CurTime() + .1 )
  85.  
  86. local ExtinguishEffect = EffectData()
  87. ExtinguishEffect:SetAttachment( 1 )
  88. ExtinguishEffect:SetEntity( self.Owner )
  89. ExtinguishEffect:SetOrigin( self.Owner:GetShootPos() )
  90. ExtinguishEffect:SetNormal( self.Owner:GetAimVector() )
  91. util.Effect( "extinguish", ExtinguishEffect )
  92.  
  93. if SERVER then
  94. local trace = {}
  95. trace.start = self.Owner:GetShootPos()
  96. trace.endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 150
  97. trace.filter = self.Owner
  98.  
  99. local tr = util.TraceLine( trace )
  100.  
  101. for k, v in pairs( ents.FindInSphere( tr.HitPos, 50 ) ) do
  102. if v:GetClass() == "fire" then
  103. v:ExtinguishAttack( self.Owner, false )
  104. end
  105.  
  106. if v:IsOnFire() then
  107. v:Extinguish()
  108. v:SetColor( Color( 255, 255, 255, 255 ) )
  109. end
  110. end
  111. end
  112. end
  113.  
  114. function SWEP:SecondaryAttack()
  115. end
  116.  
  117. function SWEP:Think()
  118.  
  119. if self.Owner:KeyDown( IN_ATTACK ) then
  120. -- do nothing
  121. else
  122. if self.Attacking then
  123. self.Attacking = false
  124.  
  125. local Len = self:SequenceDuration( self:SelectWeightedSequence( ACT_VM_SECONDARYATTACK ) )
  126. self:SendWeaponAnim( ACT_VM_SECONDARYATTACK )
  127. self:SetNextPrimaryFire( CurTime() + Len )
  128. end
  129. end
  130. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement