Compare commits

..

5 Commits
main ... lsr

Author SHA1 Message Date
e26538f785 fix jailb and spawnpoint (#9)
fix jailb and spawnpoint

Reviewed-on: #9
Reviewed-by: Александр Авдеев <reload@luanti.ru>
Co-authored-by: Shepel Pavel <shepelpavel@mail.ru>
Co-committed-by: Shepel Pavel <shepelpavel@mail.ru>
2024-12-17 12:32:08 +03:00
d0c49465c3 Очистка сумок заключённого (#8)
_Originally posted by @shepel in #6 (comment)

Co-authored-by: Shepel Pavel <shepelpavel@mail.ru>
Co-authored-by: Aleksandr Avdeev <reload-gtn@mail.ru>
Reviewed-on: #8
Co-authored-by: Koldun <koldun@noreply.git.minetestserver.ru>
Co-committed-by: Koldun <koldun@noreply.git.minetestserver.ru>
2024-12-13 14:16:28 +03:00
f4914fc516 Изменить позицию спавна при посадке в тюрьму 2024-12-12 17:28:56 +03:00
Aleksandr Avdeev
8814c417af
Добавить команду на освобождение игрока из тюрьмы по нику 2024-10-21 18:40:20 +05:00
Aleksandr Avdeev
89a96d69e3
Убрать привилегию shout при помещении в тюрьму 2024-10-21 18:39:59 +05:00
4 changed files with 86 additions and 15 deletions

View File

@ -2,10 +2,15 @@ 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,
jail.spawnpos = {
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.jailpos = {
x = tonumber(minetest.settings:get("jail_prison_center_point_x")) or 690,
y = tonumber(minetest.settings:get("jail_prison_center_point_y")) or 5,
z = tonumber(minetest.settings:get("jail_prison_center_point_z")) or -7
}
jail.escape_boundary = tonumber(minetest.settings:get("jail_wrap_radius")) or 50
local releasepos = {
@ -31,10 +36,25 @@ end
jail.set_permissions_for_the_jail = function (player)
minetest.set_player_privs(player, {
interact = true,
shout = true,
})
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
@ -49,7 +69,8 @@ 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
player:setpos(jail.jailpos)
jail.remove_all_inventory(player_name)
player:setpos(jail.spawnpos)
minetest.chat_send_player(player_name, minetest.colorize("red", S("You have been sent to jail")))
end
else
@ -71,7 +92,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 +110,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"),
@ -111,7 +148,7 @@ minetest.register_chatcommand("jail_return", {
end
local player = minetest.env:get_player_by_name(playername)
if (player) then
player:setpos(jailpos)
player:setpos(jail.spawnpos)
minetest.chat_send_player(playername, minetest.colorize("red", S("You have been return to jail")))
minetest.chat_send_all(minetest.colorize("red",
"" .. param .. " " .. S("has been return to jail by") .. " " .. name))
@ -120,11 +157,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 +211,22 @@ minetest.register_chatcommand("jailb_off", {
end
})
minetest.register_chatcommand("remove_all_inventory", {
params = "<player>",
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)
@ -206,7 +268,7 @@ minetest.register_globalstep(function(dtime)
if (max_pos_x < pos.x or pos.x < min_pos_x or max_pos_z < pos.z or pos.z < min_pos_z or pos.y > max_pos_y)
and pos.y > lower_prison_limit then
object:set_pos(jail.jailpos)
object:set_pos(jail.spawnpos)
msg = minetest.colorize("red", S("Escape attempt: ") .. " " .. prisoners_list[i])
jail.private_messages_with_privilege({ban = true}, msg)
minetest.chat_send_player(prisoners_list[i], msg)
@ -215,7 +277,7 @@ minetest.register_globalstep(function(dtime)
--Проверка если игрок копает в низ по кординатам тюрьмы
if pos.y < lower_prison_limit and pos.y > forced_labor then
object:set_pos(jail.jailpos)
object:set_pos(jail.spawnpos)
msg = minetest.colorize("red", prisoners_list[i] .. S(": He dug under the prison"))
jail.private_messages_with_privilege({ban = true}, msg)
minetest.chat_send_player(prisoners_list[i], msg)
@ -224,7 +286,7 @@ minetest.register_globalstep(function(dtime)
--Условие если игрок находится взаданом параметре jail.forced_labor.y под землей
if pos.y > jail.forced_labor.y and pos.y < -10 then
object:set_pos(jail.jailpos)
object:set_pos(jail.spawnpos)
minetest.chat_send_player(prisoners_list[i], minetest.colorize("red", S("You are prohibited from leaving this area")))
jail.set_permissions_for_the_jail(prisoners_list[i])
end

View File

@ -4,6 +4,7 @@ Allows one to send/release prisoners=Позволяет заключать и о
Sends a player to Jail=Отправить игрока в тюрьму
Sends the player to prison for a limited time=
Releases a player from Jail by ID=Освободить игрока из тюрьмы по ID
Releases a player from Jail by nickname=Освободить игрока из тюрьмы по никнейму
You have been sent to jail=Вы помещены в тюрьму
You have been return to jail=Вы возвращены в тюрьму
You have been released from jail=Вы были освобождены из тюрьмы
@ -13,6 +14,7 @@ has been released from jail by=был освобожден из тюрьмы и
List of prisoners=Список заключенных
Prisoners:=Заключенные:
Invalid ID=Неверный ID
Invalid playername=Неверное имя игрока
Return a prisoner to jail=Возвратить заключенного в тюрьму
The player is already in jail=Игрок уже в тюреме
Total number of prisoners:=Общее число заключенных:
@ -31,3 +33,5 @@ To freedom=На свободу
Graphical prisoner management shell=Интерфейс управления заключенными
The player '=Игрока '
' does not exist, check that the nickname is correct=' не сущеcтвует, проверьте правильность ника
Remove bags and clear inventory=Удалить сумки и очистить инвентарь
The players inventory has been completely cleared=Инвентарь игрока был полностью очищен

View File

@ -14,3 +14,5 @@ Invalid ID=
Return a prisoner to jail=
The player is already in jail=
Total number of prisoners:=
Remove bags and clear inventory=
The players inventory has been completely cleared=

View File

@ -1,7 +1,10 @@
[Prison spawn point]
jail_prison_spawn_point_x (Position X) int 690
jail_prison_spawn_point_x (Position X) int 666
jail_prison_spawn_point_y (Position Y) int 5
jail_prison_spawn_point_z (Position z) int -7
jail_prison_spawn_point_z (Position z) int 2
jail_prison_center_point_x (Position X) int 690
jail_prison_center_point_y (Position Y) int 5
jail_prison_center_point_z (Position z) int -7
[End of the border]
jail_wrap_radius (Wrap radius) int 50