• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

onDeath script 1.2

jackl90

Member
Joined
Jul 25, 2017
Messages
249
Reaction score
12
How can i do a onDeath script to check if the tile is pvpzone and the player died for monsters is teleported to a determinated position?
 
it 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
 
it 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
He need to check If killer is monster too
 
He need to check If killer is monster too
i can't understand his writing so what the action he want to take if killer is not player?
something like this ?
Code:
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
 
Last edited by a moderator:
Back
Top