-- SWEP template -- Version 0.2 BETA -- All code written by Aric Blunk (mblunk) -- Effect settings SWEP.PrintName = "USP Match" -- The name of the weapon SWEP.Slot = 1 -- The weapon slot this SWEP belongs in (0-5) SWEP.SlotPos = 2 -- The position in the slot this weapon belongs in (0-infinity, DO NOT COVER UP EXISTING WEAPONS) SWEP.DrawAmmo = true -- Display how much ammo this weapon has left? SWEP.DrawCrosshair = true -- Display the crosshair? SWEP.ViewModel = "models/weapons/v_pistol.mdl" -- First person model SWEP.WorldModel = "models/weapons/w_pistol.mdl" -- Third person model SWEP.ReloadSound = "weapons/pistol/pistol_reload1.wav" -- What sound should this weapon make when reloaded? -- Other settings SWEP.Weight = 3 -- How powerful is this weapon? SWEP.AutoSwitchTo = false -- Automatically switch to this weapon if it's more powerful than what we're already holding SWEP.AutoSwitchFrom = false -- Automatically switch from this weapon if what we pick up is more powerful than this weapon SWEP.Spawnable = false -- Can clients spawn this weapon? SWEP.AdminSpawnable = true -- Can admins spawn this weapon? --SWEP.AutoReload = true -- Automatically reload if the clip is empty? (DOES NOT WORK YET) SWEP.Base= "weapon_cs_base" -- Weapon info SWEP.Author = "AKA Alex" -- Who made this SWEP.Contact = "" -- How you can contact who made this SWEP.Purpose = "" -- Why was this made? SWEP.Instructions = "" -- How do you use this? -- Primary fire settings SWEP.Primary.Sound = "weapons/pistol/pistol_fire2.wav" -- What sound should this weapon make when fired? SWEP.Primary.Damage = 10 -- How much damage each bullet inflicts SWEP.Primary.NumShots = 1 -- How many bullets we should shoot each time we fire the weapon (Use more than one for shotguns and the like) SWEP.Primary.Recoil = 0.5 -- How much we should punch the view SWEP.Primary.Cone = 2 -- How many degrees the bullets can spread (90 max) SWEP.Primary.Delay = 0.01 -- How many seconds between each shot SWEP.Primary.ClipSize = 18 -- How big the clip is SWEP.Primary.DefaultClip = 256 -- How much ammo the gun comes with SWEP.Primary.Tracer = 1 -- Fire a tracer round every so many bullets SWEP.Primary.Force = 1000 -- How much force the bullets have when they hit physics objects SWEP.Primary.TakeAmmoPerBullet = false -- Take 1 ammo for each bullet = true, take 1 ammo for each shot = false SWEP.Primary.Automatic = false -- Is this weapon automatic? SWEP.Primary.Ammo = "pistol" -- Primary ammo type -- Secondary fire settings SWEP.Secondary.Sound = "" -- What sound should this weapon make when fired? SWEP.Secondary.Damage = 0 -- How much damage each bullet inflicts SWEP.Secondary.NumShots = 0 -- How many bullets we should shoot each time we fire the weapon (Use more than one for shotguns and the like) SWEP.Secondary.Recoil = 0 -- How much we should punch the view SWEP.Secondary.Cone = 0 -- How many degrees the bullets can spread (90 max) SWEP.Secondary.Delay = 0 -- How many seconds between each shot SWEP.Secondary.ClipSize = -1 -- How big the clip is SWEP.Secondary.DefaultClip = -1 -- How much ammo the gun comes with SWEP.Secondary.Tracer = 0 -- Fire a tracer round every so many bullets SWEP.Secondary.Force = 0 -- How much force the bullets have when they hit physics objects SWEP.Secondary.TakeAmmoPerBullet = false -- Take 1 ammo for each bullet = true, take 1 ammo for each shot = false SWEP.Secondary.Automatic = false -- Is this weapon automatic? SWEP.Secondary.Ammo = "none" -- Secondary ammo type -- Functions that we can use to run certain code at certain times -- I don't suggest you play around with this stuff unless you know what you're doing function SWEP:Initialize() -- Called when this script is run end function SWEP:PrimaryAttack() -- Called when we press primary fire if ( !self:CanPrimaryAttack() ) then return end -- If we shouldn't be shooting, don't shoot local bullet = {} -- Set up the shot bullet.Num = self.Primary.NumShots -- How many bullets we'll fire at once bullet.Src = self.Owner:GetShootPos() -- Where the bullets are coming from bullet.Dir = self.Owner:GetAimVector() -- Where the bullets are headed bullet.Spread = Vector( self.Primary.Cone / 90, self.Primary.Cone / 90, 0 ) -- Bullet spread bullet.Tracer = self.Primary.Tracer -- Set up tracer rounds bullet.Force = self.Primary.Force -- Set the bullet's force bullet.Damage = self.Primary.Damage -- Define how much damage each bullet does self.Owner:FireBullets( bullet ) -- Shoot! self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) -- View model animation self.Owner:MuzzleFlash() -- Crappy muzzle light self.Owner:SetAnimation( PLAYER_ATTACK1 ) -- 3rd Person Animation self.Weapon:EmitSound(Sound(self.Primary.Sound)) -- Make shooty noises self.Owner:ViewPunch(Angle( -self.Primary.Recoil, 0, 0 )) if (self.Primary.TakeAmmoPerBullet) then -- Set up ammo loss self:TakePrimaryAmmo(self.Primary.NumShots) else self:TakePrimaryAmmo(1) end self:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) -- Don't shoot again until the delay has expired end function SWEP:Think() -- Called every frame while this weapon is active --[[ autoreload code (doesn't work, help?) if ( self.AutoReload ) and (( self.LastReload == nil ) or ( CurTime() > (self.LastReload + 1) )) then SWEP.LastReload = CurTime() if (self:Ammo1() > 0) and (self:Clip1() == 0) and (!self.Weapon:DefaultReload()) then self.Weapon:DefaultReload( ACT_VM_RELOAD ) --self:Reload() end if (self:Ammo2() > 0) and (self:Clip2() == 0) and (!self.Weapon:DefaultReload()) then self.Weapon:DefaultReload( ACT_VM_RELOAD ) --self:Reload() end end ]] end function SWEP:Reload() -- Called when we reload if (self.Weapon:DefaultReload()) then return end -- If we're already reloading, don't try to reload self.Weapon:DefaultReload( ACT_VM_RELOAD ) -- Reload self.Weapon:EmitSound(Sound(self.ReloadSound)) -- Make reloady noises end function SWEP:Deploy() -- Called when we take this weapon out self.Weapon:SendWeaponAnim(ACT_VM_DRAW) return true end function SWEP:Holster() -- Called when we put this weapon away return true end function SWEP:OnRemove() -- Called right before this gun exists no more end function SWEP:OnRestore() -- Called when we load a save where you have this weapon, or if the admin changes the map end function SWEP:Precache() -- Use this function to precache resources end function SWEP:OwnerChanged() -- Called when this weapons is dropped or someone else picks it up end function SWEP:ContextScreenClick( aimvec, mousecode, pressed, ply ) -- Use this function to define what happens when the user clicks with the context screen cursor end SWEP.IronSightsPos = Vector( -5.54, -8, 4.1 ) SWEP.IronSightsAng = Vector( 0, 0, 0 )