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, }) --[[ local cmd ="/away" if message:sub(0, #cmd) == cmd then if message == '/away' then 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())) return true end end local cmd ="/re" if message:sub(0, #cmd) == cmd then if message == '/re' then 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())) return true end end local cmd ="/hacmd" if message:sub(0, #cmd) == cmd then if message == '/hacmd' then --local player = minetest.env:get_player_by_name(name) minetest.chat_send_all("additional Commands") minetest.chat_send_all("===================") minetest.chat_send_all("use /away for afk note from server.") minetest.chat_send_all("use /re for no-longer-afk note from server.") minetest.chat_send_all("use /spawn to teleporting you to the spawnpoint.") minetest.chat_send_all("use /helpcmdplus to show this helpmessage.") return true end end local cmd ="/helpcmdplus" if message:sub(0, #cmd) == cmd then if message == '/helpcmdplus' then local player = minetest.env:get_player_by_name(name) minetest.chat_send_all("additional Comands") minetest.chat_send_all("==================") minetest.chat_send_player(player:get_player_name(),"use /away for afk note from server.") minetest.chat_send_player(player:get_player_name(),"use /re for no-longer-afk note from server.") minetest.chat_send_player(player:get_player_name(),"use /spawn to teleporting you to the Spawnpoint.") return true end end end) --Deds to Kahrl minetest.register_on_newplayer(function(player) player:setpos(spawn) return true end) --Deds to Kahrl minetest.register_on_respawnplayer(function(player, pos) player:setpos(spawn) return true 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=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 = "", 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, })