From 7861c00e3057538879984b54686689bec4274273 Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Fri, 23 Nov 2018 12:45:44 -0800 Subject: [PATCH] Fix possible crash if player leaves while blinded by a flashbang --- grenades.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grenades.lua b/grenades.lua index dd1cdf8..6677e2d 100644 --- a/grenades.lua +++ b/grenades.lua @@ -65,6 +65,7 @@ if not flash or flash == true then if v:is_player() and v:get_hp() > 0 then local playerdir = vector.round(v:get_look_dir()) local grenadedir = vector.round(vector.direction(v:get_pos(), pos)) + local name = v:get_player_name() if playerdir.x == grenadedir.x and playerdir.z == grenadedir.z then for i = 1, 3, 1 do @@ -78,7 +79,11 @@ if not flash or flash == true then offset = {x=0, y=0} }) - minetest.after(1.7*i, function() v:hud_remove(key) end) + minetest.after(1.6*i, function() + if minetest.get_player_by_name(name) then + minetest.get_player_by_name(name):hud_remove(key) + end + end) end end end