Added insta-kill ability for tools/commands

Some armor was too powerful that killing yourself to respawn wouldn't work or instant kill tools for admin didn't have effect, so I've added a check so that if the player is dealt with more than -100 damage points it instantly kills them but doesn't damage armor.  Also added /kill command.
This commit is contained in:
tenplus1 2016-02-08 19:05:32 +00:00
parent 0d5cf6d58a
commit 5a112547e6

View File

@ -513,6 +513,12 @@ end
minetest.register_on_player_hpchange(function(player, hp_change)
local name, player_inv, armor_inv = armor:get_valid_player(player, "[on_hpchange]")
if name and hp_change < 0 then
-- used for insta kill tools/commands like /kill (doesnt damage armor)
if hp_change < -100 then
return hp_change
end
local heal_max = 0
local state = 0
local items = 0
@ -599,3 +605,15 @@ minetest.register_globalstep(function(dtime)
end
armor.timer = 0
end)
-- kill player when command issued
minetest.register_chatcommand("kill", {
params = "<name>",
description = "Kills player instantly",
func = function(name, param)
local player = minetest.get_player_by_name(name)
if player then
player:set_hp(-1001)
end
end,
})