dont send players to hell if they execute those chatcommands without nether priv

This commit is contained in:
HybridDog 2015-12-30 11:16:58 +01:00
parent a0995f18f8
commit 1003e8288c
1 changed files with 7 additions and 22 deletions

View File

@ -91,18 +91,11 @@ end
-- Chatcommands (edited) written by sss -- Chatcommands (edited) written by sss
minetest.register_chatcommand("to_hell", { minetest.register_chatcommand("to_hell", {
params = "", params = "[<player_name>]",
description = "Send someone to hell", description = "Send someone to hell",
func = function(name, pname) func = function(name, pname)
if not minetest.check_player_privs(name, {nether=true}) then if not minetest.check_player_privs(name, {nether=true}) then
local self_player,msg = minetest.get_player_by_name(name) return false, "You need the nether priv to execute this chatcommand."
if self_player then
msg = "You can't send anyone to hell, go to hell instead"
player_to_nether(self_player)
else
msg = "Something went wrong."
end
return false, msg
end end
if not player_exists(pname) then if not player_exists(pname) then
pname = name pname = name
@ -113,37 +106,29 @@ minetest.register_chatcommand("to_hell", {
end end
minetest.chat_send_player(pname, "Go to hell !!!") minetest.chat_send_player(pname, "Go to hell !!!")
player_to_nether(player) player_to_nether(player)
return true return true, pname.." is now in the nether."
end end
}) })
minetest.register_chatcommand("from_hell", { minetest.register_chatcommand("from_hell", {
params = "", params = "[<player_name>]",
description = "Extract from hell", description = "Extract from hell",
func = function(name, pname) func = function(name, pname)
if not minetest.check_player_privs(name, {nether=true}) then if not minetest.check_player_privs(name, {nether=true}) then
local self_player = minetest.get_player_by_name(name) return false, "You need the nether priv to execute this chatcommand."
if self_player then
minetest.chat_send_player(name, "You can't send anyone to hell, go to hell instead")
player_to_nether(self_player)
else
minetest.chat_send_player(name, "Something went wrong.")
end
return false
end end
if not player_exists(pname) then if not player_exists(pname) then
pname = name pname = name
end end
local player = minetest.get_player_by_name(pname) local player = minetest.get_player_by_name(pname)
if not player then if not player then
minetest.chat_send_player(name, "Something went wrong.") return false, "Something went wrong."
return false
end end
minetest.chat_send_player(pname, "You are free now") minetest.chat_send_player(pname, "You are free now")
player_from_nether(player) player_from_nether(player)
local pos = player:getpos() local pos = player:getpos()
player:moveto({x=pos.x, y=100, z=pos.z}) player:moveto({x=pos.x, y=100, z=pos.z})
return true return true, pname.." is now out of the nether."
end end
}) })