2024-05-14 17:52:30 +03:00
|
|
|
local FORMNAME = "essentials:mute_menu"
|
2023-10-03 18:46:18 +03:00
|
|
|
|
|
|
|
-- ban menu
|
|
|
|
function show_mute_menu(name)
|
|
|
|
local formspec = [[
|
|
|
|
formspec_version[6]
|
|
|
|
size[4.5,9.6]
|
|
|
|
field[0.1,4.9;4.3,1.1;player;Player for mute;]
|
|
|
|
button[0.1,6.1;4.3,1.1;mute_btn;Mute the player]
|
2024-05-14 17:52:30 +03:00
|
|
|
image[0.1,0.1;4.3,4.3;essentials_mute_user.png]
|
|
|
|
image_button_exit[3.4,8.5;1,1;essentials_close_btn.png;close_btn;]
|
2023-10-03 18:46:18 +03:00
|
|
|
button[0.1,7.3;4.3,1.1;unmute_btn;Unmute the player]
|
|
|
|
]]
|
|
|
|
|
|
|
|
minetest.show_formspec(name, FORMNAME, formspec)
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|
|
|
if formname ~= FORMNAME then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2024-05-14 17:52:30 +03:00
|
|
|
if fields.close_btn then
|
|
|
|
minetest.sound_play("clicked", name)
|
|
|
|
end
|
|
|
|
|
2023-10-03 18:46:18 +03:00
|
|
|
if fields.unmute_btn then
|
|
|
|
local admin = player:get_player_name()
|
|
|
|
local player_mutted = fields.player
|
|
|
|
local player = minetest.get_player_by_name(fields.player)
|
|
|
|
|
|
|
|
if core.is_singleplayer() then
|
|
|
|
minetest.chat_send_player(admin, core.colorize("red", "You cannot mute in single mode!"))
|
2024-05-14 17:52:30 +03:00
|
|
|
minetest.sound_play("error", name)
|
2023-10-03 18:46:18 +03:00
|
|
|
elseif player_mutted == "" then
|
|
|
|
minetest.chat_send_player(admin, core.colorize("red", "Player name cannot be empty!"))
|
2024-05-14 17:52:30 +03:00
|
|
|
minetest.sound_play("error", name)
|
2023-10-03 18:46:18 +03:00
|
|
|
elseif not player then
|
|
|
|
minetest.chat_send_player(admin, core.colorize("red", "Player not found!"))
|
2024-05-14 17:52:30 +03:00
|
|
|
minetest.sound_play("error", name)
|
2023-10-03 18:46:18 +03:00
|
|
|
elseif privs.shout == true then
|
|
|
|
minetest.chat_send_player(admin, core.colorize("red", "Player already unmuted!"))
|
2024-05-14 17:52:30 +03:00
|
|
|
minetest.sound_play("error", name)
|
2023-10-03 18:46:18 +03:00
|
|
|
else
|
|
|
|
local privs = minetest.get_player_privs(fields.player)
|
|
|
|
minetest.chat_send_all(player_mutted .. " has been unmuted.")
|
|
|
|
privs = {shout = true}
|
|
|
|
minetest.set_player_privs(player, privs)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if fields.mute_btn then
|
|
|
|
local admin = player:get_player_name()
|
|
|
|
local player_mutted = fields.player
|
|
|
|
local player = minetest.get_player_by_name(fields.player)
|
|
|
|
|
|
|
|
if core.is_singleplayer() then
|
|
|
|
minetest.chat_send_player(admin, core.colorize("red", "You cannot mute in single mode!"))
|
2024-05-14 17:52:30 +03:00
|
|
|
minetest.sound_play("error", name)
|
2023-10-03 18:46:18 +03:00
|
|
|
elseif player_mutted == "" then
|
|
|
|
minetest.chat_send_player(admin, core.colorize("red", "Player name cannot be empty!"))
|
2024-05-14 17:52:30 +03:00
|
|
|
minetest.sound_play("error", name)
|
2023-10-03 18:46:18 +03:00
|
|
|
elseif not player then
|
|
|
|
minetest.chat_send_player(admin, core.colorize("red", "Player not found!"))
|
2024-05-14 17:52:30 +03:00
|
|
|
minetest.sound_play("error", name)
|
2023-10-03 18:46:18 +03:00
|
|
|
elseif privs.shout == true then
|
|
|
|
minetest.chat_send_player(admin, core.colorize("red", "Player already muted!"))
|
2024-05-14 17:52:30 +03:00
|
|
|
minetest.sound_play("error", name)
|
2023-10-03 18:46:18 +03:00
|
|
|
else
|
|
|
|
local privs = minetest.get_player_privs(fields.player)
|
|
|
|
minetest.chat_send_all(player_mutted .. " has been muted.")
|
|
|
|
privs = {shout = true}
|
|
|
|
minetest.set_player_privs(player, privs)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end)
|
|
|
|
-- end
|