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

TFS 1.X+ Tfs 1.2 teleport all killers, is possible?

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
201
Hi, i'm using tfs 1.2 have a boss in a game, and i need all players who dealt at least 1 damage are teleported to a position.
but its only teleporting 1 player, not everyone who attacks the boss, would i have to use another function?

i"m tryng to use something like this:
Lua:
local posFinal = Position(1000,1000,7)

function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)

    for cid, damage in pairs(creature:getDamageMap()) do
        local killer = Creature(cid)
        if killer:isPlayer() then
            killer:teleportTo(posFinal)
        end
    end

    return true
end
 
Solution
Your engine doesn't seem to be keeping track of damageMap properly.
Just use a healthChange event and store the ids of each player that damages the boss in a global variable, inside onDeath loop through the table and teleport each player id if they're still online.
You can register a creaturescript to a specific monster by adding this to its XML:
XML:
<script>
    <event name="your creaturescript event name here"/>
</script>
I think you should post your request on Request place.
About teleport, you can use like:

Lua:
-- Use this to teleport all, with or without damage
local posFinal = Position(1000,1000,7)
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    local creatures = Game.getSpectators(Position(99999,99999,9999), false, false, 20, 20, 20, 20) -- configure pos and range x y
    if creatures ~= nil then
        for i = 1, #creatures do
            local creature = creatures[i]
            if creature:isPlayer() then               
                creature:teleportTo(posFinal)
            end
        end
    end  
    return true
end

-- Use this to teleport all that deal some damage (its like your script but this is checking summons too)
local posFinal = Position(1000,1000,7)
function onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    for attackerUid, damage in pairs(creature:getDamageMap()) do
        local player = Creature(attackerUid)
        if player then
            local playerKiller = nil
            if player:isPlayer() then
                playerKiller = player
            elseif player:getMaster() then
                playerKiller = player:getMaster()
            end
            if playerKiller and playerKiller:isPlayer() then
                playerKiller:teleportTo(posFinal)
            end
        end
    end   
    return true
end
 
Last edited:
I think you should post your request on Request place.
About teleport, you can use like:

Lua:
-- Use this to teleport all, with or without damage
local posFinal = Position(1000,1000,7)
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    local creatures = Game.getSpectators(Position(99999,99999,9999), false, false, 20, 20, 20, 20) -- configure pos and range x y
    if creatures ~= nil then
        for i = 1, #creatures do
            local creature = creatures[i]
            if creature:isPlayer() then           
                creature:teleportTo(posFinal)
            end
        end
    end
    return true
end

-- Use this to teleport all that deal some damage (its like your script but this is checking summons too)
local posFinal = Position(1000,1000,7)
function onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    for attackerUid, damage in pairs(creature:getDamageMap()) do
        local player = Creature(attackerUid)
        if player then
            local playerKiller = nil
            if player:isPlayer() then
                playerKiller = player
            elseif player:getMaster() then
                playerKiller = player:getMaster()
            end
            if playerKiller and playerKiller:isPlayer() then
                playerKiller:teleportTo(posFinal)
            end
        end
    end
    return true
end

It dont work, i used like this to print a name, and attacked a monster with 2 players, it printed only 1 name.
With player A I attacked the monster until lost 80% of its life.
With player B I just finished defeating the boss.
Just printed player B (player who killed the boss)

Edit: i need player get teleported only if player has attacked the boss, like i say in the fist topic
Lua:
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)

local posFinal = Position(1000,1000,7)
    for attackerUid, damage in pairs(creature:getDamageMap()) do
        local player = Creature(attackerUid)
        if player then
            local playerKiller = nil
            if player:isPlayer() then
                playerKiller = player
            elseif player:getMaster() then
                playerKiller = player:getMaster()
            end
            if playerKiller and playerKiller:isPlayer() then
                print(playerKiller:getName())
            end
        end
    end
    return true
end
 
Last edited:
Your engine doesn't seem to be keeping track of damageMap properly.
Just use a healthChange event and store the ids of each player that damages the boss in a global variable, inside onDeath loop through the table and teleport each player id if they're still online.
You can register a creaturescript to a specific monster by adding this to its XML:
XML:
<script>
    <event name="your creaturescript event name here"/>
</script>
 
Solution
Back
Top