fire(): Return before declaring def, if stack is nil

This commit is contained in:
Anand S 2019-01-13 12:09:19 +05:30
parent 40fa0fd4ca
commit b23f5fa2de
No known key found for this signature in database
GPG Key ID: 3AD8A3C4A51AAB97

View File

@ -52,12 +52,13 @@ local function hide_scope(player)
end
local function fire(stack, player)
local def = gunslinger.get_def(stack:get_name())
if not def or not stack then
-- Workaround to prevent function from executing if stack is nil
if not stack then
return
end
local def = gunslinger.get_def(stack:get_name())
-- Play gunshot sound
play_sound(def.fire_sound or "gunslinger_fire1")