diff --git a/shooter/api.lua b/shooter/api.lua index 0b64599..9b14679 100644 --- a/shooter/api.lua +++ b/shooter/api.lua @@ -551,3 +551,7 @@ end shooter.set_shooting = function(name, is_shooting) shooting[name] = is_shooting and true or nil end + +minetest.register_on_dieplayer(function(player) + shooting[player:get_player_name()] = nil +end) diff --git a/shooter/init.lua b/shooter/init.lua index 01f16e9..3e00c37 100644 --- a/shooter/init.lua +++ b/shooter/init.lua @@ -67,11 +67,10 @@ minetest.register_entity("shooter:turret_entity", { if shooter.config.automatic_weapons == true then minetest.register_globalstep(function() - for _,player in pairs(minetest.get_connected_players()) do + for _, player in pairs(minetest.get_connected_players()) do local name = player:get_player_name() - if name then - shooter.set_shooting(name, - player:get_player_control().LMB == true) + if shooter.get_shooting(name) and not player:get_player_control().LMB then + shooter.set_shooting(name, nil) end end end)