command = {} minetest.register_chatcommand("spawn", { params = "", privs = {interact=true}, description = "Teleports you to the Spawnpoint", func = function(name, param) local player = minetest.env:get_player_by_name(name) local spawnPoint = minetest.setting_get("static_spawnpoint") minetest.get_player_by_name(name):setpos(minetest.string_to_pos(spawnPoint)) minetest.chat_send_player(name, "Teleporting to Spawnpoint...") end, }) minetest.register_chatcommand("away", { params = "", privs = {shout=true}, description = "tell the people that you be away now", func = function(name, param) local player = minetest.env:get_player_by_name(name) minetest.chat_send_all(name.." is now away from keyboard!") irc:say(string.format('*** %s is now away from keyboard.', player:get_player_name())) end, }) minetest.register_chatcommand("re", { params = "", privs = {shout=true}, description = "tell the people that you be back now", func = function(name, param) local player = minetest.env:get_player_by_name(name) minetest.chat_send_all(name.." is no longer away from keyboard!") irc:say(string.format('*** %s is no longer away from keyboard.', player:get_player_name())) end, }) minetest.register_chatcommand("commands", { params = "", privs = {shout=true}, description = "tells you some available commands", func = function(name, param) minetest.chat_send_player(name, "use /away for public afk note from server.") minetest.chat_send_player(name, "use /re for public no-longer-afk note from server.") minetest.chat_send_player(name, "use /sethome to set your homepoint.") minetest.chat_send_player(name, "use /home to go back to your homepoint.") minetest.chat_send_player(name, "use /spawn to teleporting you to the spawnpoint.") minetest.chat_send_player(name, "use /help see the full list of available commands.") minetest.chat_send_player(name, "use /help for command info.") minetest.chat_send_player(name, "use /commands to show this helpmessage.") minetest.chat_send_player(name, ">> hit F10 for the full output of this command.") end, }) -- Commands, originally by Grailtest @0-afflatus -- Notices function command.send_notice(target, text) local player = minetest.get_player_by_name(target) if not player then return false, ("There's no player named '%s'."):format(target) end local fs = { } local lines = { } for i, line in ipairs(text:split("|")) do local lt = { } for j = 1, #line, 40 do table.insert(lt, line:sub(j, j+39)) end lines[i] = table.concat(lt, "\n") end text = table.concat(lines, "\n") text = minetest.formspec_escape(text) table.insert(fs, "size[8,4]") --table.insert(fs, "background[0,0;8,4;ui_form_bg.png]") table.insert(fs, "label[1,.2;"..text.."]") table.insert(fs, "button_exit[3,3.2;2,0.5;ok;OK]") fs = table.concat(fs) minetest.after(0.5, function() minetest.show_formspec(target, "notice:notice", fs) end) return true end minetest.register_privilege("notice", "Send notices to players.") minetest.register_chatcommand("notice", { params = " ", privs = { notice=true, }, description = "Show a notice to a player.", func = function(name, params) local target, text = params:match("(%S+)%s+(.+)") if not (target and text) then return false, "Usage: /notice " end local ok, err = command.send_notice(target, text) if not ok then return false, err end return true, "Notice sent!" end, }) -- Arrest local court = {x=-107, y=1000, z=-153} local court_admin = {x=-105, y=1000, z=-153} 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 = "", 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, })