Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- AddCSLuaFile( "shared.lua" )
- resource.AddFile("sound/Weapons/exshotgun.wav")
- resource.AddFile("materials/VGUI/ttt/icon_shotgun.vtf")
- end
- SWEP.HoldType = "shotgun"
- if CLIENT then
- SWEP.PrintName = "The Lawbringer"
- SWEP.Slot = 2
- SWEP.Icon = "VGUI/ttt/icon_shotgun"
- end
- SWEP.InLoadoutFor = { ROLE_DETECTIVE }
- SWEP.Base = "weapon_tttbase"
- SWEP.Spawnable = true
- SWEP.AdminSpawnable = true
- SWEP.Kind = WEAPON_EQUIP2
- SWEP.Primary.Ammo = "Buckshot"
- SWEP.Primary.Damage = 3.55
- SWEP.Primary.Cone = 0.09
- SWEP.Primary.Delay = 0.80
- SWEP.Primary.ClipSize = 6
- SWEP.Primary.ClipMax = 24
- SWEP.Primary.DefaultClip = 6
- SWEP.Primary.Automatic = true
- SWEP.Primary.NumShots = 24
- SWEP.AmmoEnt = "item_box_buckshot_ttt"
- SWEP.ViewModel = "models/weapons/v_shot_m3super90.mdl"
- SWEP.WorldModel = "models/weapons/w_shot_m3super90.mdl"
- SWEP.Primary.Sound = Sound( "Weapons/exshotgun.wav" )
- SWEP.Primary.Recoil = 22
- --SWEP.IronSightsPos = Vector( 5.7, -3, 3 )
- SWEP.IronSightsPos = Vector( 5.7297, -2.5, 5.155 )
- SWEP.IronSightsAng = Vector(0, 0, 0)
- SWEP.reloadtimer = 0
- function SWEP:SetZoom(state)
- if CLIENT then return end
- if state then
- self.Owner:SetFOV(35, 0.5)
- else
- self.Owner:SetFOV(0, 0.2)
- end
- end
- -- Add some zoom to ironsights for this gun
- function SWEP:SecondaryAttack()
- if not self.IronSightsPos then return end
- if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
- bIronsights = not self:GetIronsights()
- self:SetIronsights( bIronsights )
- if SERVER then
- self:SetZoom(bIronsights)
- end
- self.Weapon:SetNextSecondaryFire(CurTime() + 0.6)
- end
- function SWEP:PreDrop()
- self:SetZoom(false)
- self:SetIronsights(false)
- return self.BaseClass.PreDrop(self)
- end
- function SWEP:Reload()
- self.Weapon:DefaultReload( ACT_VM_RELOAD );
- self:SetIronsights( false )
- self:SetZoom(false)
- end
- function SWEP:Holster()
- self:SetIronsights(false)
- self:SetZoom(false)
- return true
- end
- function SWEP:SetupDataTables()
- self:DTVar("Bool", 0, "reloading")
- return self.BaseClass.SetupDataTables(self)
- end
- function SWEP:Reload()
- self:SetIronsights( false )
- --if self.Weapon:GetNetworkedBool( "reloading", false ) then return end
- if self.dt.reloading then return end
- if not IsFirstTimePredicted() then return end
- if self.Weapon:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount( self.Primary.Ammo ) > 0 then
- if self:StartReload() then
- return
- end
- end
- end
- function SWEP:StartReload()
- --if self.Weapon:GetNWBool( "reloading", false ) then
- if self.dt.reloading then
- return false
- end
- if not IsFirstTimePredicted() then return false end
- self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
- local ply = self.Owner
- if not ply or ply:GetAmmoCount(self.Primary.Ammo) <= 0 then
- return false
- end
- local wep = self.Weapon
- if wep:Clip1() >= self.Primary.ClipSize then
- return false
- end
- wep:SendWeaponAnim(ACT_SHOTGUN_RELOAD_START)
- self.reloadtimer = CurTime() + wep:SequenceDuration()
- --wep:SetNWBool("reloading", true)
- self.dt.reloading = true
- return true
- end
- function SWEP:PerformReload()
- local ply = self.Owner
- -- prevent normal shooting in between reloads
- self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
- if not ply or ply:GetAmmoCount(self.Primary.Ammo) <= 0 then return end
- local wep = self.Weapon
- if wep:Clip1() >= self.Primary.ClipSize then return end
- self.Owner:RemoveAmmo( 1, self.Primary.Ammo, false )
- self.Weapon:SetClip1( self.Weapon:Clip1() + 1 )
- wep:SendWeaponAnim(ACT_VM_RELOAD)
- self.reloadtimer = CurTime() + wep:SequenceDuration()
- end
- function SWEP:FinishReload()
- self.dt.reloading = false
- self.Weapon:SendWeaponAnim(ACT_SHOTGUN_RELOAD_FINISH)
- self.reloadtimer = CurTime() + self.Weapon:SequenceDuration()
- end
- function SWEP:CanPrimaryAttack()
- if self.Weapon:Clip1() <= 0 then
- self:EmitSound( "Weapon_Shotgun.Empty" )
- self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
- return false
- end
- return true
- end
- function SWEP:Think()
- if self.dt.reloading and IsFirstTimePredicted() then
- if self.Owner:KeyDown(IN_ATTACK) then
- self:FinishReload()
- return
- end
- if self.reloadtimer <= CurTime() then
- if self.Owner:GetAmmoCount(self.Primary.Ammo) <= 0 then
- self:FinishReload()
- elseif self.Weapon:Clip1() < self.Primary.ClipSize then
- self:PerformReload()
- else
- self:FinishReload()
- end
- return
- end
- end
- end
- function SWEP:Deploy()
- self.dt.reloading = false
- self.reloadtimer = 0
- return self.BaseClass.Deploy(self)
- end
Add Comment
Please, Sign In to add comment