Доработать функцию отправки игрока в тюрьму (#1)

- добавлена проверка на корректность введенного имени игрока;
- добавлена отправка в тюрьму игрока, который оффлайн.

Co-authored-by: Aleksandr Avdeev <reload-gtn@mail.ru>
Reviewed-on: https://git.minetestserver.ru/MTSR/jail/pulls/1
Reviewed-by: Koldun <koldun@noreply.git.minetestserver.ru>
Co-authored-by: Александр Авдеев <reload@minetestserver.ru>
Co-committed-by: Александр Авдеев <reload@minetestserver.ru>
This commit is contained in:
Александр Авдеев 2024-10-16 17:00:42 +03:00 committed by Koldun
parent fae274cdab
commit 5f8cf99fc4
2 changed files with 17 additions and 13 deletions

View File

@ -36,22 +36,24 @@ jail.set_permissions_for_the_jail = function (player)
end
jail.add_jail = function(self_player_name, player_name)
if (minetest.player_exists(player_name)) then
for i = 1, #prisoners_list do
if prisoners_list[i] == player_name then
minetest.chat_send_player(self_player_name, S("The player is already in jail"))
return
end
end
local player = minetest.env:get_player_by_name(player_name)
if (player) then
table.insert(prisoners_list, player_name)
player:setpos(jail.jailpos)
minetest.chat_send_player(player_name, minetest.colorize("red", S("You have been sent to jail")))
jail.set_permissions_for_the_jail(player_name)
local player = minetest.env:get_player_by_name(player_name)
minetest.chat_send_all(minetest.colorize("red",
"" .. player_name .. " " .. S("has been sent to jail by") .. " " .. self_player_name))
jail.set_permissions_for_the_jail(player_name)
if (player) then
player:setpos(jail.jailpos)
minetest.chat_send_player(player_name, minetest.colorize("red", S("You have been sent to jail")))
end
else
minetest.chat_send_player(player_name, minetest.colorize("red", S("Не в сети")))
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

View File

@ -28,4 +28,6 @@ Players online=Игроки онлайн
Prisoners=Заключенные
To jail=В тюрьму
To freedom=На свободу
Graphical prisoner management shell=Графическая оболочка управления заключенными
Graphical prisoner management shell=Интерфейс управления заключенными
The player '=Игрока '
' does not exist, check that the nickname is correct=' не сущеcтвует, проверьте правильность ника