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

33 lines
1.3 KiB
Lua
Raw Normal View History

local timers = {}
2015-02-08 23:51:02 +01:00
local SPAWN_INTERVAL = 5*60
2014-10-28 18:01:32 +01:00
minetest.register_on_chat_message(function(name, message, playername, player)
local cmd = "/spawn"
if message:sub(0, #cmd) == cmd then
if message == '/spawn' then
local player = minetest.get_player_by_name(name)
2015-06-10 17:14:58 +02:00
-- Checking timers
local timer_player = os.difftime(os.time(),timers[name])
if timer_player ~= nil and timer_player < SPAWN_INTERVAL then -- less than x minutes
minetest.chat_send_player(name, "Please retry later, you used spawn last time less than ".. SPAWN_INTERVAL .." seconds ago.")
minetest.chat_send_player(name, "Retry in: ".. SPAWN_INTERVAL-timer_player .." seconds.")
minetest.log("action","Player ".. name .." tried to respawn within forbidden interval.")
return false
end
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.")
timers[name] = os.time()
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
end
end)