• Constant Sound While Firing (HELP)
    1 replies, posted
Hey guys! Was just wondering how the hell do I get this working. I've been messing around, and I figure'd I'd make a dubstep gun, except I failed, again. Heres my code: [code] function SWEP:PrimaryAttack() if ( !self:CanPrimaryAttack() ) then return end if ( self.LoopSound ) then self.LoopSound = CreateSound( self.Owner, Sound( "sound/weapons/knifeparty.wav" ) ) if ( self.LoopSound ) then self.LoopSound:Play() end 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 //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) if ( !self:CanPrimaryAttack() ) then return end self:ShootEffects() Dubstep() self.Owner:FireBullets( bullet ) end [/code] Here's the error: [code] [ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_dubstep/shared.lua:54: attempt to index global 'self' (a nil value) 1. Dubstep - gamemodes/terrortown/entities/weapons/weapon_ttt_dubstep/shared.l ua:54 2. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_dubstep/shared. lua:79 [/code]
[QUOTE=Cowan108;42351126]Hey guys! Was just wondering how the hell do I get this working. I've been messing around, and I figure'd I'd make a dubstep gun, except I failed, again. Heres my code: [code] function SWEP:PrimaryAttack() if ( !self:CanPrimaryAttack() ) then return end if ( self.LoopSound ) then self.LoopSound = CreateSound( self.Owner, Sound( "sound/weapons/knifeparty.wav" ) ) if ( self.LoopSound ) then self.LoopSound:Play() end 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 //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) if ( !self:CanPrimaryAttack() ) then return end self:ShootEffects() Dubstep() self.Owner:FireBullets( bullet ) end [/code] Here's the error: [code] [ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_dubstep/shared.lua:54: attempt to index global 'self' (a nil value) 1. Dubstep - gamemodes/terrortown/entities/weapons/weapon_ttt_dubstep/shared.l ua:54 2. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_dubstep/shared. lua:79 [/code][/QUOTE] Which line is the error actually on? I mean I know it is 54, but could you point out the actual line?
Sorry, you need to Log In to post a reply to this thread.