*UPDATE* Alright, I managed to get this far, but for whatever reason now it won't spawn in my TTT Server
[lua]
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
local bullet = {}
bullet.Num = self.Primary.NumberofShots //The number of shots fired
bullet.Src = self.Owner:GetShootPos() //Gets where the bullet comes from
bullet.Dir = self.Owner:GetAimVector() //Gets where you're aiming
bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0)
//The above, sets how far the bullets spread from each other.
bullet.Tracer = 0
bullet.Force = self.Primary.Force
bullet.Damage = self.Primary.Damage
bullet.AmmoType = self.Primary.Ammo
local rnda = self.Primary.Recoil * -1
local rndb = self.Primary.Recoil * math.random(-1, 1)
self:EmitSound("weapons/lazor1")
timer.Simple(2)
self:EmitSound("weapons/lazor2")
self:ShootEffects()
self.Owner:FireBullets( bullet )
self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) )
self:TakePrimaryAmmo(self.Primary.TakeAmmo)
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
end
[/lua]
[lua]
function SWEP:PrimaryAttack()
self.Weapon:EmitSound( "weapons/lazor1" )
timer.Simple( --[[Delay here]]--, fire() )
local function fire()
-- your code here
end
[/lua]
I don't really mess with sweps but that should work.
[CODE]
function SWEP:Think() -- Called every frame
if self.NextFire > CurTime() then return end
local trace = self.Owner:GetEyeTrace()
if self.Owner:KeyDown(IN_ATTACK) then
if self.Charge >= 180 then
local explo
if SERVER then
self.Owner:EmitSound(Sound("npc/vort/attack_shoot.wav"))
explo = ents.Create("env_explosion"); explo:SetPos(trace.HitPos); explo:SetOwner(self.Owner); explo:SetKeyValue("iMagnitude", "200"); explo:Spawn(); explo:Fire("explode", "", 0); explo:Fire("kill", "", 0); self.Weapon:TakePrimaryAmmo(1);
end
self.NextFire = CurTime() + 4
self.Charge = 0
self.Weapon:SetNWInt("SLCharge", 0)
return
end
if self.Weapon:Clip1() == 0 then self:Reload() return end
self.Charge = self.Charge + 1
if self.Charge == 1 then if SERVER then self.Owner:EmitSound(Sound("ambient/machines/thumper_startup1.wav")) end end
self.Weapon:SetNWInt("SLCharge", self.Weapon:GetNWInt("SLCharge") + 1)
self.MuzzlePos = self.Owner:GetShootPos() + self.Owner:GetRight() * 2
else
self.Charge = 0
self.Weapon:SetNWInt("SLCharge", 0)
end
end
end[/CODE]
from an old spartan laser addon, pick it apart
Sorry, you need to Log In to post a reply to this thread.