• Three round burst problem
    2 replies, posted
When i switch my gun into three round burst mode, it should fire 3 rounds with a certain rpm, instead it fires only one full automatic with the delay of each burst it should give. each shot creates this error below: [ERROR] addons/gunz/lua/weapons/my_base/shared.lua:437: attempt to index local 'self' (a nil value) 1. unknown - addons/futuristic weaponry by operatorx/lua/weapons/my_base/shared.lua:437 Timer Failed! [Simple][@addons/gunz/lua/weapons/my_base/shared.lua (line 171)] [ERROR] addons/gunz/lua/weapons/my_base/shared.lua:437: attempt to index local 'self' (a nil value) 1. unknown - addons/futuristic weaponry by operatorx/lua/weapons/my_base/shared.lua:437 Timer Failed! [Simple][@addons/gunz/lua/weapons/my_base/shared.lua (line 174)] line 437: [lua] if not self:CanFire(self.Weapon:Clip1()) then return end[/lua] below is the script for the burst fire function which includes line 171/174: [lua]SWEP.FireModes.Burst = {} SWEP.FireModes.Burst.FireFunction = function(self) local clip = self.Weapon:Clip1() if not self:CanFire(clip) then return end self:BaseAttack() timer.Simple(self.BurstDelay, self.BaseAttack, self) if clip > 1 then timer.Simple(2*self.BurstDelay, self.BaseAttack, self) end end SWEP.FireModes.Burst.InitFunction = function(self) self.Primary.Automatic = true self.Primary.Delay = 60/self.SemiRPM + 3*self.BurstDelay -- Burst delay is derived from self.BurstRPM if CLIENT then self.FireModeDrawTable.x = 0.037*surface.ScreenWidth() self.FireModeDrawTable.y = 0.912*surface.ScreenHeight() end end [/lua] if anyone knows why the script is wrong then please help out and reply!
[code]timer.Simple(self.BurstDelay, self.BaseAttack, self)[/code] Timers don't work this way anymore, you gotta use [code]timer.Simple(self.BurstDelay, function() self:BaseAttack() end )[/code]
Thanks!
Sorry, you need to Log In to post a reply to this thread.