1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-25 02:00:37 +01:00

Added spawn's timer and reduced interval for home

- HOME_INTERVAL is now 20 minutes
- Added spawn's timer : interval is 10 minutes
This commit is contained in:
LeMagnesium 2015-02-06 19:59:09 +01:00
parent f2da93525a
commit 030e104df3
2 changed files with 19 additions and 2 deletions

View File

@ -4,7 +4,7 @@ home.homes_file = {["real"] = minetest.get_worldpath() .. "/realhomes",
["nether"] = minetest.get_worldpath() .. "/netherhomes"} ["nether"] = minetest.get_worldpath() .. "/netherhomes"}
home.homepos = {["real"] = {}, ["nether"] = {}} home.homepos = {["real"] = {}, ["nether"] = {}}
home.timers = {} home.timers = {}
home.HOME_INTERVAL = 30*60 home.HOME_INTERVAL = 20*60
home.sethome = function(name) home.sethome = function(name)
local player = minetest.env:get_player_by_name(name) local player = minetest.env:get_player_by_name(name)

View File

@ -1,15 +1,32 @@
local timers = {}
local SPAWN_INTERVAL = 10*60
minetest.register_on_chat_message(function(name, message, playername, player) minetest.register_on_chat_message(function(name, message, playername, player)
local cmd = "/spawn" local cmd = "/spawn"
if message:sub(0, #cmd) == cmd then if message:sub(0, #cmd) == cmd then
if message == '/spawn' then if message == '/spawn' then
local player = minetest.get_player_by_name(name) local player = minetest.get_player_by_name(name)
-- 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
if minetest.setting_get_pos("static_spawnpoint") then if minetest.setting_get_pos("static_spawnpoint") then
minetest.chat_send_player(player:get_player_name(), "Teleporting to spawn...") minetest.chat_send_player(player:get_player_name(), "Teleporting to spawn...")
player:setpos(minetest.setting_get_pos("static_spawnpoint")) 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
else else
minetest.chat_send_player(player:get_player_name(), "ERROR: No spawn point is set on this server!") minetest.chat_send_player(player:get_player_name(), "ERROR: No spawn point is set on this server!")
return false
end end
return true
end end
end end
end) end)