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

Action [TFS 1.3] Teleport to trainers.

Perun

nems.online
Joined
May 1, 2009
Messages
378
Solutions
7
Reaction score
176
Teleport you to first free slot - simple version.
Tommorow i will create/upload infinity training room too. (just saw messages about that).

tiX8q2R.jpg


Lua:
local config = {
    leftTopCorner = {x = 1046, y = 996},
    rightDownCorner = {x = 1071, y = 1011},
    zPos = 7,
    tileItemId = 407, --tile item id for scanner, where you want to teleport player, ez to change for tile with uid if someone need
}

local function findFirstEmpty()
    for x = config.leftTopCorner.x, config.rightDownCorner.x do
        for y = config.leftTopCorner.y, config.rightDownCorner.y do
            local tmpPos = {x=x, y=y, z = config.zPos};
            local t = Tile(tmpPos)
            if t ~= nil then
                if(t:getThing():getId() == config.tileItemId and not t:getTopCreature()) then
                    return tmpPos
                end
            end
        end
    end
    return false
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local availableTrainingSlot = findFirstEmpty()
    if(availableTrainingSlot) then
        cid:teleportTo(availableTrainingSlot)
        cid:sendTextMessage(MESSAGE_INFO_DESCR, "Welcome.")
    else
        cid:sendTextMessage(MESSAGE_INFO_DESCR, "No available slots.")
    end
    return true
end
 
are you people never tired of tp servers and crazy exp stuff no one has spirit of adventure here or what
the creativity is fading on this comunity
 
Incomplete script. It indeed work, but you need to do a function to verify every tile for free slots after every teleportation, otherwise when someone is teleported to a tile, it never clear itself, even before the player leaves. So the way that is, only one player can use all slots if he leaves and come back, then after using all slots, no one can enter anymore...
 
Back
Top