function onPrepareDeath(player, killer)
local tile = Tile(player:getPosition()):hasFlag(TILESTATE_PVPZONE)
if tile then
player:teleportTo(player:getTown():getTemplePosition())
player:addHealth(player:getMaxHealth() - 200)
end
return false
end
He need to check If killer is monster tooit can't be onDeath.
Code:function onPrepareDeath(player, killer) local tile = Tile(player:getPosition()):hasFlag(TILESTATE_PVPZONE) if tile then player:teleportTo(player:getTown():getTemplePosition()) player:addHealth(player:getMaxHealth() - 200) end return false end
i can't understand his writing so what the action he want to take if killer is not player?He need to check If killer is monster too
function onPrepareDeath(player, killer)
local tile = Tile(player:getPosition()):hasFlag(TILESTATE_PVPZONE)
if tile then
if killer ~= nil then
if killer:isPlayer() then
player:teleportTo(player:getTown():getTemplePosition()) --to be teleported when killed by player
player:addHealth(player:getMaxHealth() - 200)
else
local master = killer:getMaster()
if master and master ~= killer and master:isPlayer() then
player:teleportTo(player:getTown():getTemplePosition()) --to be teleported when killed by any player summon
player:addHealth(player:getMaxHealth() - 200)
else
player:teleportTo(player:getTown():getTemplePosition()) -- to be teleported when killed by normal monsters
player:addHealth(player:getMaxHealth() - 200)
end
end
end
end
return false
end