[TTT] Lua error when firing Railgun


#1

Server:
TTT

Issue or Suggestion:
Issue

Description of problem:
I got this lua error after firing the Railgun without charging it:

[ERROR] gamemodes/terrortown/entities/weapons/weapon_rp_railgun.lua:244: attempt to perform arithmetic on local 'recoil' (a nil value)
  1. BfgFire - gamemodes/terrortown/entities/weapons/weapon_rp_railgun.lua:244
   2. unknown - gamemodes/terrortown/entities/weapons/weapon_rp_railgun.lua:181

I looked in “weapon_rp_railgun.lua” rq and at line 244 there’s just the end of this if statement:

        if self.mode == "4" then
		self:TakePrimaryAmmo( 4 )
		recoil = 82
		damage = 160
	end

and at line 181 is self.overcharge = nil in this if statement:

        if self.overcharge and CurTime() > self.overcharge then
		self.overcharge = nil
		if !self.Owner:KeyDown(IN_ATTACK) then return end
		self:Explode()
	end

which makes me v e r y c o n f u s e d

My guess is that sense this “recoil” value is used in the first offending line number’s related function as a local value, the code is confused as to why it’s doing a bunch of stuff with it without a value, though it looks like in the code the compiler shouldn’t have worried about it. Hmmmmmmmmmmmm

Well, I hope this can be resolved. Plz? Tnx.

// Read About the Issues and Suggestions Tracker category before posting!
// Remember to put the server you are referring to the topic tile also!