• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

TFS 1.X+ create teleport by pulling levers tfs 1.5

bpm91

Active Member
Joined
May 23, 2019
Messages
455
Solutions
7
Reaction score
44
Location
Brazil
hello I'm trying to make the teleport be created, and that after 4 minutes after pulling the first lever they all return to the initial starting point and the teleport disappears but when I pull they don't create the teleport and don't go back to normal

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local leverOn = 1945 -- id da alavanca on (qnd o player da o 1 use)
    local leverOf = 1946 -- id da alavanca off
    local config = {
        [1] = {x = 33320, y = 32682, z = 14}, -- [actionid] = posição da alavanca
        [2] = {x = 33349, y = 32680, z = 14}, -- posição da alavanca
        [3] = {x = 33358, y = 32701, z = 14}, -- posição da alavanca
        [4] = {x = 33338, y = 32702, z = 14}, -- posição da alavanca
        [5] = {x = 33305, y = 32734, z = 14}, -- posição da alavanca
        [6] = {x = 33357, y = 32749, z = 14}, -- posição da alavanca
        [7] = {x = 33368, y = 32763, z = 14}, -- posição da alavanca
        [8] = {x = 33382, y = 32786, z = 14}, -- posição da alavanca
    }
    local time = 4 -- 4 minutos

    local teleportId = 1387 -- id do tp
    local tpPos = {x = 33399, y = 32802, z = 14} -- pos do tp
    local toTpPos = {x = 33367, y = 32805, z = 14} -- pos que o tp vai levar


    if (item:getId() == 1945) then
        item:transform(1946)
    elseif (item:getId() == 1946) then
        item:transform(1945)
    end
    local lever1 = Tile({x = config[1].x, y = config[1].y, z = config[1].z}):getItemById(leverOn)
    local lever2 = Tile({x = config[2].x, y = config[2].y, z = config[2].z}):getItemById(leverOn)
    local lever3 = Tile({x = config[3].x, y = config[3].y, z = config[3].z}):getItemById(leverOn)
    local lever4 = Tile({x = config[4].x, y = config[4].y, z = config[4].z}):getItemById(leverOn)
    local lever5 = Tile({x = config[5].x, y = config[5].y, z = config[5].z}):getItemById(leverOn)
    local lever6 = Tile({x = config[6].x, y = config[6].y, z = config[6].z}):getItemById(leverOn)
    local lever7 = Tile({x = config[7].x, y = config[7].y, z = config[7].z}):getItemById(leverOn)
    local lever8 = Tile({x = config[8].x, y = config[8].y, z = config[8].z}):getItemById(leverOn)
    if (lever1 and lever2 and lever3 and lever4 and lever5 and lever6 and lever7 and lever8) then
        local item2 = Game.createItem(teleportId, 1,cpPos)
        if item2:isTeleport() then
            item2:setDestination(toTpPos)
        end
        return true
    end
    addEvent(function ()
        if (not lever1 or not lever2 or not lever3 or not lever4 or not lever5 or not lever6 or not lever7 or not lever8) then
            lever1:transform(leverOf)
            lever2:transform(leverOf)
            lever3:transform(leverOf)
            lever4:transform(leverOf)
            lever5:transform(leverOf)
            lever6:transform(leverOf)
            lever7:transform(leverOf)
            lever8:transform(leverOf)
        end
    end, time * 1000 * 60 * 60 )
    return true
end
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,185
Solutions
128
Reaction score
1,459
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
try with:
Lua:
local leverOn = 1945 -- id da alavanca on (qnd o player da o 1 use)
local leverOf = 1946 -- id da alavanca off
local config = {
    Position(33320, 32682, 14), -- [actionid] = posição da alavanca
    Position(33349, 32680, 14), -- posição da alavanca
    Position(33358, 32701, 14), -- posição da alavanca
    Position(33338, 32702, 14), -- posição da alavanca
    Position(33305, 32734, 14), -- posição da alavanca
    Position(33357, 32749, 14), -- posição da alavanca
    Position(33368, 32763, 14), -- posição da alavanca
    Position(33382, 32786, 14) -- posição da alavanca
}

local time = 4 -- 4 minutos
local teleportId = 1387 -- id do tp
local tpPos = Position(33398, 32702, 14) -- pos do tp
local toTpPos = Position(33367, 32705, 14) -- pos que o tp vai levar

local function resetAllLevers()
    for i = 1, #config do
        local tile = Tile(config[i])
        if tile then
            local lever = tile:getItemById(leverOn)
            if lever then
                lever:transform(leverOf)
            end
        end
    end

    local tile = Tile(tpPos)
    if tile then
        local item = tile:getItemById(teleportId)
        if item then
            item:remove()
            tpPos:sendMagicEffect(CONST_ME_POFF)
        end
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    item:transform(item:getId() == 1945 and 1946 or 1945)
    for i = 1, #config do
        local tile = Tile(config[i])
        if not tile or not tile:getItemById(leverOn) then
            return true
        end
    end

    local teleport = Game.createItem(teleportId, 1, tpPos)
    teleport:setDestination(toTpPos)
    addEvent(resetAllLevers, time * 60 * 1000)
    return true
end

lver.gif
 
Last edited:
OP
OP
bpm91

bpm91

Active Member
Joined
May 23, 2019
Messages
455
Solutions
7
Reaction score
44
Location
Brazil
this creates the teleport by pulling only 1 lever

lever did not reset either

when pulling one the others are blocked :/
 

underewar

Active Member
Joined
Feb 9, 2013
Messages
41
Reaction score
42
Location
Brazil
GitHub
Underewarrr
this creates the teleport by pulling only 1 lever

lever did not reset either

when pulling one the others are blocked :/
Take a look here.
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,185
Solutions
128
Reaction score
1,459
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
Solution
Top