Make cloaked players invincible

This commit is contained in:
luk3yx 2019-02-24 11:52:37 +13:00
parent be3777d278
commit e32aca2621
1 changed files with 11 additions and 0 deletions

View File

@ -254,3 +254,14 @@ function cloaking.is_cloaked(player)
if type(player) ~= "string" then player = player:get_player_name() end
return cloaked_players[player] and true or false
end
-- Prevent cloaked players dying
minetest.register_on_player_hpchange(function(player, hp_change)
if player and hp_change < 0 then
local name = player:get_player_name()
if cloaked_players[name] then
hp_change = 0 - hp_change
end
end
return hp_change
end, true)