Доработать очистку инвентаря:
- выделил код в отдельную функцию очистки 'remove_all_inventory'; - переименовал команду чата для очистки инвентаря игрока.
This commit is contained in:
parent
708eed289d
commit
6656ea8315
69
init.lua
69
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,18 +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
|
||||
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
|
||||
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
|
||||
@ -68,31 +73,6 @@ jail.add_jail = function(self_player_name, player_name)
|
||||
end
|
||||
end
|
||||
|
||||
jail.remove_bags = function(self_player_name, player_name)
|
||||
if (minetest.player_exists(player_name)) then
|
||||
local player = minetest.env:get_player_by_name(player_name)
|
||||
if (player) then
|
||||
local player_inv = player:get_inventory() -- получить инвентарь игрока
|
||||
local bags_inv = minetest.get_inventory({
|
||||
type = "detached",
|
||||
name = player_name .. "_bags"
|
||||
}) -- получить сумки игрока
|
||||
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
|
||||
minetest.chat_send_player(self_player_name,
|
||||
S('The player bags have been removed'))
|
||||
end
|
||||
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
|
||||
|
||||
jail.set_release_privs = function(self_name, player, prisoners_list_id)
|
||||
minetest.set_player_privs(player, {
|
||||
interact = true,
|
||||
@ -226,12 +206,19 @@ minetest.register_chatcommand("jailb_off", {
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("remove_bags", {
|
||||
minetest.register_chatcommand("remove_all_inventory", {
|
||||
params = "<player>",
|
||||
description = S("Remove bags from inventory"),
|
||||
description = S("Remove bags and clear inventory"),
|
||||
privs = { jail = true },
|
||||
func = function(name, param)
|
||||
jail.remove_bags(name, param)
|
||||
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,
|
||||
})
|
||||
|
||||
|
@ -33,5 +33,5 @@ To freedom=На свободу
|
||||
Graphical prisoner management shell=Интерфейс управления заключенными
|
||||
The player '=Игрока '
|
||||
' does not exist, check that the nickname is correct=' не сущеcтвует, проверьте правильность ника
|
||||
Remove bags from inventory=Удалить сумки из инвентаря
|
||||
The player bags have been removed=Сумки игрока были удалены
|
||||
Remove bags and clear inventory=Удалить сумки и очистить инвентарь
|
||||
The players inventory has been completely cleared=Инвентарь игрока был полностью очищен
|
@ -14,5 +14,5 @@ Invalid ID=
|
||||
Return a prisoner to jail=
|
||||
The player is already in jail=
|
||||
Total number of prisoners:=
|
||||
Remove bags from inventory=
|
||||
The player bags have been removed=
|
||||
Remove bags and clear inventory=
|
||||
The players inventory has been completely cleared=
|
Loading…
Reference in New Issue
Block a user