-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsg.lua
62 lines (46 loc) · 1.54 KB
/
msg.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
--[[
Mod MultiChat para Minetest
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
Recebeste uma cópia da GNU Lesser General
Public License junto com esse software,
se não, veja em <http://www.gnu.org/licenses/>.
Ajuste no comando /msg
]]
local som_avisar = multichat.som_avisar
local old_func = minetest.chatcommands.msg.func
function minetest.chatcommands.msg.func(name, param)
local sendto, message = param:match("^(%S+)%s(.+)$")
if not sendto then
return false, "Invalid usage, see /help msg."
end
local ouvinte = sendto
-- Verifica o jogador pode ouvir
if minetest.player_exists(ouvinte) and minetest.get_player_by_name(ouvinte) then
local player = minetest.get_player_by_name(ouvinte)
local status = player:get_attribute("multichat_status")
-- Verifica se o jogador está no bate-papo público
if status == nil or status == "pub" then
-- Verificar se está desativado
elseif status == "off" then
som_avisar(name)
return true, "Message sent." -- Tenta enganar jogador que enviou a mensagem
-- Verifica se jogador está ouvindo apenas seu grupo
elseif status == "grupo" and multichat.grupos[ouvinte] then
-- Verifica se falante está no grupo
if multichat.grupos[name][falante] == nil then
som_avisar(name)
return true, "Message sent." -- Tenta enganar jogador que enviou a mensagem
end
end
end
local r, msg = old_func(name, param)
if r == true then
if ouvinte == name then
som_avisar(name)
else
som_avisar(ouvinte, message)
som_avisar(name)
end
end
return r, msg
end