1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-14 06:20:32 +01:00

- Fixing seawrecks' awards' itemstrings in U-boots

- Tracking (again) _misc (untracking has probably disabled the IRC bot MFF-Bot)
This commit is contained in:
LeMagnesium 2014-11-08 12:41:57 +01:00
parent 6a8e1c9bac
commit 7024b29415
9 changed files with 453 additions and 4 deletions

63
mods/_misc/ban.lua Normal file
View File

@ -0,0 +1,63 @@
future_ban_list = {}
local file = io.open(minetest.get_worldpath().."/future_banlist.txt", "r")
if file then
future_ban_list = minetest.deserialize(file:read("*all"))
file:close()
if not future_ban_list then
future_ban_list = {}
end
end
local function save_file()
local file = io.open(minetest.get_worldpath().."/future_banlist.txt", "w")
if file then
file:write(minetest.serialize(future_ban_list))
file:close()
end
end
minetest.register_chatcommand("future_ban", {
params = "<playername> | leave playername out to see the future ban list",
description = "The player will be banned when trying to join",
privs = {ban=true},
func = function(name, param)
if param == "" then
minetest.chat_send_player(name, "Future ban list: " .. dump(future_ban_list))
return
end
if not minetest.env:get_player_by_name(param) then
table.insert(future_ban_list, param)
minetest.chat_send_player(name, param .. " to future ban list added.")
minetest.log("action", name .. " added " .. param .. " to future ban list.")
save_file()
return
end
if not minetest.ban_player(param) then
table.insert(future_ban_list, param)
minetest.chat_send_player(name, desc .. " to future ban list added.")
minetest.log("action", name .. " added " .. desc .. " to future ban list.")
save_file()
else
local desc = minetest.get_ban_description(param)
minetest.chat_send_player(name, "Banned " .. desc .. ".")
minetest.log("action", name .. " bans " .. desc .. ".")
end
end
})
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
for i,n in ipairs(future_ban_list) do
if n == name then
if not minetest.ban_player(name) then
minetest.chat_send_player(name, "Failed to ban player " .. name .. " (from future ban list).")
else
local desc = minetest.get_ban_description(name)
minetest.log("action", desc .. " banned (from future ban list).")
table.remove(future_ban_list, i)
save_file()
end
end
end
end)

View File

@ -0,0 +1,25 @@
-- This allows me to chat and use basic commands without being in-game
-- Based on the External Command mod by Menche
minetest.register_globalstep(
function(dtime)
f = (io.open(minetest.get_worldpath("external_cmd").."/message", "r"))
if f ~= nil then
local message = f:read("*line")
f:close()
os.remove(minetest.get_worldpath("external_cmd").."/message")
if message ~= nil then
local cmd, param = string.match(message, "^/([^ ]+) *(.*)")
if not param then
param = ""
end
local cmd_def = minetest.chatcommands[cmd]
if cmd_def then
cmd_def.func("CraigyDavi", param)
else
minetest.chat_send_all("<CraigyDavi> "..message)
end
end
end
end
)

15
mods/_misc/chatlog.lua Normal file
View File

@ -0,0 +1,15 @@
local chatlog = minetest.get_worldpath().."/chatlog.txt"
monthfirst = true -- Wheter the 1st of Feb should be 1/2/13(monthfirst = true) or 2/1/13(monthfirst = false)
function playerspeak(name,msg)
f = io.open(chatlog, "a")
if monthfirst then
f:write(os.date("(%m/%d/%y %X) ["..name.."]: "..msg.."\n"))
else
f:write(os.date("(%d/%m/%y %X) ["..name.."]: "..msg.."\n"))
end
f:close()
end
minetest.register_on_chat_message(playerspeak)

View File

@ -56,14 +56,14 @@ end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "irc" then return end
local name = player:get_player_name()
if fields.accept then
local name = player:get_player_name()
if fields.accept then
minetest.chat_send_player(name, "Merci d'avoir accepte les regles, vous etes maintenant capable de parler.")
minetest.chat_send_player(name, "Pour plus d'informations tapez /news")
local privs = minetest.get_player_privs(name)
privs.shout = true
minetest.set_player_privs(name, privs)
end
--end
return
elseif fields.decline then
minetest.kick_player(name, "Aurevoir ! Vous devez accepter les règles de l'irc pour jouer sur le serveur (revennez si vous changez d'avis).")

48
mods/_misc/news.lua Normal file
View File

@ -0,0 +1,48 @@
local news = {}
news.path = minetest.get_worldpath()
function news.formspec(player,article)
if ( article == "" or article == nil ) then
article = "news.txt"
else
article = "news_"..article..".txt"
end
local newsfile = io.open(news.path.."/"..article,"r")
local formspec = "size[12,10]"
if newsfile ~= nil then
local newscontent = newsfile:read("*a")
formspec = formspec.."textarea[.25,.25;12,10;news;;"..newscontent.."]"
else
formspec = formspec.."label[.25,.25;Article does not exist]"
end
formspec = formspec.."button_exit[.25,9;2,1;exit;Fermer"
if ( newsfile ~= nil ) then
newsfile:close()
end
return formspec
end
function news.show_formspec(player)
local name = player:get_player_name()
minetest.show_formspec(name,"news",news.formspec(player))
minetest.log('action','Showing formspec to '..name)
end
minetest.register_chatcommand("news",{
params = "<article>",
description="Montre les news du serveur",
func = function (name,params)
local player = minetest.get_player_by_name(name)
minetest.show_formspec(name,"news",news.formspec(player,params))
end,
})
minetest.register_on_joinplayer(function (player)
minetest.after(5,news.show_formspec,player)
end)

View File

@ -0,0 +1,53 @@
local wield={}
local huds={}
local dtimes={}
local dlimit=60
local airhudmod = minetest.get_modpath("4air")
local function get_desc(item)
if minetest.registered_nodes[item] then return minetest.registered_nodes[item]["description"] end
if minetest.registered_items[item] then return minetest.registered_items[item]["description"] end
if minetest.registered_craftitems[item] then return minetest.registered_craftitems[item]["description"] end
if minetest.registered_tools[item] then return minetest.registered_tools[item]["description"] end
return ""
end
minetest.register_globalstep(function(dtime)
local players = minetest.get_connected_players()
for i,player in ipairs(players) do
local pll = player:get_player_name()
local wstack = player:get_wielded_item():get_name()
local shift = player:get_player_control()['sneak']
local meta = player:get_wielded_item():get_metadata()
local desc
if not shift then
desc = wstack
else
desc = wstack
end
if dtimes[pll] then dtimes[pll]=dtimes[pll]+dtime else dtimes[pll]=0 end
if dtimes[pll]>dlimit then
if huds[pll] then player:hud_remove(huds[pll]) end
dtimes[pll]=dlimit+1
end
if wstack ~= wield[pll] then
wield[pll]=wstack
dtimes[pll]=0
if huds[pll]
then
player:hud_remove(huds[pll])
end
local off = {x=0, y=-70}
if airhudmod then off.y=off.y-20 end
huds[pll] = player:hud_add({
hud_elem_type = "text",
position = {x=0.5, y=1},
offset = off,
alignment = {x=0, y=0},
number = 0xFFFFFF ,
text = desc,
})
end
end
end)

211
mods/_misc/seen.lua Normal file
View File

@ -0,0 +1,211 @@
seendebug = true
local last_time = os.time()
local save_interval = 60
if minetest.setting_get("seen.save_interval") ~= nil then
local save_int = minetest.setting_get("seen.save_interval")
if tonumber(save_int) > 20 then
save_interval = save_int
end
end
local function save_data(sett, data)
if sett ~= nil then
data_ser = minetest.serialize(data)
sett:set("data", data_ser)
sett:write()
else
minetest.chat_send_all("Seen Mod: Saving data failed. Please shout at the server admin!")
end
end
local function load_data(sett, field)
local loaded = sett:get("data")
local def = sett:get("default")
if loaded ~= nil then
local data = minetest.deserialize(loaded)
else
local data = {}
end
end
local function relative_time (time)
local diff = os.time() - time
if diff == 0 then
return "now"
elseif diff > 0 then
local day_diff = math.floor(diff/86400)
if day_diff == 0 then
if diff < 60 then
return "a few seconds ago"
end
if diff < 120 then
return "1 minute ago."
end
if diff < 3600 then
return tostring(math.floor(diff/60)).." minutes ago"
end
if diff < 7200 then
return "1 hour ago"
end
if diff < 86400 then
return tostring(math.floor(diff/3600)).." hours ago"
end
end
if day_diff == 1 then
return "yesterday"
end
if day_diff < 7 then
return tostring(day_diff).." days ago"
end
if day_diff < 31 then
return tostring(math.ceil(day_diff/7)).." weeks ago"
end
if day_diff < 60 then
return "last month"
end
return os.date("%B %Y", time)
else
local diff = math.abs(diff)
local day_diff = math.floor(diff/86400)
if day_diff == 0 then
if diff < 120 then
return "in a minute"
end
if diff < 3600 then
return "in "..tostring(math.floor(diff/60)).." minutes"
end
if diff < 7200 then
return "in an hour"
end
if diff < 86400 then
return "in "..tostring(math.floor(diff/3600)).." hours"
end
end
if day_diff == 1 then
return "tomorrow"
end
if day_diff < 4 then
return os.date("%A", time)
end
if day_diff < 7 + (7 - tonumber(os.date("%w"))) then
return "next week"
end
if math.ceil (day_diff / 7) < 4 then
return "in "..tostring(math.ceil(day_diff/7)).." weeks"
end
if tonumber(os.date("%m", time)) == tonumber(os.date("%m")) + 1 then
return "next month"
end
return os.date("%B %Y", time);
end
end
local function print_r(tab,com)
if seendebug == true then
print("DEBUG: "..com)
table.foreach(tab, print)
print("-----")
return true
else
return false
end
end
local function debug(var, com)
if seendebug == true then
print("DEBUG: "..com)
print(var)
minetest.chat_send_all("DEBUG: "..var.."// "..com)
print("-----")
return true
else
return false
end
end
local config_file = minetest.get_worldpath().."/seen.txt"
--in case of not existant config file, it
--will create it
local file_desc = io.open(config_file, "a")
file_desc:close()
--create config instance
local config = Settings(config_file)
local data
local seens = {}
data = config:get("data")
if data ~= nil then
seens = minetest.deserialize(data)
for _, player in pairs( minetest.get_connected_players() ) do
name = player:get_player_name()
seens[name] = os.time()
end
else
seens = {}
for _, player in pairs( minetest.get_connected_players() ) do
name = player:get_player_name()
seens[name] = os.time()
end
end
save_data(config, seens)
minetest.register_on_newplayer(function(player)
name = player:get_player_name()
seens[name] = os.time()
save_data(config, seens)
return true
end)
minetest.register_on_joinplayer(function(player)
name = player:get_player_name()
seens[name] = os.time()
save_data(config, seens)
return true
end)
minetest.register_on_leaveplayer(function(player)
name = player:get_player_name()
seens[name] = os.time()
save_data(config, seens)
return true
end)
minetest.register_on_shutdown(function()
for _, player in pairs( minetest.get_connected_players() ) do
name = player:get_player_name()
seens[name] = os.time()
end
save_data(config, seens)
return true
end)
minetest.register_globalstep(function ( dtime )
if os.time() >= last_time then
last_time = os.time() + save_interval
for _, player in pairs( minetest.get_connected_players() ) do
name = player:get_player_name()
seens[name] = os.time()
end
save_data(config, seens)
end
end);
minetest.register_chatcommand("seen", {
params = "<name>",
description = "Recherche quand un joueur etait en ligne pour la derniere fois.",
func = function(name, param)
local player = minetest.get_player_by_name(name)
if not player then
return
end
if param ~= nil and param ~= "" then
if seens[param] ~= nil then
minetest.chat_send_player(name, param.." etait en ligne pour la derniere fois "..relative_time(seens[param]))
else
minetest.chat_send_player(name, "Il n'y a aucune donnees sur "..param..". Peut-etre que l'identifiant n'est pas correcte ?")
end
end
end,
})

View File

@ -0,0 +1,34 @@
-- By VanessaE, sfan5, and kaeza.
local disallowed = {
["guest"] = "Les comptes Guest/invités sont désactivés sur ce serveur. "..
"S'il vous plaît, choisissez un nom d'utilisateur correcte et réessayez.",
["^[0-9]+$"] = "Les identifiants contenant uniquement des chiffres sont désactivés sur ce serveur. "..
"S'il vous plaît, choisissez un nom d'utilisateur correcte et réessayez.",
["[0-9].-[0-9].-[0-9].-[0-9].-[0-9]"] = "Trop de chiffres dans votre identifiant. "..
"S'il vous plaît, réessayez avec moins de 5 chiffres dans votre identifiant.",
["[4a]dm[1il]n"] = "Ce nom d'utilisateur est désactivé pour des raisons évidentes. "..
"Merci de choisir un autre nom d'utilisateur."
}
minetest.register_on_prejoinplayer(function(name, ip)
local lname = name:lower()
for re, reason in pairs(disallowed) do
if lname:find(re) then
return reason
end
end
if #name < 2 then
return "Identifiant trop court. "..
"S'il vous plaît, choisissez un identifiant avec au moins 2 lettres et réessayez."
end
if #name > 18 then
return "Identifiant trop long. "..
"S'il vous plaît, choisissez un identifiant avec moins de 18 caractères."
end
end)

View File

@ -97,7 +97,7 @@ minetest.register_node("seawrecks:ubootchest", {
local kind_of_price = math.floor(math.random()*2)
local amount_of_price = math.floor(math.random()*10)+1
local ingot_price = {"default:steel_ingot","default:copper_ingot","default:gold_ingot","moreores:tin_ingot","moreore:silver_ingot"}
local ingot_price = {"default:steel_ingot","default:copper_ingot","default:gold_ingot","moreores:tin_ingot","moreores:silver_ingot"}
local price_group = {"",""}
choosen_ingot = math.floor(math.random()*5)+1
price_group[1] = ingot_price[choosen_ingot].." "..amount_of_price