• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[TFS 1.3] [Revscriptsys] Easy to configure teleport room script

Lundrial

lundrial:getTitle()
Joined
Apr 15, 2014
Messages
142
Reaction score
105
Location
Chile
There are a ton of scripts like this, but this one is based on revscriptsys so it's easy to install and configure, basically if you have a single destination set you will be teleported instantly, but if you add more than one a modal window will be displayed containing all destinations you added, you can also add subarea names by just adding them to the sub area part, if you don't add them it will create default subarea names with numbers.

make a .lua file on your scripts folder and add:
LUA:
-- Config
local tplist = {
    [40000] = {name = "Cyclops", positions = {{x = 343, y = 305, z = 7}, {x = 270, y = 440, z = 7}}, subareas = {'Cyclops Cave', 'Cyclops Isle'}},
    [40001] = {name = "Rotworms", positions = {{x = 216, y = 341, z = 8}}, subareas = {}}
}
local firstid = 40000 -- Put your first action id used here
local lastid = 40001 -- Put your last action id used here

-- Config End
local teleports = MoveEvent()
function teleports.onStepIn(player, item, position, fromPosition)
    if not player:isPlayer() then
        return false
    end
  
    local tp = tplist[item.actionid]
    local quantity = table.getn(tp.positions)
  
    player:registerEvent("Teleport_Modal_Window")
  
    local title = "Teleport"
    local message = "List of ".. tp.name .." Spawns"
      
    local window = ModalWindow(item.actionid, title, message)
    window:addButton(100, "Go")
    window:addButton(101, "Cancel")
      
    for i = 1, quantity do
        if tp.subareas[i] == nil then
            window:addChoice(i,"".. tp.name .." ".. i .."")
        else
            window:addChoice(i,"".. tp.subareas[i] .."")
        end
    end
  
    window:setDefaultEnterButton(100)
    window:setDefaultEscapeButton(101)
  
    if tp and quantity < 2 then
        player:unregisterEvent("Teleport_Modal_Window")
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Teleported to '.. tp.name ..'.')
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        player:teleportTo(tp.positions[1])
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    else
        window:sendToPlayer(player)
    end
    return true
end

for j = firstid, lastid do
    teleports:aid(j)
end

teleports:type("stepin")
teleports:register()

local modalTp = CreatureEvent("Teleport_Modal_Window")
modalTp:type("modalwindow")

function modalTp.onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:unregisterEvent("Teleport_Modal_Window")
    if modalWindowId >= firstid and modalWindowId <= lastid then
        if buttonId == 100 then
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(tplist[modalWindowId].positions[choiceId])
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            if tplist[modalWindowId].subareas[choiceId] == nil then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Teleported to '.. tplist[modalWindowId].name ..' '.. choiceId ..'.')
            else
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Teleported to '.. tplist[modalWindowId].subareas[choiceId] ..'.')
            end
        end
    end
    return true
end

modalTp:register()

Demo:

test.gif
 
Last edited:
what if a player stands on tile forever and you can't move him? cause the script doesn't let you walk tru
 
I got this error when step in the tile. I'm Using Otservbr

Lua Script Error: [Scripts Interface] /home/ica/home/co/data/scripts/tp.lua:callback /home/ica/home/co/data/scripts/tp.lua:17: attempt to call field 'getn' (a nil value) stack traceback: [C]: in function 'getn' /home/ica/home/co/data/scripts/tp.lua:17: in function </home/ica/home/co/data/scripts/tp.lua:11>
 
Last edited:
Cool script, I'll use it for sure.
How can I change this script to check if player is vip or not?
And if he's not vip then the player will receive a message like: "You need vip to use this"
 
Cool script, I'll use it for sure.
How can I change this script to check if player is vip or not?
And if he's not vip then the player will receive a message like: "You need vip to use this"
15th line
LUA:
if player:yourVipFunction() then
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are not VIP.')
    return true
end
 
Very good! Thank you so much

Is it possible to create a new item named "boss tp", load the item in bp and use the item?
 
@Lundrial Would you be willing to add the option of level requirements?
Untested.
LUA:
-- Config
local tplist = {
    [40000] = {name = "Cyclops", level = 15, positions = {{x = 343, y = 305, z = 7}, {x = 270, y = 440, z = 7}}, subareas = {'Cyclops Cave', 'Cyclops Isle'}},
    [40001] = {name = "Rotworms", level = 10, positions = {{x = 216, y = 341, z = 8}}, subareas = {}}
}
local firstid = 40000 -- Put your first action id used here
local lastid = 40001 -- Put your last action id used here

-- Config End
local teleports = MoveEvent()
function teleports.onStepIn(player, item, position, fromPosition)
    if not player:isPlayer() then
        return false
    end
 
    local tp = tplist[item.actionid]
    local quantity = table.getn(tp.positions)
 
    player:registerEvent("Teleport_Modal_Window")
 
    local title = "Teleport"
    local message = "List of ".. tp.name .." Spawns"
      
    local window = ModalWindow(item.actionid, title, message)
    window:addButton(100, "Go")
    window:addButton(101, "Cancel")
      
    for i = 1, quantity do
        if tp.subareas[i] == nil then
            window:addChoice(i,"".. tp.name .." ".. i .."")
        else
            window:addChoice(i,"".. tp.subareas[i] .."")
        end
    end
 
    window:setDefaultEnterButton(100)
    window:setDefaultEscapeButton(101)
 
    if tp and quantity < 2 then
        player:unregisterEvent("Teleport_Modal_Window")
        
        if player:getLevel() < tp.level then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You do not have the required level.')
            return true
        end
    
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Teleported to '.. tp.name ..'.')
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        player:teleportTo(tp.positions[1])
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    else
        window:sendToPlayer(player)
    end
    return true
end

for j = firstid, lastid do
    teleports:aid(j)
end

teleports:type("stepin")
teleports:register()

local modalTp = CreatureEvent("Teleport_Modal_Window")
modalTp:type("modalwindow")

function modalTp.onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:unregisterEvent("Teleport_Modal_Window")
    if modalWindowId >= firstid and modalWindowId <= lastid then
        if buttonId == 100 then
        
            if player:getLevel() < tplist[modalWindowId].level then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You do not have the required level.')
                return true
            end
        
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(tplist[modalWindowId].positions[choiceId])
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            if tplist[modalWindowId].subareas[choiceId] == nil then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Teleported to '.. tplist[modalWindowId].name ..' '.. choiceId ..'.')
            else
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Teleported to '.. tplist[modalWindowId].subareas[choiceId] ..'.')
            end
        end
    end
    return true
end

modalTp:register()
 
Do the levels take subareas into consideration? For example, I want 1 area to be no level required but the second layer have a level requirement.
 
Do the levels take subareas into consideration? For example, I want 1 area to be no level required but the second layer have a level requirement.
:)
If you have subareas, make sure levels are in a table (wrapped in { }), and leave level as 0 if you dont need a level for that area/subarea.
Again, untested.
LUA:
-- Config
local tplist = {
    [40000] = {name = "Cyclops", level = {0, 30} positions = {{x = 343, y = 305, z = 7}, {x = 270, y = 440, z = 7}}, subareas = {'Cyclops Cave', 'Cyclops Isle'}},
    [40001] = {name = "Rotworms", level = 10, positions = {{x = 216, y = 341, z = 8}}, subareas = {}}
}
local firstid = 40000 -- Put your first action id used here
local lastid = 40001 -- Put your last action id used here

-- Config End
local teleports = MoveEvent()
function teleports.onStepIn(player, item, position, fromPosition)
    if not player:isPlayer() then
        return false
    end
 
    local tp = tplist[item.actionid]
    local quantity = table.getn(tp.positions)
 
    player:registerEvent("Teleport_Modal_Window")
 
    local title = "Teleport"
    local message = "List of ".. tp.name .." Spawns"
      
    local window = ModalWindow(item.actionid, title, message)
    window:addButton(100, "Go")
    window:addButton(101, "Cancel")
      
    for i = 1, quantity do
        if tp.subareas[i] == nil then
            window:addChoice(i,"".. tp.name .." ".. i .."")
        else
            window:addChoice(i,"".. tp.subareas[i] .."")
        end
    end
 
    window:setDefaultEnterButton(100)
    window:setDefaultEscapeButton(101)
 
    if tp and quantity < 2 then
        player:unregisterEvent("Teleport_Modal_Window")
        
        local levelReq = tp.level
        if levelReq > 0 and player:getLevel() < levelReq then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You do not have the required level.')
            return true
        end
    
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Teleported to '.. tp.name ..'.')
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        player:teleportTo(tp.positions[1])
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    else
        window:sendToPlayer(player)
    end
    return true
end

for j = firstid, lastid do
    teleports:aid(j)
end

teleports:type("stepin")
teleports:register()

local modalTp = CreatureEvent("Teleport_Modal_Window")
modalTp:type("modalwindow")

function modalTp.onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:unregisterEvent("Teleport_Modal_Window")
    if modalWindowId >= firstid and modalWindowId <= lastid then
        if buttonId == 100 then
            
            local levelReq = tplist[modalWindowId].level[choiceId]
            if levelReq > 0 and player:getLevel() < levelReq then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You do not have the required level.')
                return true
            end
        
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(tplist[modalWindowId].positions[choiceId])
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            if tplist[modalWindowId].subareas[choiceId] == nil then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Teleported to '.. tplist[modalWindowId].name ..' '.. choiceId ..'.')
            else
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Teleported to '.. tplist[modalWindowId].subareas[choiceId] ..'.')
            end
        end
    end
    return true
end

modalTp:register()
 
@Boy67 I got this error o.o

LUA:
73: attempt to index field 'level' (a nil value)
stack traceback:

EDIT:
... I'm dumb. It works perfectly.
 
Last edited:
There is a minor change I would recommend for anyone that uses the level requirement version of the script for improved quality of life, it shows what level is required in the failure to teleport description.

LUA:
local tplist = {
    [40000] = {name = "Cyclops", level = {1, 50}, positions = {{x = 343, y = 305, z = 7}, {x = 270, y = 440, z = 7}}, subareas = {'Cyclops Cave', 'Cyclops Isle'}},
    [40001] = {name = "Rotworms", level = 50, positions = {{x = 216, y = 341, z = 8}}, subareas = {}}
}
local firstid = 40000 -- Put your first action id used here
local lastid = 40001 -- Put your last action id used here

-- Config End
local teleports = MoveEvent()
function teleports.onStepIn(player, item, position, fromPosition)
    if not player:isPlayer() then
        return false
    end
 
    local tp = tplist[item.actionid]
    local quantity = table.getn(tp.positions)
 
    player:registerEvent("Teleport_Modal_Window")
 
    local title = "Teleport"
    local message = "List of ".. tp.name .." Spawns"
   
    local window = ModalWindow(item.actionid, title, message)
    window:addButton(100, "Go")
    window:addButton(101, "Cancel")
   
    for i = 1, quantity do
        if tp.subareas[i] == nil then
            window:addChoice(i,"".. tp.name .." ".. i .."")
        else
            window:addChoice(i,"".. tp.subareas[i] .."")
        end
    end
 
    window:setDefaultEnterButton(100)
    window:setDefaultEscapeButton(101)
 
    if tp and quantity < 2 then
        player:unregisterEvent("Teleport_Modal_Window")
     
        local levelReq = tp.level
        if levelReq > 0 and player:getLevel() < levelReq then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You do not have the required level of '.. tp.level ..'.')
            return true
        end
 
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Teleported to '.. tp.name ..'.')
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        player:teleportTo(tp.positions[1])
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    else
        window:sendToPlayer(player)
    end
    return true
end
for j = firstid, lastid do
    teleports:aid(j)
end
teleports:type("stepin")
teleports:register()
local modalTp = CreatureEvent("Teleport_Modal_Window")
modalTp:type("modalwindow")
function modalTp.onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:unregisterEvent("Teleport_Modal_Window")
    if modalWindowId >= firstid and modalWindowId <= lastid then
        if buttonId == 100 then
         
            local levelReq = tplist[modalWindowId].level[choiceId]
            if levelReq > 0 and player:getLevel() < levelReq then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You do not have the required level of '.. levelReq ..'.')
                return true
            end
     
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(tplist[modalWindowId].positions[choiceId])
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            if tplist[modalWindowId].subareas[choiceId] == nil then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Teleported to '.. tplist[modalWindowId].name ..' '.. choiceId ..'.')
            else
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Teleported to '.. tplist[modalWindowId].subareas[choiceId] ..'.')
            end
        end
    end
    return true
end
modalTp:register()
 
Back
Top