• 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 all player in are to area

darcioantonio

www.adventurerpg.com.br
Joined
Jul 30, 2013
Messages
165
Solutions
1
Reaction score
4
Location
Brasil
Twitch
darcio_
YouTube
UCEXCOEw_dYchojHNz
Hi, good afternoon, I need an action that teleports all the players in a certain area.
North Left: {x = 1252, y = 1007, z = 5}
South Right: {x = 1261, y = 1013, z = 5}
Final Position: {x = 1253, y = 1010, z = 6}
I found some but I could not make it work.
Thanks, remembering that I use tfs 1.2 Tibia 10.77
 
Solution
You can test this mate.

Code:
local square = {
    frompos = {x = 1252, y = 1007, z = 5},
    topos = {x = 1261, y = 1013, z = 5},
    exitpos = {x = 1253, y = 1010, z = 6}
}

for a = square.frompos.x, square.topos.x do
    for b = square.frompos.y, square.topos.y do
        pos = {x = a, y = b, z = 5, stackpos = 255}
            if(isPlayer(getTopCreature(pos).uid)) then
                doTeleportThing(getTopCreature(pos).uid,square.exitpos)
            end
    end
end
You can test this mate.

Code:
local square = {
    frompos = {x = 1252, y = 1007, z = 5},
    topos = {x = 1261, y = 1013, z = 5},
    exitpos = {x = 1253, y = 1010, z = 6}
}

for a = square.frompos.x, square.topos.x do
    for b = square.frompos.y, square.topos.y do
        pos = {x = a, y = b, z = 5, stackpos = 255}
            if(isPlayer(getTopCreature(pos).uid)) then
                doTeleportThing(getTopCreature(pos).uid,square.exitpos)
            end
    end
end
 
Solution
is working perfectly mind, I have 2 doubts, the first is if the character is in the same sqm of another character only 1 theme tp. the second is, would it be for the characters that take teleportation to go to a random area of a certain region?
 
I didn't really understand the first one, but for the second one you can surely do something like this:
Code:
local square = {
    frompos = {x = 1252, y = 1007, z = 5},
    topos = {x = 1261, y = 1013, z = 5}
}

local exitRandom = {
    [1] = {x = , y = , z = },    --You can add or remove as many positions as you want if you use that format " [X] = {x = , y = , z = }, "
    [2] = {x = , y = , z = },
    [3] = {x = , y = , z = }    --The last position doesnt have the "," at the end, remember that
}

local count = 0

for i = 1, #exitRandom do        --Here it will count as many positions as you configure on exitRandom
    count = count + 1
end

for a = square.frompos.x, square.topos.x do
    for b = square.frompos.y, square.topos.y do
        pos = {x = a, y = b, z = 5, stackpos = 255}
            if(isPlayer(getTopCreature(pos).uid)) then
                local randomTeleport = math.floor(math.random(1,count))        --Here it will choose a random number between the first to last exitRandom position you configured
                doTeleportThing(getTopCreature(pos).uid,exitRandom[randomTeleport])
            end
    end
end

Made some comments on the code, so you can understand what is happening, if that's interesting to you XD
I have to state something, if two players are found, they maybe get teleported to different places, if that's not what you wanted, we can modify the script so that it will randomize the exit position only once at the time the script is called and NOT everytime it finds a player. Test it and let me know.
 
Last edited:
Back
Top