Hey all, I am not sure if this is the way to go about it but…
[LUA]
AddCSLuaFile()
SWEP.Base = “weapon_base”
SWEP.PrintName = “Test SWEP”
SWEP.Author = “Keosan”
SWEP.Spawnable = false
SWEP.AdminSpawnable = true
SWEP.ViewModelFlip = false
SWEP.HoldType = “pistol”
SWEP.ViewModel = “models/weapons/w_alyx_gun_2.mdl”
SWEP.WorldModel = “models/weapons/w_alyx_gun_2.mdl”
SWEP.Primary.Recoil = 0.75
SWEP.Primary.Damage = 100
SWEP.Primary.NumShots = 1
SWEP.Primary.Spread = 0.05
SWEP.Primary.Cone = 0.05
SWEP.Primary.ClipSize = 10
SWEP.Primary.DefaultClip = 10
SWEP.Primary.Ammo = “pistol”
SWEP.Primary.Automatic = false
SWEP.Primary.Delay = 1
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “none”
function SWEP:Initialize()
util.PrecacheSound(“newpistol/pistolshoot.wav”)
self:SetWeaponHoldType( self.HoldType )
end
function SWEP:PrimaryAttack()
if ( not self:CanPrimaryAttack() ) then
return
end
local Bullet {}
Bullet.Num = self.Primary.NumShots
Bullet.Src = self.Owner:GetShootPos()
Bullet.Dir = self.Owner:GetAimVector()
Bullet.Spread = Vector( self.Primary.Spread, self.Primary.Spread,0 )
Bullet.Tracer = 0
Bullet.Damage = self.Primary.Damage
Bullet.AmmoType = self.Primary.Ammo
self:ShootEffects()
self:FireBullets( Bullet)
self:EmitSound(“newpistol/pistolshoot.wav”)
self:TakePrimaryAmmo( 1 )
self:SetNextPrimaryFire( CurTime()+self.Primary.Delay)
end
function SWEP:SecondaryAttack()
if ( not self:CanSecondaryAttack() ) then
return
end
local bulletpos = self.Owner:GetBulletPos()
local die = ents.Create(“env_ar2explosion”)
die:SetPos( bulletpos.BulletPos )
die:SetOwner (self.Owner)
die:Spawn()
die:SetKeyValue(“iMagnitude”, “300”)
die:Fire(“Explode”, 0, 0)
die:EmitSound(“weapon_AWP.Single”, 400, 400)
self:SetNextPrimaryFire( CurTime() + self.Secondary.Delay )
self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
end
end
function SWEP:Reload()
end
function SWEP:Think()
end
[/LUA]
I am trying to create a SWEP Pistol named test pistol which fires a bullet with primary button and then upon pressing the secondary button that bullet that was fired will expand to a given size and kill anything that falls within it. I am not sure of how to do this so i looked around and i couldn’t find anything so i need your help! What did i do right and what did i do wrong?