Guest User

Untitled

a guest
Oct 21st, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. if SERVER then
  2. AddCSLuaFile( "shared.lua" )
  3. resource.AddFile("sound/Weapons/exshotgun.wav")
  4. resource.AddFile("materials/VGUI/ttt/icon_shotgun.vtf")
  5. end
  6.  
  7. SWEP.HoldType = "shotgun"
  8.  
  9. if CLIENT then
  10. SWEP.PrintName = "The Lawbringer"
  11.  
  12. SWEP.Slot = 2
  13. SWEP.Icon = "VGUI/ttt/icon_shotgun"
  14. end
  15.  
  16. SWEP.InLoadoutFor = { ROLE_DETECTIVE }
  17.  
  18. SWEP.Base = "weapon_tttbase"
  19. SWEP.Spawnable = true
  20. SWEP.AdminSpawnable = true
  21.  
  22. SWEP.Kind = WEAPON_EQUIP2
  23.  
  24. SWEP.Primary.Ammo = "Buckshot"
  25. SWEP.Primary.Damage = 3.55
  26. SWEP.Primary.Cone = 0.09
  27. SWEP.Primary.Delay = 0.80
  28. SWEP.Primary.ClipSize = 6
  29. SWEP.Primary.ClipMax = 24
  30.  
  31. SWEP.Primary.DefaultClip = 6
  32. SWEP.Primary.Automatic = true
  33. SWEP.Primary.NumShots = 24
  34. SWEP.AmmoEnt = "item_box_buckshot_ttt"
  35. SWEP.ViewModel = "models/weapons/v_shot_m3super90.mdl"
  36. SWEP.WorldModel = "models/weapons/w_shot_m3super90.mdl"
  37. SWEP.Primary.Sound = Sound( "Weapons/exshotgun.wav" )
  38. SWEP.Primary.Recoil = 22
  39. --SWEP.IronSightsPos = Vector( 5.7, -3, 3 )
  40.  
  41. SWEP.IronSightsPos = Vector( 5.7297, -2.5, 5.155 )
  42. SWEP.IronSightsAng = Vector(0, 0, 0)
  43.  
  44. SWEP.reloadtimer = 0
  45.  
  46.  
  47.  
  48. function SWEP:SetZoom(state)
  49. if CLIENT then return end
  50. if state then
  51. self.Owner:SetFOV(35, 0.5)
  52. else
  53. self.Owner:SetFOV(0, 0.2)
  54. end
  55. end
  56.  
  57. -- Add some zoom to ironsights for this gun
  58. function SWEP:SecondaryAttack()
  59. if not self.IronSightsPos then return end
  60. if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
  61.  
  62. bIronsights = not self:GetIronsights()
  63.  
  64. self:SetIronsights( bIronsights )
  65.  
  66. if SERVER then
  67. self:SetZoom(bIronsights)
  68. end
  69.  
  70. self.Weapon:SetNextSecondaryFire(CurTime() + 0.6)
  71. end
  72.  
  73. function SWEP:PreDrop()
  74. self:SetZoom(false)
  75. self:SetIronsights(false)
  76. return self.BaseClass.PreDrop(self)
  77. end
  78.  
  79. function SWEP:Reload()
  80. self.Weapon:DefaultReload( ACT_VM_RELOAD );
  81. self:SetIronsights( false )
  82. self:SetZoom(false)
  83. end
  84.  
  85.  
  86. function SWEP:Holster()
  87. self:SetIronsights(false)
  88. self:SetZoom(false)
  89. return true
  90. end
  91.  
  92.  
  93.  
  94.  
  95. function SWEP:SetupDataTables()
  96. self:DTVar("Bool", 0, "reloading")
  97.  
  98. return self.BaseClass.SetupDataTables(self)
  99. end
  100.  
  101. function SWEP:Reload()
  102. self:SetIronsights( false )
  103.  
  104. --if self.Weapon:GetNetworkedBool( "reloading", false ) then return end
  105. if self.dt.reloading then return end
  106.  
  107. if not IsFirstTimePredicted() then return end
  108.  
  109. if self.Weapon:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount( self.Primary.Ammo ) > 0 then
  110.  
  111. if self:StartReload() then
  112. return
  113. end
  114. end
  115.  
  116. end
  117.  
  118. function SWEP:StartReload()
  119. --if self.Weapon:GetNWBool( "reloading", false ) then
  120. if self.dt.reloading then
  121. return false
  122. end
  123.  
  124. if not IsFirstTimePredicted() then return false end
  125.  
  126. self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  127.  
  128. local ply = self.Owner
  129.  
  130. if not ply or ply:GetAmmoCount(self.Primary.Ammo) <= 0 then
  131. return false
  132. end
  133.  
  134. local wep = self.Weapon
  135.  
  136. if wep:Clip1() >= self.Primary.ClipSize then
  137. return false
  138. end
  139.  
  140. wep:SendWeaponAnim(ACT_SHOTGUN_RELOAD_START)
  141.  
  142. self.reloadtimer = CurTime() + wep:SequenceDuration()
  143.  
  144. --wep:SetNWBool("reloading", true)
  145. self.dt.reloading = true
  146.  
  147. return true
  148. end
  149.  
  150. function SWEP:PerformReload()
  151. local ply = self.Owner
  152.  
  153. -- prevent normal shooting in between reloads
  154. self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  155.  
  156. if not ply or ply:GetAmmoCount(self.Primary.Ammo) <= 0 then return end
  157.  
  158. local wep = self.Weapon
  159.  
  160. if wep:Clip1() >= self.Primary.ClipSize then return end
  161.  
  162. self.Owner:RemoveAmmo( 1, self.Primary.Ammo, false )
  163. self.Weapon:SetClip1( self.Weapon:Clip1() + 1 )
  164.  
  165. wep:SendWeaponAnim(ACT_VM_RELOAD)
  166.  
  167. self.reloadtimer = CurTime() + wep:SequenceDuration()
  168. end
  169.  
  170. function SWEP:FinishReload()
  171. self.dt.reloading = false
  172. self.Weapon:SendWeaponAnim(ACT_SHOTGUN_RELOAD_FINISH)
  173.  
  174. self.reloadtimer = CurTime() + self.Weapon:SequenceDuration()
  175. end
  176.  
  177. function SWEP:CanPrimaryAttack()
  178. if self.Weapon:Clip1() <= 0 then
  179. self:EmitSound( "Weapon_Shotgun.Empty" )
  180. self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  181. return false
  182. end
  183. return true
  184. end
  185.  
  186. function SWEP:Think()
  187. if self.dt.reloading and IsFirstTimePredicted() then
  188. if self.Owner:KeyDown(IN_ATTACK) then
  189. self:FinishReload()
  190. return
  191. end
  192.  
  193. if self.reloadtimer <= CurTime() then
  194.  
  195. if self.Owner:GetAmmoCount(self.Primary.Ammo) <= 0 then
  196. self:FinishReload()
  197. elseif self.Weapon:Clip1() < self.Primary.ClipSize then
  198. self:PerformReload()
  199. else
  200. self:FinishReload()
  201. end
  202. return
  203. end
  204. end
  205. end
  206.  
  207. function SWEP:Deploy()
  208. self.dt.reloading = false
  209. self.reloadtimer = 0
  210. return self.BaseClass.Deploy(self)
  211. end
Add Comment
Please, Sign In to add comment