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

Lua teleport all spectators

Lava Titan

Developer
Joined
Jul 25, 2009
Messages
1,571
Solutions
3
Reaction score
98
Location
Portugal
Code:
local specs = Game.getSpectators(Position(1000,1000,7), false, true, 0, 150, 0, 150)
        for i = 1, #specs do
            if specs[i] >= 1 then
                specs[i]:teleportTo(specs[i]:getTown():getTemplePosition(), false)
            end
        end

I was trying to teleport all players in radius X and Y of 150 to temple but it's not working
Can any1 tell me what did I do wrong :x?
 
Code:
Game.getSpectators(Position(1000,1000,7), false, true, 0, 150, 0, 150)
this Position is the CENTER of the area, not fromPos toPos

pretty sure Game.getSpectators is limited to 11 squares max
not is limited, I use it with 100 squares ;P and work perfectly
 
Last edited by a moderator:
not is limited, I use it with 100 squares ;P and work perfectly

Nice, I just read that 11 was max from gesior, just tested it and yeah it works with more than 11 :) Good to know

and to make the code work do this @Lava Titan there's no need for the if statement
Code:
local specs = Game.getSpectators(Position(1000,1000,7), false, true, 0, 150, 0, 150)
for i = 1, #specs do
specs[i]:teleportTo(specs[i]:getTown():getTemplePosition(), false)
end
 
Last edited:
Code:
    local middle = Position(1288,1179,7)
    local specs = Game.getSpectators(middle, false, true, 0, 150, 0, 150)
    for i = 1, #specs do
    specs[i]:teleportTo(specs[i]:getTown():getTemplePosition(), false)
    end

not working '-'
 
Code:
    local middle = Position(1288,1179,7)
    local specs = Game.getSpectators(middle, false, true, 0, 150, 0, 150)
    for i = 1, #specs do
    specs[i]:teleportTo(specs[i]:getTown():getTemplePosition(), false)
    end

not working '-'
change the values, 0, 150, 0, 150 ... change to 10, 10, 10, 10 just for test... now the script will teleport players in area 10x10 squares
 
because middle is declared wrong, you could just do it like you did in the start like
local specs = Game.getSpectators(Position(1000,1000,7), false, true, 0, 150, 0, 150)
or
local middle = {x = 1288, y = 1179, z = 7}
 
because middle is declared wrong, you could just do it like you did in the start like
local specs = Game.getSpectators(Position(1000,1000,7), false, true, 0, 150, 0, 150)
or
local middle = {x = 1288, y = 1179, z = 7}
no bro, is not declared wrong.. but this declaration is not needed...
 
Code:
    local middle = {x = 1288, y = 1179, z = 7}
    local specs = Game.getSpectators(middle, false, true, 150, 150, 150, 150)
    for i = 1, #specs do
    specs[i]:teleportTo(specs[i]:getTown():getTemplePosition(), false)
    end

There you go :p
 
Last edited:
Back
Top