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

Solved Teleport all players and monsters from room

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,758
Solutions
127
Reaction score
2,277
Hello, im trying to make script to teleport all players and monsters from room to another room.
I did something like that, but its not everytime teleporting every player and monster, just two or one.
It's for creaturescripts

Code:
function teleportback()
        player = Creature(cid)
        pposback = Position(33324, 33224, 8)  
        local specs, spec = Game.getSpectators(centerRoomPos, false, false, 15, 15, 15, 15)
        for i = 1, #specs do
            spec = specs[i]
            spec:teleportTo(pposback)
        end
  
    return false
end

It work, but when I enter chance:
Code:
if math.random(1,100) <= 1 then
then its not teleporting all monsters and players ;/

Also is any way to make delays in creaturescript? For example spell for monster?
 
Code:
function teleportback()
    local pposback = Position(33324, 33224, 8) 
    local centerRoomPos = ?
    local specs, spec = Game.getSpectators(centerRoomPos, false, false, 15, 15, 15, 15)
    if #specs ~= nil then
        for i = 1, #specs do
            spec = specs[i]
            spec:teleportTo(pposback)
        end
    end   
    return true
end

Try this with or without centerRoomPos defined.
 
Dunno for what purpose you made this, but try something like :

Code:
function tpBack(centerPos, backPos)
Local specs = Game.getspectators(centerPos, false, false, 15, 15, 15, 15)

if math.random(1, 100) <= 1 then
for_, creatures in pairs(specs) do
creatures:teleportTo(backPos)
end
end
return true
end

I haven't tested this, also sorry for no indentation, wrote this on my phone while in the car

Usage:
Code:
tpBack(Position(1, 2, 3), Position(4, 5, 6))
 
Thank you guys! Well my error was as @Zothion mentioned. I put math.random in wrong line, so spectators was using math.random while teleporting to other room. Never thought of that...
Thanks for help :D
Solved.
 
Back
Top