mirror of
https://github.com/minetest-mods/3d_armor.git
synced 2024-11-26 14:23:45 +01:00
Merge pull request #45 from tenplus1/patch-7
Added insta-kill ability for tools/commands
This commit is contained in:
commit
36737441d4
@ -513,6 +513,12 @@ end
|
|||||||
minetest.register_on_player_hpchange(function(player, hp_change)
|
minetest.register_on_player_hpchange(function(player, hp_change)
|
||||||
local name, player_inv, armor_inv = armor:get_valid_player(player, "[on_hpchange]")
|
local name, player_inv, armor_inv = armor:get_valid_player(player, "[on_hpchange]")
|
||||||
if name and hp_change < 0 then
|
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 heal_max = 0
|
||||||
local state = 0
|
local state = 0
|
||||||
local items = 0
|
local items = 0
|
||||||
@ -599,3 +605,15 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end
|
end
|
||||||
armor.timer = 0
|
armor.timer = 0
|
||||||
end)
|
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,
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user