• Make sure sent chat messages aren't chatcommands (fixes #2)
• Add checks to cloaking.cloak() and cloaking.uncloak().
This commit is contained in:
luk3yx 2018-07-26 07:29:19 +12:00
parent ad11b33cee
commit 271e978d98
2 changed files with 12 additions and 4 deletions

View File

@ -14,7 +14,7 @@ minetest.register_chatcommand("cloak", {
victim = player
end
p = cloaking.get_player_by_name(victim)
local p = cloaking.get_player_by_name(victim)
if not p then
return false, "Could not find a player with the name '" .. victim .. "'!"
end

View File

@ -87,7 +87,7 @@ local override_chatcommands = function()
end
minetest.register_on_chat_message(function(name)
if cloaked_players[name] then
if message:sub(1, 1) ~= "/" and cloaked_players[name] then
minetest.chat_send_player(name, "You cannot use chat while cloaked." ..
" Please use /uncloak if you want to use chat.")
return true
@ -111,6 +111,10 @@ cloaking.cloak = function(player)
end
local victim = player:get_player_name()
if cloaked_players[victim] then
return
end
player:set_properties({visual_size = {x = 0, y = 0}, collisionbox = {0,0,0,0,0,0}})
player:set_nametag_attributes({text = " "})
@ -140,11 +144,16 @@ cloaking.uncloak = function(player)
end
local victim = player:get_player_name()
if not cloaked_players[victim] then
return
end
player:set_properties({visual_size = {x = 1, y = 1}, collisionbox = {-0.25,-0.85,-0.25,0.25,0.85,0.25}})
player:set_nametag_attributes({text = victim})
cloaked_players[victim] = false
-- In singleplayer, there is no joined the game message by default.
if victim == "singleplayer" then
minetest.chat_send_all("*** " .. victim .. " joined the game.")
end
@ -168,8 +177,7 @@ end
cloaking.delayed_uncloak = function(player)
local victim = player:get_player_name()
if cloaked ~= 'cloaking' and
cloaked_players[victim] then
if cloaked_players[victim] then
minetest.after(0.5, function()
cloaked_players[victim] = nil
if areas and areas.hud and areas.hud[victim] then