• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

help with a function tfs 1.1

silveralol

Advanced OT User
Joined
Mar 16, 2010
Messages
1,484
Solutions
9
Reaction score
217
well guys, in tfs 1.0 have a function interesting
Code:
function teleportAllPlayersFromAnother(fromArea, toPos)
    for x = fromArea[1].x, fromArea[2].x do
        for y = fromArea[1].y, fromArea[2].y do
            for z = fromArea[1].z, fromArea[2].z do
                if(getThingfromPos({x = x, y = y, z = z, stackpos = 255}).uid > 0) then
                    local thing = getThingfromPos({x = x, y = y, z = z, stackpos = 255})
                    local player = Player(thing.uid)
                    if thing and player then
                        doTeleportThing(thing.uid, toPos)
                    end
                end
            end
        end
    end
    return true
end
how I can update this function to tfs 1.1?
 
Code:
function teleportAllPlayersFromAnother(fromArea, toPosition)
    local width = (math.max(fromArea[1].x, fromArea[2].x) - math.min(fromArea[1].x, fromArea[2].x)) / 2 + 1
    local height = (math.max(fromArea[1].y, fromArea[2].y) - math.min(fromArea[1].y, fromArea[2].y)) / 2 + 1
    local position = Position(math.min(fromArea[1].x, fromArea[2].x) + width, math.min(fromArea[1].y, fromArea[2].y) + height, fromArea[1].z}
    for _, cid in pairs(Game.getSpectators(position, 0, width, 0, height, false, true)) do
        Player(cid):teleportTo(toPosition)
    end
    return true
end

You should just push the fromPosition and toPosition arguments from start, this will translate that code to get those 2 positions insted.
And use the getSpectators function insted :p
 
Cant you insert this function into the lib?
I tryed but not work properly...
Code:
function teleportAllPlayersFromAnother(fromArea, toPosition)
    local width = (math.max(fromArea[1].x, fromArea[2].x) - math.min(fromArea[1].x, fromArea[2].x)) / 2 + 1
    local height = (math.max(fromArea[1].y, fromArea[2].y) - math.min(fromArea[1].y, fromArea[2].y)) / 2 + 1
    local position = Position(math.min(fromArea[1].x, fromArea[2].x) + width, math.min(fromArea[1].y, fromArea[2].y) + height, fromArea[1].z}
    for _, cid in pairs(Game.getSpectators(position, 0, width, 0, height, false, true)) do
        Player(cid):teleportTo(toPosition)
    end
    return true
end

You should just push the fromPosition and toPosition arguments from start, this will translate that code to get those 2 positions insted.
And use the getSpectators function insted :p
ya, thanks, I got sucess with this, thanks
 
Back
Top