2023-10-03 18:46:18 +03:00
|
|
|
local FORMNAME = "essentials:kick_menu"
|
|
|
|
|
|
|
|
-- ban menu
|
|
|
|
function show_kick_menu(name)
|
|
|
|
local formspec = [[
|
|
|
|
formspec_version[6]
|
|
|
|
size[12.5,4.5]
|
|
|
|
field[1.2,0.6;6.8,1;player;Player name;]
|
|
|
|
field[1.2,2.1;6.8,1;reason;Reason of kick;]
|
|
|
|
button[1.2,3.3;6.8,1.1;kick_btn;Kick the player]
|
2024-05-14 17:52:30 +03:00
|
|
|
image[8.2,0.2;4.2,4.2;essentials_kick_user.png]
|
|
|
|
image_button_exit[0.1,0.1;1,1;essentials_close_btn.png;close_btn;]
|
2023-10-03 18:46:18 +03:00
|
|
|
]]
|
|
|
|
|
|
|
|
minetest.show_formspec(name, FORMNAME, formspec)
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|
|
|
local name = player:get_player_name()
|
|
|
|
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.kick_btn then
|
|
|
|
local player_kick = minetest.get_player_by_name(fields.player)
|
|
|
|
local player_kicked = fields.player
|
|
|
|
local reason_kick = fields.reason
|
|
|
|
|
|
|
|
if core.is_singleplayer() then
|
|
|
|
minetest.chat_send_player(name, core.colorize("red", "You cannot kick 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 not player_kick then
|
|
|
|
minetest.chat_send_player(name, 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 reason_kick == "" then
|
|
|
|
core.kick_player(fields.player, fields.reason)
|
|
|
|
core.chat_send_all("Kicked ".. player_kicked ..".")
|
2024-05-14 17:52:30 +03:00
|
|
|
minetest.sound_play("player_kicked")
|
2023-10-03 18:46:18 +03:00
|
|
|
else
|
|
|
|
core.kick_player(fields.player, fields.reason)
|
|
|
|
core.chat_send_all("Kicked ".. player_kicked .." for ".. reason_kick ..".")
|
2024-05-14 17:52:30 +03:00
|
|
|
minetest.sound_play("player_kicked")
|
2023-10-03 18:46:18 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end)
|
|
|
|
-- end
|