Hey guys, so I’m looking for some code help on making weapons inaccurate while moving. I started off with this code and had some success but have been getting strange results, here is the code:
if self.Owner:KeyDown(IN_FORWARD | IN_BACK | IN_MOVELEFT | IN_MOVERIGHT) then
self.Primary.Cone = self.Primary.Cone * 2
self.Primary.Cone = self.Primary.Cone
I inserted this code in a base lua file that links to all of the other weapons. I put this code under:
as that function deemed fit for this code. Now the code works, but my problem is reverting back to the default cone of fire after standing still. I tried to make it so that it reverted in the last line of the code. What I get, is I get the cone I want when I move but when I standstill the cone remains as it was when I was moving and I get this error in console:
Sometimes the Out-of-range value is different.
I’m very new at coding and I only just recently got into Lua so I’m sure I did something wrong, which is why I’m here asking for some help.
On a side note, does anyone also know how to add stamina for sprinting and jumping?
Any help is appreciated and I thank you for it.
P.S. I am using “ALL WW2 Sweps V2” and coding in weapon_dod_sim_base/shared.lua