I’m trying to create a weapon that, well, overheats.
So I set a variable called SWEP.Heat and reset it at 0.
Then, I do this: [lua]if self.Heat >= 255 then
–Create explosion, destroy the gun
if self.Owner:KeyDown( IN_ATTACK ) and CurTime() > self.Weapon:GetNextPrimaryFire() then self.Heat = self.Heat + 1 elseif self.Heat > 0 then self.Heat = self.Heat - ( (255-self.Heat)/127 ) if self.Heat < 0 then self.Heat = 0 end if self.Owner:KeyReleased( IN_ATTACK ) and CurTime() > self:GetNextPrimaryFire() then self.Weapon:SetNextPrimaryFire( CurTime() + 2 ) end end
- Apparently SWEP:Think() is affected by… something, so it doesn’t really fit my needs as I need a static length of time to count on. And I assume there’s a much better way to do this than a timer…
- This will mean the “cool down” mechanism won’t work if the weapon isn’t deployed, which really doesn’t fit my needs as that is illogical and makes the weapon lame af
- I assume there’s a better way to do all of this that I’m just not aware of…