Minetest mod: Toggle privs in areas
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
775 B

minetest.register_privilege("pvp", {
description = "Allow PvP",
give_to_singleplayer= false,
})
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
if not hitter:is_player() then
return false -- if this is a MOB then give Damage
end
local player_name = player:get_player_name()
local hitter_player_name = hitter:get_player_name()
if minetest.check_player_privs(hitter_player_name, {kick=true}) then
return false
end
if minetest.check_player_privs(player_name, {arena=true}) then
return false
end
if not minetest.check_player_privs(player_name, {pvp=true}) then
return true
end
if not minetest.check_player_privs(hitter_player_name, {pvp=true}) then
return true
end
return false
end)