add arrest command
This commit is contained in:
parent
05e230684f
commit
69dc14788f
67
commands.lua
67
commands.lua
@ -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,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user