From d0c49465c3e517cad155a26ff30fae5cbccdd90e Mon Sep 17 00:00:00 2001 From: Koldun Date: Fri, 13 Dec 2024 14:16:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=87=D0=B8=D1=81=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=81=D1=83=D0=BC=D0=BE=D0=BA=20=D0=B7=D0=B0=D0=BA=D0=BB=D1=8E?= =?UTF-8?q?=D1=87=D1=91=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE=20(#8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _Originally posted by @shepel in https://git.luanti.ru/MTSR/jail/pulls/6#issuecomment-267_ Co-authored-by: Shepel Pavel Co-authored-by: Aleksandr Avdeev Reviewed-on: https://git.luanti.ru/MTSR/jail/pulls/8 Co-authored-by: Koldun Co-committed-by: Koldun --- init.lua | 33 +++++++++++++++++++++++++++++++++ locale/jail.ru.tr | 4 +++- locale/template.txt | 4 +++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 984c0c9..ad89442 100644 --- a/init.lua +++ b/init.lua @@ -34,6 +34,22 @@ jail.set_permissions_for_the_jail = function (player) }) end +jail.remove_all_inventory = function (player_name) + local player = minetest.env:get_player_by_name(player_name) + local player_inv = player:get_inventory() -- получить инвентарь игрока + local bags_inv = minetest.get_inventory({ + type = "detached", + name = player_name .. "_bags" + }) -- получить сумки игрока + player_inv:set_list("main", {}) -- очистить инвентарь + for i = 1, 4 do + player_inv:set_list("bag" .. i .. "contents", {}) -- очистить инвентарь сумок + if (bags_inv) then + bags_inv:set_stack("bag" .. i, 1, "") -- отобрать сумки + end + end +end + jail.add_jail = function(self_player_name, player_name) if (minetest.player_exists(player_name)) then for i = 1, #prisoners_list do @@ -48,6 +64,7 @@ jail.add_jail = function(self_player_name, player_name) minetest.chat_send_all(minetest.colorize("red", "" .. player_name .. " " .. S("has been sent to jail by") .. " " .. self_player_name)) if (player) then + jail.remove_all_inventory(player_name) player:setpos(jail.jailpos) minetest.chat_send_player(player_name, minetest.colorize("red", S("You have been sent to jail"))) end @@ -189,6 +206,22 @@ minetest.register_chatcommand("jailb_off", { end }) +minetest.register_chatcommand("remove_all_inventory", { + params = "", + description = S("Remove bags and clear inventory"), + privs = { jail = true }, + func = function(self_player_name, player_name) + local player = minetest.env:get_player_by_name(player_name) + if (player) then + jail.remove_all_inventory(player_name) + minetest.chat_send_player(self_player_name,S('The players inventory has been completely cleared')) + else + minetest.chat_send_player(self_player_name,minetest.colorize("red", + S("The player '") .. player_name .. S("' does not exist, check that the nickname is correct"))) + end + end, +}) + minetest.register_on_shutdown(function() local prisoners = table.concat(prisoners_list, "\n") mod_storage:set_string("prisoners", prisoners) diff --git a/locale/jail.ru.tr b/locale/jail.ru.tr index 44bd833..7f0a297 100644 --- a/locale/jail.ru.tr +++ b/locale/jail.ru.tr @@ -32,4 +32,6 @@ To jail=В тюрьму To freedom=На свободу Graphical prisoner management shell=Интерфейс управления заключенными The player '=Игрока ' -' does not exist, check that the nickname is correct=' не сущеcтвует, проверьте правильность ника \ No newline at end of file +' does not exist, check that the nickname is correct=' не сущеcтвует, проверьте правильность ника +Remove bags and clear inventory=Удалить сумки и очистить инвентарь +The players inventory has been completely cleared=Инвентарь игрока был полностью очищен \ No newline at end of file diff --git a/locale/template.txt b/locale/template.txt index 74c436a..c6aadf7 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -13,4 +13,6 @@ Prisoners:= Invalid ID= Return a prisoner to jail= The player is already in jail= -Total number of prisoners:= \ No newline at end of file +Total number of prisoners:= +Remove bags and clear inventory= +The players inventory has been completely cleared= \ No newline at end of file