Ajuste sobre abertura do servidor
[gestor/gestor2.git] / protetor.lua
blob388c4657519ace2b42bd04c5c1c871e139e3c3bb
1 --[[
2 Mod Gestor para Minetest
3 Gestor v1.0 Copyright (C) 2016 BrunoMine (https://github.com/BrunoMine)
5 Recebeste uma cópia da GNU Lesser General
6 Public License junto com esse software,
7 se não, veja em <http://www.gnu.org/licenses/>.
9 Protetor
12 -- Proteger uma area
13 gestor.proteger_area = function(name, PlayerName, AreaName, pos1, pos2, silencio)
14 if not tostring(PlayerName) or not tostring(AreaName) then return "Faltam argumentos ou estao incorretos" end
15 if not areas or not area.add then return "Faltou mod areas" end
16 local param = tostring(PlayerName).." "..tostring(AreaName)
17 local found, _, ownername, areaname = param:find('^([^ ]+) (.+)$')
19 if not found then
20 return "Incorrect usage, see /help set_owner"
21 end
23 if pos1 and pos2 then
24 pos1, pos2 = areas:sortPos(pos1, pos2)
25 else
26 return "Você precisa selecionar a area primeiro"
27 end
29 if not areas:player_exists(ownername) then
30 return "O jogador \""..ownername.."\" não existe."
31 end
33 minetest.log("action", name.." runs /set_owner. Owner = "..ownername..
34 " AreaName = "..areaname..
35 " StartPos = "..minetest.pos_to_string(pos1)..
36 " EndPos = " ..minetest.pos_to_string(pos2))
38 local id = areas:add(ownername, areaname, pos1, pos2, nil)
39 areas:save()
41 if silencio == nil or silencio == false then
42 minetest.chat_send_player(ownername,
43 "Voce registrou essa area para o jogador #"..
44 id..". Use /lista para ver as areas.")
45 minetest.chat_send_player(name, "Area protected. ID: "..id)
46 end
47 return true
48 end