• 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 I need help to add time for levers to return to ID (1945) after the player enters the teleport

Rngomes

New Member
Joined
Oct 24, 2014
Messages
3
Reaction score
0
I need help to add time for levers to return to ID (1945) after 5 minutes the player enters the teleport .. sorry i'n newbie :(

Lua:
local pos_certa = {x = 33368, y = 32805, z = 14} -- Correct Position
local pos_errada = {x = 33399, y = 32801, z = 14} -- Wrong Position

local alavancas = {
    [1] = {x = 33320, y = 32682, z = 14},
    [2] = {x = 33349, y = 32680, z = 14},
    [3] = {x = 33358, y = 32701, z = 14},
    [4] = {x = 33338, y = 32702, z = 14},
    [5] = {x = 33305, y = 32734, z = 14},
    [6] = {x = 33357, y = 32749, z = 14},
    [7] = {x = 33368, y = 32763, z = 14},
    [8] = {x = 33382, y = 32786, z = 14},
}

local levers = { -- Initial state
    [1] = "d",
    [2] = "d",
    [3] = "d",
    [4] = "d",
    [5] = "d",
    [6] = "d",
    [7] = "d",
    [8] = "d",
}

local aux = {"d", "e"}

function onStepIn(cid, item, position, fromPosition)
    for id, pos in ipairs(alavancas) do
        local itemid = levers[id] == "d" and 1946 or 1945
        if getTileItemById(pos, itemid).uid < 100 then
            doSendMagicEffect(getThingPos(cid), 10)
            doTeleportThing(cid, pos_errada)
            doSendMagicEffect(getThingPos(cid), 10)
            doPlayerSendCancel(cid,"Sorry not possible, you need to pull all the levers.")
            return true
        end
    end

    for id, pos in ipairs(alavancas) do
        local itemid = levers[id] == "d" and 1946 or 1945
        if getTileItemById(pos, itemid).uid > 100 then
        doSendMagicEffect(getThingPos(cid), 10)
        doTeleportThing(cid, pos_certa, true)
        doSendMagicEffect(getThingPos(cid), 10)
        end
    end
    return true
end
 
try this
Lua:
local pos_certa = {x = 33368, y = 32805, z = 14} -- Correct Position
local pos_errada = {x = 33399, y = 32801, z = 14} -- Wrong Position

local alavancas = {
    [1] = {x = 33320, y = 32682, z = 14},
    [2] = {x = 33349, y = 32680, z = 14},
    [3] = {x = 33358, y = 32701, z = 14},
    [4] = {x = 33338, y = 32702, z = 14},
    [5] = {x = 33305, y = 32734, z = 14},
    [6] = {x = 33357, y = 32749, z = 14},
    [7] = {x = 33368, y = 32763, z = 14},
    [8] = {x = 33382, y = 32786, z = 14},
}

local levers = { -- Initial state
    [1] = "d",
    [2] = "d",
    [3] = "d",
    [4] = "d",
    [5] = "d",
    [6] = "d",
    [7] = "d",
    [8] = "d",
}

local aux = {"d", "e"}

local function leverCheck()
    local count = 0
    for id, pos in ipairs(alavancas) do
        local itemid = levers[id] == "d" and 1946 or 1945
        if getTileItemById(pos, itemid).uid > 100 then
            count = count + 1
        end
    end
    return count == #levers
end

local t = {5*60*1000, 1000}

local function teleport(cid, bool)
    doTeleportThing(cid, bool and pos_certa or pos_errada, bool)
    doSendMagicEffect(getThingPos(cid), 10)
    if not bool then
        doPlayerSendCancel(cid,"Sorry not possible, you need to pull all the levers.")
    end
end

function onStepIn(cid, item, position, fromPosition)
    local check = leverCheck()
    doSendMagicEffect(getThingPos(cid), 10)
    addEvent(teleport, check and t[1] or t[2], cid, check)
    return true
end
 
Last edited:
try this
Lua:
local pos_certa = {x = 33368, y = 32805, z = 14} -- Correct Position
local pos_errada = {x = 33399, y = 32801, z = 14} -- Wrong Position

local alavancas = {
    [1] = {x = 33320, y = 32682, z = 14},
    [2] = {x = 33349, y = 32680, z = 14},
    [3] = {x = 33358, y = 32701, z = 14},
    [4] = {x = 33338, y = 32702, z = 14},
    [5] = {x = 33305, y = 32734, z = 14},
    [6] = {x = 33357, y = 32749, z = 14},
    [7] = {x = 33368, y = 32763, z = 14},
    [8] = {x = 33382, y = 32786, z = 14},
}

local levers = { -- Initial state
    [1] = "d",
    [2] = "d",
    [3] = "d",
    [4] = "d",
    [5] = "d",
    [6] = "d",
    [7] = "d",
    [8] = "d",
}

local aux = {"d", "e"}

local function leverCheck()
    local count = 0
    for id, pos in ipairs(alavancas) do
        local itemid = levers[id] == "d" and 1946 or 1945
        if getTileItemById(pos, itemid).uid > 100 then
            count = count + 1
        end
    end
    return count == #levers
end

local time = {5*60*1000, 1000}

local function teleport(cid, bool)
    doTeleportThing(cid, bool and pos_certa or pos_errada, bool)
    doSendMagicEffect(getThingPos(cid), 10)
    if not bool then
        doPlayerSendCancel(cid,"Sorry not possible, you need to pull all the levers.")
    end
end

function onStepIn(cid, item, position, fromPosition)
    local check = leverCheck()
    doSendMagicEffect(getThingPos(cid), 10)
    addEvent(teleport, check and t[1] or t[2], cid, check)
    return true
end

dont work bro :(
S0tWcyo.jpg

S0tWcyo.jpg
 
Back
Top Bottom