|
|
|
@ -3,9 +3,9 @@ local S = minetest.get_translator("jail")
|
|
|
|
|
jail = {}
|
|
|
|
|
jail.forced_labor = {y = tonumber(minetest.settings:get("jail_upper_limit_underground_y")) or -14848}
|
|
|
|
|
jail.jailpos = {
|
|
|
|
|
x = tonumber(minetest.settings:get("jail_prison_spawn_point_x")) or 690,
|
|
|
|
|
x = tonumber(minetest.settings:get("jail_prison_spawn_point_x")) or 666,
|
|
|
|
|
y = tonumber(minetest.settings:get("jail_prison_spawn_point_y")) or 5,
|
|
|
|
|
z = tonumber(minetest.settings:get("jail_prison_spawn_point_z")) or -7
|
|
|
|
|
z = tonumber(minetest.settings:get("jail_prison_spawn_point_z")) or 2
|
|
|
|
|
}
|
|
|
|
|
jail.escape_boundary = tonumber(minetest.settings:get("jail_wrap_radius")) or 50
|
|
|
|
|
local releasepos = {
|
|
|
|
@ -31,7 +31,6 @@ end
|
|
|
|
|
jail.set_permissions_for_the_jail = function (player)
|
|
|
|
|
minetest.set_player_privs(player, {
|
|
|
|
|
interact = true,
|
|
|
|
|
shout = true,
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -49,6 +48,18 @@ 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
|
|
|
|
|
player:setpos(jail.jailpos)
|
|
|
|
|
minetest.chat_send_player(player_name, minetest.colorize("red", S("You have been sent to jail")))
|
|
|
|
|
end
|
|
|
|
@ -57,6 +68,31 @@ 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,
|
|
|
|
@ -71,7 +107,7 @@ jail.set_release_privs = function(self_name, player, prisoners_list_id)
|
|
|
|
|
table.remove(prisoners_list, prisoners_list_id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
jail.release = function(self_name, id_player)
|
|
|
|
|
jail.release_id = function(self_name, id_player)
|
|
|
|
|
local id = tonumber(id_player)
|
|
|
|
|
local playername = prisoners_list[id]
|
|
|
|
|
if (id == nil or id > #prisoners_list or id <= 0) then
|
|
|
|
@ -89,6 +125,22 @@ jail.release = function(self_name, id_player)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
jail.release = function(self_name, player_name)
|
|
|
|
|
for i = 1, #prisoners_list do
|
|
|
|
|
if player_name == prisoners_list[i] then
|
|
|
|
|
local player = minetest.env:get_player_by_name(player_name)
|
|
|
|
|
if (player) then
|
|
|
|
|
player:setpos(releasepos)
|
|
|
|
|
minetest.chat_send_player(player_name, minetest.colorize("green", S("You have been released from jail")))
|
|
|
|
|
end
|
|
|
|
|
jail.set_release_privs(self_name, player_name, i)
|
|
|
|
|
return
|
|
|
|
|
else
|
|
|
|
|
minetest.chat_send_player(self_name, S("Invalid playername"))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
minetest.register_chatcommand("jail", {
|
|
|
|
|
params = "<player>",
|
|
|
|
|
description = S("Sends a player to Jail"),
|
|
|
|
@ -120,11 +172,20 @@ minetest.register_chatcommand("jail_return", {
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
minetest.register_chatcommand("release", {
|
|
|
|
|
params = "<nickname prisoners>",
|
|
|
|
|
description = S("Releases a player from Jail by nickname"),
|
|
|
|
|
privs = { jail = true },
|
|
|
|
|
func = function(name, param)
|
|
|
|
|
jail.release(name, param)
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
minetest.register_chatcommand("release_id", {
|
|
|
|
|
params = "<ID prisoners>",
|
|
|
|
|
description = S("Releases a player from Jail by ID"),
|
|
|
|
|
privs = { jail = true },
|
|
|
|
|
func = function(name, param)
|
|
|
|
|
jail.release(name, param)
|
|
|
|
|
jail.release_id(name, param)
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
@ -165,6 +226,15 @@ minetest.register_chatcommand("jailb_off", {
|
|
|
|
|
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()
|
|
|
|
|
local prisoners = table.concat(prisoners_list, "\n")
|
|
|
|
|
mod_storage:set_string("prisoners", prisoners)
|
|
|
|
|