Skip to content
Snippets Groups Projects
Commit 69dc1478 authored by Milan's avatar Milan
Browse files

add arrest command

parent 05e23068
No related branches found
No related tags found
No related merge requests found
......@@ -68,6 +68,9 @@ end)
-- Commands, originally by Grailtest @0-afflatus
command = {}
-- Notices
function command.send_notice(target, text)
local player = minetest.get_player_by_name(target)
if not player then
......@@ -114,3 +117,67 @@ minetest.register_chatcommand("notice", {
end,
})
-- Arrest
local court = {x=13, y=35, z=-11}
local court_admin = {x=35, y=24, z=-11}
local prison = {x=0, y=-2015, z=0}
local prison_admin = {x=19, y=-2015, z=19}
function command:is_in(context, search_term)
for k, value in ipairs(context) do
if value == search_term then
return k
end
end
return false
end
function command:player_exists(name)
local privs = minetest.get_player_privs( name );
if( not( privs )) then
return false;
else
return true;
end
end
function command:arrest(playername)
local perp = minetest.get_player_by_name(playername)
if perp then
--minetest.set_player_privs(perp, {shout = true})
perp:setpos(court)
else
return false;
end
return true;
end
function command:make_arrest(adminname)
local judge = minetest.get_player_by_name(adminname)
judge:setpos(court_admin)
return true;
end
minetest.register_chatcommand("arrest", {
params = "<player>",
privs = { basic_privs=true, },
description = "Arrest a player. (removes all privs but shout)",
func = function(name, param)
local perps = string.split(param, " ")
local perp = perps[1] or "Suspect"
minetest.chat_send_player(name, "You arrest "..perp)
if not command:player_exists(perp) then
return false, "Player " .. perp .. " does not exist."
end
--local privs = minetest.get_player_privs(perp)
-- arrest function
command:make_arrest(name)
if not command:arrest(perp) then
return false, "You fail to arrest "..perp
end
minetest.log("action", name .. " arrested " .. perp)
minetest.chat_send_player(name, "Player "..perp.." arrested. Revoked all but shout.")
end,
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment