Novas funcionalidades padronizadas

master
BrunoMine 2016-02-10 14:29:37 -02:00
parent 5521cf26cc
commit 192ee9acbd
6 changed files with 150 additions and 1 deletions

View File

@ -1,2 +1,9 @@
# Anti_Cracker
Modificação anti-cracker (anti-trapaça) para Servidor de Mineteste
Pacote de Modificações anti-cracker (anti-trapaça) para Servidor de Mineteste
Podes definir algumas diretrizes em diretrizes.lua
Catalogo de medidas
Medida Medida
11 Foi entendido que o jogador atravessou paredes de caverna

53
anti_nohup.lua Normal file
View File

@ -0,0 +1,53 @@
--
-- Mod Ant-Cracker
--
-- Ant-NoHup
--
-- Loop para verificar se o jogador esta usando nohup
verificar_nohup = function(name)
if name then
local player = minetest.get_player_by_name(name)
if player then
local pos = player:getpos()
local node = minetest.get_node(pos)
if
-- Esta no mesmo lugar que uma pedra
node.name == "default:stone"
-- Certifica que nao existe escavacao nas proximidades
and table.maxn(minetest.find_nodes_in_area(
{x=pos.x-3, y=pos.y-3, z=pos.z-3},
{x=pos.x+3, y=pos.y+3, z=pos.z+3},
{"default:stone", "default:stone_with_iron", "default:stone_with_coal", "default:stone_with_copper"}
)) == 343
-- Nao tem tunel vertical em cima
and table.maxn(minetest.find_nodes_in_area(
{x=pos.x-2, y=pos.y+12, z=pos.z-2},
{x=pos.x+2, y=pos.y+12, z=pos.z+2},
{"default:stone", "default:stone_with_iron", "default:stone_with_coal", "default:stone_with_copper"}
)) == 25
then
minetest.chat_send_player(name, "Morreste soterrado")
tomar_medida(name, 11, name.." aparentemente usou nohup em cavernas.")
player:set_hp(0)
minetest.after(tempo_verificar_nohup, verificar_nohup, name)
else
if pos.y < -100 then
minetest.after(tempo_verificar_nohup, verificar_nohup, name)
else
minetest.after(60, verificar_nohup, name)
end
end
end
end
end
-- Inicia o loop com jogadores que se conectam no servidor
minetest.register_on_joinplayer(function(player)
if player then
local name = player:get_player_name()
if minetest.check_player_privs(name, {nohup=true}) ~= true then
minetest.after(tempo_verificar_nohup, verificar_nohup, name)
end
end
end)

10
diretrizes.lua Normal file
View File

@ -0,0 +1,10 @@
--
-- Mod Ant-Cracker
--
-- Diretrizes
--
-- Tempo em segundos para verificar se o jogador esta
-- atravessando as paredes de uma caverna
tempo_verificar_nohup = 5

21
init.lua Normal file
View File

@ -0,0 +1,21 @@
--
-- Mod Ant-Cracker
--
-- Inicializador de scripts Lua
--
-- Notificador de Inicializador
local notificar = function(msg)
if minetest.setting_get("log_mods") then
minetest.debug("[ANT-CRACKER]"..msg)
end
end
local modpath = minetest.get_modpath("anti_cracker")
-- Carregar scripts
notificar("Carregando scripts...")
dofile(modpath.."/diretrizes.lua")
dofile(modpath.."/metodos.lua")
dofile(modpath.."/anti_nohup.lua")
notificar("OK")

16
medidas.lua Normal file
View File

@ -0,0 +1,16 @@
--
-- Mod Ant-Cracker
--
-- Medidas
--
-- Tomar medidas
tomar_medida = function(name, numero, msg, kick, tempo)
if not name or not tonumber(numero) or not msg then return end
local player = minetest.get_player_by_name(name)
if not player then return end
if kick and tonumber(tempo) then
kickar(name, numero, msg, tempo)
end
minetest.log("action", "[Ant-Cracker] Medida "..numero.." | "..msg)
end

42
metodos.lua Normal file
View File

@ -0,0 +1,42 @@
--
-- Mod Ant-Cracker
--
-- Metodos
--
-- Pegar um bloco do mapa
function pegar_node(pos)
local node = minetest.get_node(pos)
if node.name == "ignore" then
minetest.get_voxel_manip():read_from_map(pos, pos)
node = minetest.get_node(pos)
end
return node
end
-- Controlar jogadores kickados
local kickados = {}
local retirar_kick = function(name)
for _, pname in pairs(kickados) do
local Nkickados = {}
if name ~= pname then
Nkickados[name] = true
end
end
kickados = Nkickados
end
-- Kickar jogador
kickar = function(name, numero, msg, tempo)
if not name or not msg or not tonumber(tempo) or not tonumber(numero) then return end
minetest.kick_player(name, "[Ant-Cracker] Medida "..numero.." | "..msg)
kickados[name] = numero
minetest.after(tempo, retirar_kick, name)
end
-- Impedir jogadores kickados de entrar
minetest.register_on_prejoinplayer(function(name)
if tonumber(kickados[name]) then
return "[Ant-Charker] O nome "..name.." foi kickado temporariamente pela medida "..kickados[name]
end
end)