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

Teleport players in a specific area

Firulis

New Member
Joined
Jan 3, 2017
Messages
34
Solutions
2
Reaction score
1
I'm working on a script and im currently stuck :\ basically when a player steps on a tile players in a specific area will be teleported to temple, im able to do it but when the players are in the same floor, but when they're in different floors it doesnt work at all. this is what i currently have:
Code:
local topLeft = {x = 997, y = 997, z = 8}
local bottomRight = {x = 1005, y = 1007, z = 4}
local temple = {x = 60, y = 54, z = 7}
function doRemoveRunners()
    for index, creature in ipairs(getPlayersOnline()) do
        if isInArea(getThingPos(creature), topLeft, bottomRight) then
                doTeleportThing(creature, temple)
        end
    end
    return true
end
my goal is to teleport players even if they're in a different floor, but in the same rectangle if that makes sense thanks.
 
lib
Lua:
function isCreatureInArea(fromPos, toPos)
    local t = {}
    for z=fromPos.z, toPos.z do
        for y=fromPos.y, toPos.y do
            for x=fromPos.x, toPos.x do
                local v = getTopCreature({x=x,y=y,z=z})
                if v.itemid == 1 and table.find({1,2,3}, v.type) then
                    table.insert(t, v.uid)
                end
            end
        end
    end
    return t
end

script
Lua:
local topLeft = {x = 997, y = 997, z = 8}
local bottomRight = {x = 1005, y = 1007, z = 4}
local temple = {x = 60, y = 54, z = 7}
function doRemoveRunners()
    for index, creature in ipairs(getPlayersOnline()) do
        if #isCreatureInArea(topLeft, bottomRight) > 0 then
                doTeleportThing(creature, temple)
        end
    end
    return true
end
 
Back
Top