1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-14 14:30:34 +01:00
server-nalc/mods/spawn/init.lua

24 lines
817 B
Lua
Raw Normal View History

2015-02-08 23:51:02 +01:00
local SPAWN_INTERVAL = 5*60
minetest.register_chatcommand("spawn", {
description = "Teleport a player to the defined spawnpoint",
func = function(name)
local player = minetest.get_player_by_name(name)
local function go_to_spawn()
2014-10-28 18:01:32 +01:00
if minetest.setting_get_pos("static_spawnpoint") then
minetest.chat_send_player(player:get_player_name(), "Teleporting to spawn...")
player:setpos(minetest.setting_get_pos("static_spawnpoint"))
minetest.log("action","Player ".. name .." respawned. Next allowed respawn in ".. SPAWN_INTERVAL .." seconds.")
return true
2014-10-28 18:01:32 +01:00
else
minetest.chat_send_player(player:get_player_name(), "ERROR: No spawn point is set on this server!")
return false
2014-10-28 18:01:32 +01:00
end
end
action_timers.wrapper(name, "spawn", "spawn_" .. name, SPAWN_INTERVAL, go_to_spawn, {})
2014-10-28 18:01:32 +01:00
end
})