• 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 Auto Teleport for GM & OtsClient

Anghelos

Member
Joined
Nov 1, 2014
Messages
30
Reaction score
10
The idea is to use the Admin on my Local server with RL map to have the full clean map on OtsClient.
As soon as i have the full RL map cleared i will release it for everybody that are using OtsClient (which is amazing) and plays in a RL map.

so here is a script i found (dunno the version of the script, i'm using TFS 1.0) but doesn't work, seems that i can't enter the if statement where is the doteleportThing...dunno why.
and this is the script:
Code:
local map = {
    Xmax=33760;
    Ymax=33023;
    Xstart=36;
    Ystart=36;
    Zstart=7;
    --
    Delay=1500;
    Skip_tiles=4;
    Floors_skip=1; --Can be 1 or -1
    Floors_count=3; --Start form floor Zstart and stop after be teleproted to 3 floors
}

function cycle(player,x,y,z,c)
    local player = Player(cid)
--    if not isPlayer(cid) then
--    print('ancora qui?');
--        return 0;
--    end
    x = x+map.Skip_tiles;
    if x > map.Xmax then
        x = map.Xmax;
    end
    if (getThingfromPos({x=x,y=y,z=z},false) or {}).uid ~= nil then
        print('qui ci entro?');
        doTeleportThing(cid,{x=x,y=y,z=z})
    end
    if x == map.Xmax then
        x = map.Xstart;
        y = y+map.Skip_tiles;
    end
    print('x= ' .. (x) .. 'y= ' .. (y) .. 'mapx= ' .. (map.Xmax) .. 'mapy= ' .. (map.Ymax));
    if y >= map.Ymax then
        y = map.Ystart;
        z = z+Floors_skip;
        c = c-1;
        if c <= 0 then
            return 0;
        end
    end
    addEvent(cycle,map.Delay,cid,x,y,z,c)
end
function onSay(player, words, param)
    local player = Player(cid)
    cycle(cid,map.Xstart,map.Ystart,map.Zstart,map.Floors_count)
end

OFC, if some1 has the complete RL map for OtsClient and wants to share ....is more than welcome :)
 
Last edited:
I don't really understand your script, but from what I can gather, it will teleport until it can't any longer, then go in a different direction, or up/down floors?

The problem with this method is mainly that not every tile is walkable.
You would need to get every tile walkable, so that you can explore every part of the map. otherwise when it goes down it would only explore a fraction of what is underneath..
and if it went up, it wouldn't be able to access all of the buildings.
 
well, if i could manage to do this part working:

if (getThingfromPos({x=x,y=y,z=z},false) or {}).uid ~= nil then
print('qui ci entro?');
doTeleportThing(cid,{x=x,y=y,z=z})
end

would be great, then i guess i will check for other errors or problems
 
TFS 1.0 not exist function doteleporthing..
changed:
Code:
doTeleportThing(cid,{x=x,y=y,z=z})
with
Code:
player:teleportTo({x=x,y=y,z=z})


Code:
local map = {
    Xmax=33760;
    Ymax=33023;
    Xstart=36;
    Ystart=36;
    Zstart=7;
    --
    Delay=1500;
    Skip_tiles=4;
    Floors_skip=1; --Can be 1 or -1
    Floors_count=3; --Start form floor Zstart and stop after be teleproted to 3 floors
}

function cycle(player,x,y,z,c)
    local player = Player(cid)
--    if not isPlayer(cid) then
--    print('ancora qui?');
--        return 0;
--    end
    x = x+map.Skip_tiles;
    if x > map.Xmax then
        x = map.Xmax;
    end
    if isInRange(player:getPosition(), map.Xmax, map.Ymax) then
        print('qui ci entro?');
        player:teleportTo({x=x,y=y,z=z})
    end
    if x == map.Xmax then
        x = map.Xstart;
        y = y+map.Skip_tiles;
    end
    print('x= ' .. (x) .. 'y= ' .. (y) .. 'mapx= ' .. (map.Xmax) .. 'mapy= ' .. (map.Ymax));
    if y >= map.Ymax then
        y = map.Ystart;
        z = z+Floors_skip;
        c = c-1;
        if c <= 0 then
            return 0;
        end
    end
    addEvent(cycle,map.Delay,cid,x,y,z,c)
end
function onSay(player, words, param)
    local player = Player(cid)
    cycle(cid,map.Xstart,map.Ystart,map.Zstart,map.Floors_count)
end


anywais in compat.lua u can add function

Code:
function doTeleportThing(uid, dest, pushMovement)
    if type(uid) == "userdata" then
        if uid:isCreature() then
            return uid:teleportTo(dest, pushMovement or false)
        else
            return uid:moveTo(dest)
        end
    else
        if uid >= 0x10000000 then
            local creature = Creature(uid)
            if creature ~= nil then
                return creature:teleportTo(dest, pushMovement or false)
            end
        else
            local item = Item(uid)
            if item ~= nil then
                return item:moveTo(dest)
            end
        end
    end
    return false
end

https://github.com/otland/forgottenserver/blob/master/data/compat.lua
 
Last edited:
Wow...thx for the answer...! I didn't expect so much help!
Anyways, it doesn't work :p I have the following error: attempt to index local 'fromPos' (a number value)

when i'm in local i just type /cycle
I was wondering if i need some argument to the function (it should get in automatic anyway)


Edit again: i also tried to override the if statement and execute directly the teleport...it's not working and i have no error in console...but it might be becoz of the previous problem =/
 
Last edited:
Code:
local map = {
    Xmax=33760;
    Ymax=33023;
    Xstart=36;
    Ystart=36;
    Zstart=7;
    --
    Delay=1500;
    Skip_tiles=4;
    Floors_skip=1; --Can be 1 or -1
    Floors_count=3; --Start form floor Zstart and stop after be teleproted to 3 floors
}

function cycle(cid,x,y,z,c)
    local player = Player(cid)
    if not isPlayer(cid) then
        return 0;
    end
    x = x+map.Skip_tiles;
    if x > map.Xmax then
        x = map.Xmax;
    end
    if isInRange(player:getPosition(), map.Xmax, map.Ymax) then
    player:teleportTo({x=x,y=y,z=z})
    -- doTeleportThing(cid,{x=x,y=y,z=z})
    end
    if x == map.Xmax then
        x = map.Xstart;
        y = y+map.Skip_tiles;
    end
   -- print('x= ' .. (x) .. 'y= ' .. (y) .. 'mapx= ' .. (map.Xmax) .. 'mapy= ' .. (map.Ymax));
    if y >= map.Ymax then
        y = map.Ystart;
        z = z+Floors_skip;
        c = c-1;
        if c <= 0 then
            return 0;
        end
    end
    addEvent(cycle,map.Delay,cid,x,y,z,c)
end
function onSay(cid, words, param)
    local player = Player(cid)
    cycle(cid,map.Xstart,map.Ystart,map.Zstart,map.Floors_count)
end
 
What function have this script?

Code:
local cfg = {
        teleportPos = Position(33760, 33023, 7),
        toPos = Position(33760, 33023, 7),
        fromPos = Position(33750, 33023, 7),
        Xstart=36,
        Ystart=36,
        Zstart=7,
        Delay = 1500,
        Skip_tiles = 4,
        Floors_skip = 1,
        Floors_count = 3
}

function cycle(cid,x,y,z,c)
    local player = Player(cid)
    if not isPlayer(cid) then
        return 0;
    if isInRange(player:getPosition() or {}).uid ~= nil then
    player:teleportTo(cfg.teleportPos)
    end
    if x == cfg.teleportPos then
        x = cfg.Xstart;
        y = y+cfg.Skip_tiles;
    end

    if y >= cfg.Ymax then
        y = cfg.Ystart;
        z = z+Floors_skip;
        c = c-1;
        if c <= 0 then
            return 0;
        end
    end
    addEvent(cycle,map.Delay,cid,x,y,z,c)
end
function onSay(cid, words, param)
    local player = Player(cid)
    cycle(cid,cfg.Xstart,cfg.Ystart,cfg.Zstart,cfg.Floors_count)
end
 
Last edited:
Back
Top