Three Round Burst

Hi all

Some time ago with some help I’ve created this function which fulfills the three round burst firemode, it works fine with no errors but something bothers me
1 click forces three shots and it send 3 rounds down the range even when you released the trigger already.
what I want Only allow bullets to be fired until the trigger is released, or the pack has fired all 3 shots. With this system I would be able to terminate the burst by releasing the trigger.

Here is the original burst function I have atm
[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, function() self:BaseAttack() end )

if clip > 1 then
	timer.Simple(2*self.BurstDelay, function() self:BaseAttack() end )
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.922*surface.ScreenHeight()
end

end

SWEP.FireModes.Burst.RevertFunction = function(self)

return

end
[/Lua]

If anyone knows what need to be changed here in order to make the idea work please leave a reply.

Thanks

(ps sorry for long post, thought it’l be hard to explain what I want)

Do not use timers in your weapons, it will break client server prediction.

Just use something like self.NextFireTime = CurTime() + 0.1 to tell the weapon to fire again in the future. Then in your think hook check if CurTime() >= self.NextFireTime and if so call your fire function.

By using curtime for each individual shot, i thought it makes you unable to set a desired burstrpm on each shared.lua

CurTime() is a float and is accurate to hundredths of a second if I recall correctly. So you could do CurTime() + 0.001 and it would still work. The only issue is that Think gets called 66 (by default) times per second. Well I say that, I can’t confirm it but I think Think gets called per server tick? Either way it’s still called ridiculously often. So being able to fire 66 bullets per second, at worst, is more than enough.

I can’t provide you with a code, but LEETNOOB(or Spy) has his FAS2 weapon pack, that has exactly what you are looking for, where it fires three rounds as long as the trigger is held down.

Yes, Thats exactly what I’m looking for.

If someone know a code for that burst fire function that works similair to that I’d be glad.

GMA extractor.

You can modify self.Primary.Automatic in your code so you can have the weapon be automatic until the last bullet, then disable automatic mode so it stops. You will also need a controlled toggle to go with the shot-counter so on-click-release the counter resets as most modern firearms do ( The M16 which was used in Vietnam actually didn’t reset so burst could be 1 shot, 2 shots or 3 depending how many shots were fired in the current count; the FN CAL [ 5.56 ] came out prior to the FN FAL [ 7.62 if I recall correctly ] actually had a clock-reset mechanism so trigger release would reset the counter ).

already tried, somehow im unable to extract FAS gma folders.
EDIT, for the “dumb” tagger. I know how to extract gma folders, ive done it alot but in the sheerest accident the FA:S folders gives a problem extracting.
its a matter of coincidence I think.

Download this: https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/gmadconv.zip or https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/gmadconv.exe

Extract, or move, it to some folder such as C:\Utilities\gmadconv.exe

Double-click a .gma file if the extension hasn’t been assigned, or Shift-Right-Click > Open With if it has been assigned to another program…

Browse > and select the exe file

Then, double-clicking a gma file will extract it to the directory the gma file is located ( not the exe ).

If you want clients to download an addon for the models and you want the server to exclude the Lua files or so… and you want something to handle all resources ( without needing to regenerate a file each time the data changes ) take a look at this: https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/setting_up_downloads_using_recursive_resource_system.lua.html