Added the ability to release the player if not in the game

This commit is contained in:
Vitaliy Olkhin 2024-03-01 14:17:44 +05:00
parent a8663e95a4
commit 52de171f68
2 changed files with 19 additions and 11 deletions

View File

@ -55,6 +55,20 @@ jail.add_jail = function(self_player_name, player_name)
end end
end end
jail.set_release_privs = function(self_name, player, prisoners_list_id)
minetest.set_player_privs(player, {
interact = true,
shout = true,
home = true,
spawn = true,
tp = true
})
minetest.chat_send_all(minetest.colorize("green",
"" .. player .. " " .. S("has been released from jail by") .. " " .. self_name))
table.remove(prisoners_list, prisoners_list_id)
end
jail.release = function(self_name, id_player) jail.release = function(self_name, id_player)
local id = tonumber(id_player) local id = tonumber(id_player)
local playername = prisoners_list[id] local playername = prisoners_list[id]
@ -62,20 +76,14 @@ jail.release = function(self_name, id_player)
minetest.chat_send_player(self_name, S("Invalid ID")) minetest.chat_send_player(self_name, S("Invalid ID"))
return 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(releasepos) player:setpos(releasepos)
minetest.chat_send_player(playername, minetest.colorize("green", S("You have been released from jail"))) minetest.chat_send_player(playername, minetest.colorize("green", S("You have been released from jail")))
minetest.chat_send_all(minetest.colorize("green", jail.set_release_privs(self_name, playername, id)
"" .. playername .. " " .. S("has been released from jail by") .. " " .. self_name)) else
minetest.set_player_privs(playername, { jail.set_release_privs(self_name, playername, id)
interact = true,
shout = true,
home = true,
spawn = true,
tp = true
})
table.remove(prisoners_list, id)
end end
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 = 3 release = 4