capturetheflag/mods/mtg/game_commands/init.lua

27 lines
754 B
Lua
Raw Normal View History

2019-01-08 21:24:35 +00:00
minetest.register_chatcommand("killme", {
description = "Kill yourself to respawn",
func = function(name)
local player = minetest.get_player_by_name(name)
if player then
minetest.log("action", name .. " ran /killme")
2019-01-08 21:24:35 +00:00
if minetest.settings:get_bool("enable_damage") then
player:set_hp(0)
return true
else
2019-03-05 13:55:49 +00:00
for _, callback in pairs(minetest.registered_on_respawnplayers) do
2019-01-08 21:24:35 +00:00
if callback(player) then
return true
end
end
-- There doesn't seem to be a way to get a default spawn pos
-- from the lua API
return false, "No static_spawnpoint defined"
end
else
-- Show error message if used when not logged in, eg: from IRC mod
return false, "You need to be online to be killed!"
end
end
})