Add remove_bags chat command
This commit is contained in:
parent
f4914fc516
commit
c48bc9d412
46
init.lua
46
init.lua
@ -48,6 +48,18 @@ jail.add_jail = function(self_player_name, player_name)
|
|||||||
minetest.chat_send_all(minetest.colorize("red",
|
minetest.chat_send_all(minetest.colorize("red",
|
||||||
"" .. player_name .. " " .. S("has been sent to jail by") .. " " .. self_player_name))
|
"" .. player_name .. " " .. S("has been sent to jail by") .. " " .. self_player_name))
|
||||||
if (player) then
|
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
|
||||||
player:setpos(jail.jailpos)
|
player:setpos(jail.jailpos)
|
||||||
minetest.chat_send_player(player_name, minetest.colorize("red", S("You have been sent to jail")))
|
minetest.chat_send_player(player_name, minetest.colorize("red", S("You have been sent to jail")))
|
||||||
end
|
end
|
||||||
@ -56,6 +68,31 @@ jail.add_jail = function(self_player_name, player_name)
|
|||||||
end
|
end
|
||||||
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)
|
jail.set_release_privs = function(self_name, player, prisoners_list_id)
|
||||||
minetest.set_player_privs(player, {
|
minetest.set_player_privs(player, {
|
||||||
interact = true,
|
interact = true,
|
||||||
@ -189,6 +226,15 @@ minetest.register_chatcommand("jailb_off", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_chatcommand("remove_bags", {
|
||||||
|
params = "<player>",
|
||||||
|
description = S("Remove bags from inventory"),
|
||||||
|
privs = { jail = true },
|
||||||
|
func = function(name, param)
|
||||||
|
jail.remove_bags(name, param)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_on_shutdown(function()
|
minetest.register_on_shutdown(function()
|
||||||
local prisoners = table.concat(prisoners_list, "\n")
|
local prisoners = table.concat(prisoners_list, "\n")
|
||||||
mod_storage:set_string("prisoners", prisoners)
|
mod_storage:set_string("prisoners", prisoners)
|
||||||
|
@ -32,4 +32,6 @@ To jail=В тюрьму
|
|||||||
To freedom=На свободу
|
To freedom=На свободу
|
||||||
Graphical prisoner management shell=Интерфейс управления заключенными
|
Graphical prisoner management shell=Интерфейс управления заключенными
|
||||||
The player '=Игрока '
|
The player '=Игрока '
|
||||||
' does not exist, check that the nickname is correct=' не сущеcтвует, проверьте правильность ника
|
' does not exist, check that the nickname is correct=' не сущеcтвует, проверьте правильность ника
|
||||||
|
Remove bags from inventory=Удалить сумки из инвентаря
|
||||||
|
The player bags have been removed=Сумки игрока были удалены
|
@ -13,4 +13,6 @@ Prisoners:=
|
|||||||
Invalid ID=
|
Invalid ID=
|
||||||
Return a prisoner to jail=
|
Return a prisoner to jail=
|
||||||
The player is already in jail=
|
The player is already in jail=
|
||||||
Total number of prisoners:=
|
Total number of prisoners:=
|
||||||
|
Remove bags from inventory=
|
||||||
|
The player bags have been removed=
|
Loading…
Reference in New Issue
Block a user