46 lines
1.4 KiB
Lua
46 lines
1.4 KiB
Lua
dofile(minetest.get_modpath("lifesteal_mod") .. "/heart.lua")
|
|
dofile(minetest.get_modpath("lifesteal_mod") .. "/withdraw.lua")
|
|
|
|
minetest.register_on_joinplayer(function(player)
|
|
local meta = player:get_meta()
|
|
local health = meta:get_int("health")
|
|
if health == 0 and meta:get_int("dead") ~= 1 then
|
|
meta:set_int("health", 22)
|
|
elseif meta:get_int("dead") == 1 then
|
|
local name = player:get_player_name()
|
|
minetest.kick_player(name, "You died on a lifesteal server.")
|
|
end
|
|
player:set_hp(meta:get_int("health"))
|
|
player:set_properties({
|
|
hp_max = health
|
|
})
|
|
end)
|
|
|
|
minetest.register_on_dieplayer(function(player, reason)
|
|
local meta = player:get_meta()
|
|
local health = meta:get_int("health")
|
|
local health = health - 2
|
|
meta:set_int("health", health)
|
|
if meta:get_int("health") == 0 then
|
|
meta:set_int("dead", 1)
|
|
local name = player:get_player_name()
|
|
minetest.kick_player(name, "You died on a lifesteal server.")
|
|
end
|
|
end)
|
|
|
|
minetest.register_on_respawnplayer(function(player)
|
|
local meta = player:get_meta()
|
|
local health = meta:get_int("health")
|
|
if meta:get_int("health") == 0 then
|
|
meta:set_int("dead", 1)
|
|
local name = player:get_player_name()
|
|
minetest.kick_player(name, "You died on a lifesteal server.")
|
|
else
|
|
player:set_hp(meta:get_int("health"))
|
|
player:set_properties({
|
|
hp_max = health
|
|
})
|
|
end
|
|
end)
|
|
|
|
minetest.register_on_punchplayer(on_punchplayer) |