mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-16 23:40:31 +01:00
Merge branch 'master' of github.com:Ombridride/minetest-minetestforfun-server
This commit is contained in:
commit
435e6037ef
1
minetestforfun_game/mods/sethome/depends.txt
Executable file
1
minetestforfun_game/mods/sethome/depends.txt
Executable file
|
@ -0,0 +1 @@
|
||||||
|
action_timers
|
|
@ -1,13 +1,9 @@
|
||||||
home = {}
|
home = {}
|
||||||
|
|
||||||
home.homes_file = {["real"] = minetest.get_worldpath() .. "/realhomes",
|
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.g_timers = {["real"] = {}, ["nether"] = {}}
|
home.time = 20 * 60
|
||||||
home.s_timers = {["real"] = {}, ["nether"] = {}}
|
|
||||||
|
|
||||||
home.GET_HOME_INTERVAL = 20*60
|
|
||||||
home.SET_HOME_INTERVAL = 20*60
|
|
||||||
|
|
||||||
home.sethome = function(name)
|
home.sethome = function(name)
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
|
@ -16,25 +12,33 @@ home.sethome = function(name)
|
||||||
if pos.y < -19600 then
|
if pos.y < -19600 then
|
||||||
p_status = "nether"
|
p_status = "nether"
|
||||||
end
|
end
|
||||||
if home.s_timers[p_status][name] ~= nil then
|
|
||||||
local timer_player = os.difftime(os.time(),home.s_timers[p_status][name])
|
local function assign_home()
|
||||||
if timer_player < home.SET_HOME_INTERVAL then -- less than x minutes
|
home.homepos[p_status][name] = pos
|
||||||
minetest.chat_send_player(name, "Please retry later, you used sethome last time less than ".. home.SET_HOME_INTERVAL .." seconds ago.")
|
minetest.chat_send_player(name, "Home set!")
|
||||||
minetest.chat_send_player(name, "Retry in: ".. home.SET_HOME_INTERVAL-timer_player .." seconds.")
|
local output = io.open(home.homes_file[p_status], "w")
|
||||||
|
output:write(minetest.serialize(home.homepos[p_status]))
|
||||||
|
io.close(output)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if not action_timers.api.get_timer("sethome_" .. name) then
|
||||||
|
if home.homepos[p_status][name] ~= pos then
|
||||||
|
home.homepos[p_status][name] = pos
|
||||||
|
end
|
||||||
|
action_timers.api.register_timer("sethome_" .. name, home.time)
|
||||||
|
return assign_home()
|
||||||
|
else
|
||||||
|
local res = action_timers.api.do_action("sethome_" .. name, assign_home)
|
||||||
|
if tonumber(res) then
|
||||||
|
minetest.chat_send_player(name, "Please retry later, you used sethome last time less than ".. home.time .." seconds ago.")
|
||||||
|
minetest.chat_send_player(name, "Retry in: ".. math.floor(res) .." seconds.")
|
||||||
minetest.log("action","Player ".. name .." tried to sethome within forbidden interval.")
|
minetest.log("action","Player ".. name .." tried to sethome within forbidden interval.")
|
||||||
return false
|
return false
|
||||||
|
elseif res == true then
|
||||||
|
return res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if home.homepos[p_status][player:get_player_name()] ~= pos then
|
|
||||||
home.s_timers[p_status][name] = os.time()
|
|
||||||
home.homepos[p_status][player:get_player_name()] = pos
|
|
||||||
minetest.chat_send_player(name, "Home set!")
|
|
||||||
local output = io.open(home.homes_file[p_status], "w")
|
|
||||||
output:write(minetest.serialize(home.homepos[p_status]))
|
|
||||||
io.close(output)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
home.tohome = function(name)
|
home.tohome = function(name)
|
||||||
|
@ -48,20 +52,28 @@ home.tohome = function(name)
|
||||||
p_status = "nether"
|
p_status = "nether"
|
||||||
end
|
end
|
||||||
if home.homepos[p_status][name] then
|
if home.homepos[p_status][name] then
|
||||||
if home.g_timers[p_status][name] ~= nil then
|
|
||||||
local timer_player = os.difftime(os.time(),home.g_timers[p_status][name])
|
local function go_to_home()
|
||||||
if timer_player < home.GET_HOME_INTERVAL then -- less than x minutes
|
player:setpos(home.homepos[p_status][player:get_player_name()])
|
||||||
minetest.chat_send_player(name, "Please retry later, you used home last time less than ".. home.GET_HOME_INTERVAL .." seconds ago.")
|
minetest.chat_send_player(name, "Teleported to home!")
|
||||||
minetest.chat_send_player(name, "Retry in: ".. home.GET_HOME_INTERVAL-timer_player .." seconds.")
|
minetest.log("action","Player ".. name .." teleported to home. Next teleportation allowed in ".. home.time .." seconds.")
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if not action_timers.api.get_timer("home_" .. name) then
|
||||||
|
action_timers.api.register_timer("home_" .. name, home.time)
|
||||||
|
return go_to_home()
|
||||||
|
else
|
||||||
|
local res = action_timers.api.do_action("home_" .. name, go_to_home)
|
||||||
|
if tonumber(res) then
|
||||||
|
minetest.chat_send_player(name, "Please retry later, you used home last time less than ".. home.time .." seconds ago.")
|
||||||
|
minetest.chat_send_player(name, "Retry in: ".. math.floor(res) .." seconds.")
|
||||||
minetest.log("action","Player ".. name .." tried to teleport home within forbidden interval.")
|
minetest.log("action","Player ".. name .." tried to teleport home within forbidden interval.")
|
||||||
return false
|
return false
|
||||||
|
elseif res == true then
|
||||||
|
return res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
player:setpos(home.homepos[p_status][player:get_player_name()])
|
|
||||||
minetest.chat_send_player(name, "Teleported to home!")
|
|
||||||
minetest.log("action","Player ".. name .." teleported to home. Last teleportation allowed in ".. home.GET_HOME_INTERVAL .." seconds.")
|
|
||||||
home.g_timers[p_status][name] = os.time()
|
|
||||||
return true
|
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, "Set a home using /sethome")
|
minetest.chat_send_player(name, "Set a home using /sethome")
|
||||||
return false
|
return false
|
||||||
|
|
62
mods/action_timers/init.lua
Executable file
62
mods/action_timers/init.lua
Executable file
|
@ -0,0 +1,62 @@
|
||||||
|
-------------------------------
|
||||||
|
-- Action timers
|
||||||
|
-- Mod handling action timers
|
||||||
|
--
|
||||||
|
|
||||||
|
action_timers = {}
|
||||||
|
action_timers.timers = {}
|
||||||
|
action_timers.limits = {}
|
||||||
|
|
||||||
|
action_timers.api = {}
|
||||||
|
|
||||||
|
|
||||||
|
function action_timers.api.register_timer(name, limit)
|
||||||
|
if action_timers.timers[name] then
|
||||||
|
minetest.log("error", "[ACTimers] Cannot register timer " .. name .. " a second time")
|
||||||
|
return
|
||||||
|
elseif not limit then
|
||||||
|
minetest.log("error", "[ACTimers] Cannot register timer " .. name .. " without limit")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
action_timers.timers[name] = limit
|
||||||
|
action_timers.limits[name] = limit
|
||||||
|
minetest.log("action", "[ACTimers] Timer " .. name .. " registered with time limit " .. limit)
|
||||||
|
end
|
||||||
|
|
||||||
|
function action_timers.api.do_action(name, func, params)
|
||||||
|
if not action_timers.timers[name] then
|
||||||
|
minetest.log("error", "[ACTimers] Timer " .. name .. " doesn't exist")
|
||||||
|
return
|
||||||
|
elseif not func then
|
||||||
|
minetest.log("error", "[ACTimers] Function passed to time checker for " .. name .. " is nil")
|
||||||
|
return
|
||||||
|
elseif action_timers.timers[name] > 0 then
|
||||||
|
minetest.log("error", "[ACTimers] Timer " .. name .. " is still up to 0")
|
||||||
|
return action_timers.timers[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
action_timers.timers[name] = action_timers.limits[name]
|
||||||
|
if not params then
|
||||||
|
print("func()")
|
||||||
|
return func()
|
||||||
|
else
|
||||||
|
print("func(unpack(params))")
|
||||||
|
return func(unpack(params))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function action_timers.api.get_timer(name)
|
||||||
|
return action_timers.timers[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
for name, _ in pairs(action_timers.timers) do
|
||||||
|
action_timers.timers[name] = action_timers.timers[name] - dtime
|
||||||
|
if action_timers.timers[name] < 0 then
|
||||||
|
action_timers.timers[name] = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.log("action", "[ACTimers] Loaded")
|
|
@ -1,5 +1,4 @@
|
||||||
irc.whereis_timer = {}
|
local whereis_interval = 120
|
||||||
irc.whereis_timer_max_limit = 120
|
|
||||||
irc.bot_commands = {}
|
irc.bot_commands = {}
|
||||||
|
|
||||||
function irc:check_botcmd(msg)
|
function irc:check_botcmd(msg)
|
||||||
|
@ -117,19 +116,28 @@ irc:register_bot_command("whereis", {
|
||||||
if not player then
|
if not player then
|
||||||
return false, "There is no player named '"..args.."'"
|
return false, "There is no player named '"..args.."'"
|
||||||
end
|
end
|
||||||
if irc.whereis_timer[user.nick] ~= nil then
|
|
||||||
local timer_player = os.difftime(os.time(),irc.whereis_timer[user.nick])
|
local function say_where_is()
|
||||||
if timer_player < irc.whereis_timer_max_limit then
|
local fmt = "Player %s is at (%.2f,%.2f,%.2f)"
|
||||||
|
local pos = player:getpos()
|
||||||
|
minetest.log("action","IRC user ".. user.nick.."!"..user.username.."@"..user.host.." asked for position of player "..player:get_player_name())
|
||||||
|
minetest.chat_send_player(player:get_player_name(),"IRC user ".. user.nick.."!"..user.username.."@"..user.host.." asked for your position")
|
||||||
|
return true, fmt:format(args, pos.x, pos.y, pos.z)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not action_timers.api.get_timer("whereis_" .. user.nick) then
|
||||||
|
action_timers.api.register_timer("whereis_" .. user.nick, whereis_interval)
|
||||||
|
return say_where_is()
|
||||||
|
else
|
||||||
|
local res = action_timers.api.do_action("whereis_" .. user.nick, say_where_is)
|
||||||
|
if tonumber(res) then
|
||||||
local answer = "Command used too often, retry in %d seconds."
|
local answer = "Command used too often, retry in %d seconds."
|
||||||
return false,answer:format(irc.whereis_timer_max_limit - timer_player)
|
return false,answer:format(math.floor(res))
|
||||||
|
else
|
||||||
|
print(res)
|
||||||
|
return res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local fmt = "Player %s is at (%.2f,%.2f,%.2f)"
|
|
||||||
local pos = player:getpos()
|
|
||||||
irc.whereis_timer[user.nick] = os.time()
|
|
||||||
minetest.log("action","IRC user ".. user.nick.."!"..user.username.."@"..user.host.." asked for position of player "..player:get_player_name())
|
|
||||||
minetest.chat_send_player(player:get_player_name(),"IRC user ".. user.nick.."!"..user.username.."@"..user.host.." asked for your position")
|
|
||||||
return true, fmt:format(args, pos.x, pos.y, pos.z)
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
1
mods/irc/depends.txt
Executable file
1
mods/irc/depends.txt
Executable file
|
@ -0,0 +1 @@
|
||||||
|
action_timers
|
1
mods/spawn/depends.txt
Executable file
1
mods/spawn/depends.txt
Executable file
|
@ -0,0 +1 @@
|
||||||
|
action_timers
|
|
@ -1,32 +1,38 @@
|
||||||
local timers = {}
|
|
||||||
local SPAWN_INTERVAL = 5*60
|
local SPAWN_INTERVAL = 5*60
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_chat_message(function(name, message, playername, player)
|
minetest.register_chatcommand("spawn", {
|
||||||
local cmd = "/spawn"
|
description = "Teleport a player to the defined spawnpoint",
|
||||||
if message:sub(0, #cmd) == cmd then
|
func = function(name)
|
||||||
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
|
|
||||||
|
|
||||||
|
local function go_to_spawn()
|
||||||
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.")
|
minetest.log("action","Player ".. name .." respawned. Next allowed respawn in ".. SPAWN_INTERVAL .." seconds.")
|
||||||
timers[name] = os.time()
|
|
||||||
return true
|
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
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Checking timers
|
||||||
|
if not action_timers.api.get_timer("spawn_" .. name) then
|
||||||
|
action_timers.api.register_timer("spawn_" .. name, SPAWN_INTERVAL)
|
||||||
|
return go_to_spawn()
|
||||||
|
else
|
||||||
|
local res = action_timers.api.do_action("spawn_" .. name, go_to_spawn)
|
||||||
|
print(res)
|
||||||
|
if tonumber(res) then
|
||||||
|
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: ".. math.floor(res) .." seconds.")
|
||||||
|
minetest.log("action","Player ".. name .." tried to respawn within forbidden interval.")
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
})
|
||||||
|
|
|
@ -7,6 +7,9 @@ News de FR - MinetestForFun (Survival - PVP - Hardcore)
|
||||||
---Informations---
|
---Informations---
|
||||||
Le générateur de map actuel est maintenant STABLE, il ne sera plus réinitialisé/reset !
|
Le générateur de map actuel est maintenant STABLE, il ne sera plus réinitialisé/reset !
|
||||||
|
|
||||||
|
---??/??/2015--- (Remerciements : ???)
|
||||||
|
Ajout du mod "action_timers" (centralisation de la gestion des compteurs de temps pour spawn, sethome, home, et whereis)
|
||||||
|
|
||||||
---09/07/2015--- (Remerciements : Gael-de-Sailly, gravgun, Obani, LeMagnesium/Mg, , crabman77/crabman, mgl512/Le_Docteur)
|
---09/07/2015--- (Remerciements : Gael-de-Sailly, gravgun, Obani, LeMagnesium/Mg, , crabman77/crabman, mgl512/Le_Docteur)
|
||||||
MAJ du mod "broomstick" (le Balai Volant/Broomstick est maintenant disponible ! Je vous invite à aller consulter son craft, vous pourrez voler 2 minutes en échange de 190 de mana, voila de quoi s'installer sur une île flottant dnas le ciel !)
|
MAJ du mod "broomstick" (le Balai Volant/Broomstick est maintenant disponible ! Je vous invite à aller consulter son craft, vous pourrez voler 2 minutes en échange de 190 de mana, voila de quoi s'installer sur une île flottant dnas le ciel !)
|
||||||
/!\ Ajout de la SuperVision/Monitoring du serveur, pour y accéder allez sur : Site officiel > LE JEU > Statut du Serveur /!\
|
/!\ Ajout de la SuperVision/Monitoring du serveur, pour y accéder allez sur : Site officiel > LE JEU > Statut du Serveur /!\
|
||||||
|
|
|
@ -214,3 +214,5 @@ load_mod_future_ban = false
|
||||||
load_mod_textures = false
|
load_mod_textures = false
|
||||||
load_mod_snowdrift = false
|
load_mod_snowdrift = false
|
||||||
load_mod_sounds = false
|
load_mod_sounds = false
|
||||||
|
|
||||||
|
load_mod_action_timers = true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user