From 2f3b09ff704dd0cc2f7761a3cf3ea2d40b8a68bf Mon Sep 17 00:00:00 2001 From: Apelta <54854228+TSafa-23@users.noreply.github.com> Date: Sat, 26 Dec 2020 23:01:36 -0600 Subject: [PATCH] Fix sniper crosshairs being active after death (#726) * Fix bug with crosshairs active after death (hopefully) fixes issue with crosshairs remaining after player death. Requires testing. How to test: - die while scoped Normally I would do this but I am unable to get to a proper platform to test. * Use function Slipped my mind, sorry :P * Fix typo, comment Fixed typo in line 100, also fixed comment for dieplayer function --- mods/pvp/sniper_rifles/init.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mods/pvp/sniper_rifles/init.lua b/mods/pvp/sniper_rifles/init.lua index eec979d..be0d705 100644 --- a/mods/pvp/sniper_rifles/init.lua +++ b/mods/pvp/sniper_rifles/init.lua @@ -63,6 +63,13 @@ local function hide_scope(name) end +-- Be absolutely certain crosshair HUD gets removed on death +minetest.register_on_dieplayer(function(player) + if scoped_hud_id[player:get_player_name()] then + hide_scope(player:get_player_name()) + end +end) + local function on_use(stack, user, pointed) if scoped[user:get_player_name()] then -- shooter checks for the return value of def.on_use, and executes @@ -90,7 +97,7 @@ local function on_rclick(item, placer, pointed_thing) end ------------------ --- Sccope-check -- +-- Scope-check -- ------------------ -- Hide scope if currently wielded item is not the same item