1
0
forked from MTSR/jail

Добавил опцию приватного сообщения для админов по привилегии ban и подправил позиции тюрьмы

This commit is contained in:
Vitaliy Olkhin 2024-02-15 14:59:53 +05:00 committed by Koldun
parent 911cd00cec
commit 58daf49b82
Signed by: Koldun
GPG Key ID: 53DE683337F5D25F
3 changed files with 42 additions and 14 deletions

View File

@ -6,6 +6,7 @@ jail.forced_labor = {y = -14848} --Начало глубины принудит
local jailpos = { x = 690, y = 5, z = -7 } local jailpos = { x = 690, y = 5, z = -7 }
local releasepos = { x = 684, y = 5, z = -7 } local releasepos = { x = 684, y = 5, z = -7 }
local timer = 0 local timer = 0
local lower_prison_limit = -5
dofile(minetest.get_modpath("jail") .. "/nodes.lua") dofile(minetest.get_modpath("jail") .. "/nodes.lua")
@ -140,9 +141,26 @@ minetest.register_on_shutdown(function()
mod_storage:set_string("prisoners", prisoners) mod_storage:set_string("prisoners", prisoners)
end) end)
jail.private_messages_with_privilege = function(list_privs, msg)
local player_name = 'player_name'
for _, player in ipairs(minetest.get_connected_players()) do
player_name = player:get_player_name()
boolean = minetest.check_player_privs(player:get_player_name(), list_privs)
if boolean then
minetest.chat_send_player(player_name, msg)
end
end
end
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
local forced_labor = 0 local forced_labor = jail.forced_labor.y + 1000
local max_pos_x = jailpos.x + jail.escape_boundary
local min_pos_x = jailpos.x - jail.escape_boundary
local max_pos_y = jailpos.x + jail.escape_boundary
local max_pos_z = jailpos.z + jail.escape_boundary
local min_pos_z = jailpos.z - jail.escape_boundary
-- every 5 seconds -- every 5 seconds
if timer > os.time() then if timer > os.time() then
@ -156,23 +174,20 @@ minetest.register_globalstep(function(dtime)
if object then if object then
local pos = object:get_pos() local pos = object:get_pos()
local max_pos_x = jail.display_node.x + jail.escape_boundary 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)
local min_pos_x = jail.display_node.x - jail.escape_boundary and pos.y > lower_prison_limit then
local max_pos_y = jail.display_node.y + jail.escape_boundary
local max_pos_z = jail.display_node.z + jail.escape_boundary
local min_pos_z = jail.display_node.z - jail.escape_boundary
forced_labor = jail.forced_labor.y + 1000
if (max_pos_x < pos.x or pos.x < min_pos_x or max_pos_z < pos.z or pos.z < min_pos_z) and pos.y > -5 then
object:set_pos(jailpos) object:set_pos(jailpos)
minetest.chat_send_all(minetest.colorize("red", S("Escape attempt: ") .. prisoners_list[i])) jail.private_messages_with_privilege({ban = true},
minetest.colorize("red", S("Escape attempt: ") .. prisoners_list[i]))
jail.set_permissions_for_the_jail(prisoners_list[i]) jail.set_permissions_for_the_jail(prisoners_list[i])
end end
--Проверка если игрок копает в низ по кординатам тюрьмы --Проверка если игрок копает в низ по кординатам тюрьмы
if pos.y < -5 and pos.y > forced_labor then if pos.y < lower_prison_limit and pos.y > forced_labor then
object:set_pos(jailpos) object:set_pos(jailpos)
minetest.chat_send_all(minetest.colorize("red", prisoners_list[i] .. S(": He dug under the prison"))) jail.private_messages_with_privilege({ban = true},
minetest.colorize("red", prisoners_list[i] .. S(": He dug under the prison")))
minetest.chat_send_all()
jail.set_permissions_for_the_jail(prisoners_list[i]) jail.set_permissions_for_the_jail(prisoners_list[i])
end end

View File

@ -3,4 +3,4 @@ description = Adds jail for game
depends = default depends = default
min_minetest_version = 5.7 min_minetest_version = 5.7
title = Jail title = Jail
release = 1 release = 2

View File

@ -33,3 +33,16 @@ minetest.register_node("jail:borders", {
groups = {dig_immediate = 3, not_in_creative_inventory = 1}, groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "" drop = ""
}) })
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end