fix jailb and spawnpoint

This commit is contained in:
Shepel Pavel 2024-12-17 12:01:42 +03:00
parent d0c49465c3
commit 66c5c1d564
3 changed files with 19 additions and 6 deletions

5
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"Lua.diagnostics.globals": [
"minetest"
]
}

View File

@ -2,11 +2,16 @@ local S = minetest.get_translator("jail")
jail = {} jail = {}
jail.forced_labor = {y = tonumber(minetest.settings:get("jail_upper_limit_underground_y")) or -14848} jail.forced_labor = {y = tonumber(minetest.settings:get("jail_upper_limit_underground_y")) or -14848}
jail.jailpos = { jail.spawnpos = {
x = tonumber(minetest.settings:get("jail_prison_spawn_point_x")) or 666, x = tonumber(minetest.settings:get("jail_prison_spawn_point_x")) or 666,
y = tonumber(minetest.settings:get("jail_prison_spawn_point_y")) or 5, y = tonumber(minetest.settings:get("jail_prison_spawn_point_y")) or 5,
z = tonumber(minetest.settings:get("jail_prison_spawn_point_z")) or 2 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 jail.escape_boundary = tonumber(minetest.settings:get("jail_wrap_radius")) or 50
local releasepos = { local releasepos = {
x = tonumber(minetest.settings:get("jail_releasepos_x")) or 684, x = tonumber(minetest.settings:get("jail_releasepos_x")) or 684,
@ -65,7 +70,7 @@ jail.add_jail = function(self_player_name, player_name)
"" .. 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
jail.remove_all_inventory(player_name) jail.remove_all_inventory(player_name)
player:setpos(jail.jailpos) player:setpos(jail.spawnpos)
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
else else
@ -143,7 +148,7 @@ minetest.register_chatcommand("jail_return", {
end end
local player = minetest.env:get_player_by_name(playername) local player = minetest.env:get_player_by_name(playername)
if (player) then 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_player(playername, minetest.colorize("red", S("You have been return to jail")))
minetest.chat_send_all(minetest.colorize("red", minetest.chat_send_all(minetest.colorize("red",
"" .. param .. " " .. S("has been return to jail by") .. " " .. name)) "" .. param .. " " .. S("has been return to jail by") .. " " .. name))
@ -263,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) 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 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]) msg = minetest.colorize("red", S("Escape attempt: ") .. " " .. prisoners_list[i])
jail.private_messages_with_privilege({ban = true}, msg) jail.private_messages_with_privilege({ban = true}, msg)
minetest.chat_send_player(prisoners_list[i], msg) minetest.chat_send_player(prisoners_list[i], msg)
@ -272,7 +277,7 @@ minetest.register_globalstep(function(dtime)
--Проверка если игрок копает в низ по кординатам тюрьмы --Проверка если игрок копает в низ по кординатам тюрьмы
if pos.y < lower_prison_limit and pos.y > forced_labor then 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")) msg = minetest.colorize("red", prisoners_list[i] .. S(": He dug under the prison"))
jail.private_messages_with_privilege({ban = true}, msg) jail.private_messages_with_privilege({ban = true}, msg)
minetest.chat_send_player(prisoners_list[i], msg) minetest.chat_send_player(prisoners_list[i], msg)
@ -281,7 +286,7 @@ minetest.register_globalstep(function(dtime)
--Условие если игрок находится взаданом параметре jail.forced_labor.y под землей --Условие если игрок находится взаданом параметре jail.forced_labor.y под землей
if pos.y > jail.forced_labor.y and pos.y < -10 then 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"))) 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]) jail.set_permissions_for_the_jail(prisoners_list[i])
end end

View File

@ -2,6 +2,9 @@
jail_prison_spawn_point_x (Position X) int 666 jail_prison_spawn_point_x (Position X) int 666
jail_prison_spawn_point_y (Position Y) int 5 jail_prison_spawn_point_y (Position Y) int 5
jail_prison_spawn_point_z (Position z) int 2 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] [End of the border]
jail_wrap_radius (Wrap radius) int 50 jail_wrap_radius (Wrap radius) int 50