Skip to content

Commit

Permalink
Update anti-recoil.lua
Browse files Browse the repository at this point in the history
Fix for if nil due to the fact players weapon has no clip or ammo attachment.
  • Loading branch information
C0nw0nk committed Jun 22, 2016
1 parent 67dc084 commit 8993e39
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions garrysmod/lua/autorun/server/anti-recoil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ hook.Add("StartCommand", "StartCommand-Anti-Recoil", function(pl, key)
--If player is holding down their attack keys

--If the player is using primary attack and the clip on their weapon is greater than 0 (not empty).
if pl:KeyDown(IN_ATTACK) and pl:GetActiveWeapon():Clip1() > 0 then
if pl:KeyDown(IN_ATTACK) and pl:GetActiveWeapon():Clip1() != nil and pl:GetActiveWeapon():Clip1() > 0 then
--If the weapon they are holding has a recoil method attached to it by the SWEP.
--If the recoil method is kickup.
if pl:GetActiveWeapon().Primary.KickUp then
Expand All @@ -36,7 +36,7 @@ hook.Add("StartCommand", "StartCommand-Anti-Recoil", function(pl, key)
end

--If the player is using secondary attack and the clip on their weapon is greater than 0 (not empty).
if pl:KeyDown(IN_ATTACK2) and pl:GetActiveWeapon():Clip1() > 0 then
if pl:KeyDown(IN_ATTACK2) and pl:GetActiveWeapon():Clip1() != nil and pl:GetActiveWeapon():Clip1() > 0 then
--If the weapon they are holding has a recoil method attached to it by the SWEP.
--If the recoil method is kickup.
if pl:GetActiveWeapon().Secondary.KickUp then
Expand Down

0 comments on commit 8993e39

Please sign in to comment.