summaryrefslogtreecommitdiff
path: root/init.lua
blob: f62c2d40700dc664edb306e22d6e418d31c32e9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
--Spawn mod for Minetest
--Originally written by VanessaE (I think), rewritten by cheapie
--WTFPL

--Banish command
--Copyright 2016 Gabriel PĂ©rez-Cerezo
--WTFPL

local spawn_spawnpos = minetest.setting_get_pos("static_spawnpoint")
local banish_pos = {x=5000, y=2, z=5000}
minetest.register_chatcommand("spawn", {
	params = "",
	privs = {teleport=true},
	description = "Teleport to the spawn point",
	func = function(name, param)
		local player = minetest.get_player_by_name(name)
		if not player then
			return false, "Player not found"
		end
		if spawn_spawnpos then
			player:setpos(spawn_spawnpos)
			return true, "Teleporting to spawn..."
		else
			return false, "The spawn point is not set!"
		end
	end,
})

function revert (player)
      local privs = minetest.get_player_privs(player);
      privs.teleport = true;
      minetest.set_player_privs(player, privs)
      minetest.chat_send_player(player, "You recovered your teleport privilege. Use /spawn to return to the spawn point")
      minetest.register_on_respawnplayer(function(player)
	    player:setpos(spawn_spawnpos)
      end)
end

minetest.register_chatcommand("banish", {
   params = "<person>",
   description = "Banishes griefers to a far away location",
   privs = {server=true},
   func = function(name, param)
      local player = minetest.get_player_by_name(param)
      if player == nil then
         return false, "Player not found"
      end
      player:setpos(banish_pos)
      local privs = minetest.get_player_privs(param)
      privs.teleport = false;
      minetest.set_player_privs(param, {interact=true, shout=true})
      minetest.register_on_respawnplayer(function(player)
	    player:setpos(banish_pos)
      end)
      minetest.chat_send_player(name, "Banished player " .. param)
      minetest.chat_send_player(param, "You were banished! You can try to walk back. You will be able to return to spawn in 5 minutes using the /spawn command.")
      minetest.after(300, revert, param)
   end,
})