• 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!

Lua [HELP] Function onPrepareDeath

Wanheda

New Member
Joined
Feb 17, 2016
Messages
44
Solutions
2
Reaction score
4
I have this script where the loser is teleported when you die inside the arena ,
I would like to make the winner also be teleported out saying he won?


Code:
local arena = {
    frompos = {x = 97, y = 36, z = 9},
    topos = {x = 109, y = 47, z = 9},
    exitpos = {x = 93, y = 40, z = 8}
}

function onPrepareDeath(player, lastHitKiller, mostDamageKiller)
    if player:isPlayer() then
        local ppos = player:getPosition()
        if isInRange(ppos, arena.frompos, arena.topos) then
            local maxhp = player:getMaxHealth()
            player:addHealth(maxhp)
            addEvent(doCreatureAddHealth, 100, player:getId(), maxhp)
            player:sendTextMessage(MESSAGE_STATUS_WARNING,"[Arena]: You lost the duel.")
        end
        if isInRange(ppos, arena.frompos, arena.topos) then
            player:teleportTo(arena.exitpos)
            return true
        end
    end
    return true
end

function onLogin(player)
    player:registerEvent("pvparena")
    return true
end
 
Code:
local arena = {
    frompos = {x = 97, y = 36, z = 9},
    topos = {x = 109, y = 47, z = 9},
    exitpos = {x = 93, y = 40, z = 8}
}

function onPrepareDeath(player, lastHitKiller, mostDamageKiller)
    if player:isPlayer() then
        local ppos = player:getPosition()
        if isInRange(ppos, arena.frompos, arena.topos) then
            local maxhp = player:getMaxHealth()
            player:addHealth(maxhp)
            addEvent(doCreatureAddHealth, 100, player:getId(), maxhp)
            player:sendTextMessage(MESSAGE_STATUS_WARNING,"[Arena]: You lost the duel.")
        end
        if isInRange(ppos, arena.frompos, arena.topos) then
            player:teleportTo(arena.exitpos)
            if lastHitKiller:isPlayer() then
                lastHitKiller:teleportTo(arena.exitpos)
            else
                print(type(lastHitKiller))
            end
            return true
        end
    end
    return true
end

function onLogin(player)
    player:registerEvent("pvparena")
    return true
end
 
Back
Top