• 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+ Teleport Player In Area

Fabi Marzan

Well-Known Member
Joined
Aug 31, 2020
Messages
135
Solutions
6
Reaction score
67
Good, I have a script that makes you teleport when you kill a monster, but it only teleports one player, what I want to do is if they are in the right area all the players are teleported.

It's a revscript:
Lua:
local creatureevent = CreatureEvent("onDeath_teleportKiller")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    killer:teleportTo(Position(10275, 13607, 6))
    killer:setDirection(DIRECTION_SOUTH)
    killer:popupFYI("Congratulations, you have killed the Amazona to get here we give you a +1 [Boss Points].")
    killer:getPosition():sendAnimatedText(TEXTCOLOR_LIGHTGREEN, "+1 Boss")
    killer:getPosition():sendMagicEffect(28)
    return true
end

creatureevent:register()

As it says here:
Code:
killer:teleportTo(Position(10275, 13607, 6))

When you kill the boss, it teleports you, how can I convert it to an area that teleports them to that same location.

Screenshot_10.png

The seen they use from, topos, i tried to do it like this:
Code:
local config = {
    [1] = {
        from_pos = {x = 1003, y = 1007, z = 6},
        to_pos = {x = 1006, y = 1009, z = 6}
    }
}

From here I don't know how to accommodate it.
 
Solution
Lua:
local cfg = {
    centrePosition = Position(250, 250, 7),
    xRange = 1, -- smallest size you can use is 1. do not put 0, or it's range defaults to 12.
    yRange = 1, -- (range 1 is an 'exori' 3 by 3 tiles. range 2 is 5 by 5 tiles)
    multifloor = false, -- if you need to check all floors, not only Z floor from centrePosition
    onlyPlayers = true,
    teleportPosition = Position(10275, 13607, 6)
}

local creatureevent = CreatureEvent("onDeath_teleportKiller")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local spectators = Game.getSpectators(cfg.centrePosition, cfg.multifloor, cfg.onlyPlayers, cfg.xRange, cfg.xRange, cfg.yRange, cfg.yRange)
    for i = 1...
Lua:
local cfg = {
    centrePosition = Position(250, 250, 7),
    xRange = 1, -- smallest size you can use is 1. do not put 0, or it's range defaults to 12.
    yRange = 1, -- (range 1 is an 'exori' 3 by 3 tiles. range 2 is 5 by 5 tiles)
    multifloor = false, -- if you need to check all floors, not only Z floor from centrePosition
    onlyPlayers = true,
    teleportPosition = Position(10275, 13607, 6)
}

local creatureevent = CreatureEvent("onDeath_teleportKiller")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local spectators = Game.getSpectators(cfg.centrePosition, cfg.multifloor, cfg.onlyPlayers, cfg.xRange, cfg.xRange, cfg.yRange, cfg.yRange)
    for i = 1, #spectators do
        local player = spectators[i]
        player:teleportTo(cfg.teleportPosition)
        player:setDirection(DIRECTION_SOUTH)
        player:popupFYI("Congratulations, you have killed the Amazona to get here we give you a +1 [Boss Points].")
        if i == #spectators then
            player:getPosition():sendAnimatedText(TEXTCOLOR_LIGHTGREEN, "+1 Boss")
            player:getPosition():sendMagicEffect(28)
        end
    end
    return true
end

creatureevent:register()
 
Solution
Back
Top