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

Lever with timer and reset script?

endziu2222

Active Member
Joined
Nov 2, 2010
Messages
167
Solutions
1
Reaction score
44
I have this script for use lever to remove rock from location but I would like it to have an extra function which is a timer.

So when you use lever it will remove rock and you receive information for example: You have 30 second before teleport disappears and after 30 seconds you have to go back and open it again.

Any help appreciated

VERSION_OTX_REVSCRIPTS

Lua:
local lever = Action()

function lever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local teleportPosition = {x = 1924, y = 1989, z = 13}
    local stonePosition = {x = 1924, y = 1987, z = 13}

    if item.itemid == 2772 then
        local teleport = Game.createItem(1949, 1, teleportPosition)
        if teleport then
            teleport:setDestination({x = 1920, y = 2007, z = 14})
            Position(teleportPosition):sendMagicEffect(CONST_ME_TELEPORT)
        end

        Tile(stonePosition):getItemById(6289):remove()
        item:transform(2773)
    elseif item.itemid == 2773 then
        Position(stonePosition):hasCreature({x = 1924, y = 1987, z = 113})
        Tile(teleportPosition):getItemById(1949):remove()
        Position(teleportPosition):sendMagicEffect(CONST_ME_POFF)
        Game.createItem(6289, 1, stonePosition)
        item:transform(2772)
    end
    return true
end

lever:uid(20007)
lever:register()
 
Solution
It does work, thank you.
Post automatically merged:


I know you have helped me bro but I am going to be a bit cheeky XD You think there is an option to change this so for example:
after clicking lever you get teleported and your outfit changes? If you can't be asked I will understand. Thanks for help
not tested.. it should work for you..

Lua:
local teleportTimer = 30
local outfitCondition = Condition(CONDITION_OUTFIT)
outfitCondition:setOutfit({lookType = 50}) -- Sets the Outfit ID
outfitCondition:setTicks(10 * 1000) -- Sets the time in milliseconds for the appearance condition (10 seconds).

local lever = Action()

function lever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local teleportPosition = {x = 1924, y =...
Lua:
local teleportTimer = 30

local lever = Action()

function lever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local teleportPosition = {x = 1924, y = 1989, z = 13}
    local stonePosition = {x = 1924, y = 1987, z = 13}

    if item.itemid == 2772 then
        local teleport = Game.createItem(1949, 1, teleportPosition)
        if teleport then
            teleport:setDestination({x = 1920, y = 2007, z = 14})
            Position(teleportPosition):sendMagicEffect(CONST_ME_TELEPORT)
        end

        Tile(stonePosition):getItemById(6289):remove()
        item:transform(2773)


        player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have " .. teleportTimer .. " seconds before the teleport disappears.")
        addEvent(function()

            Tile(teleportPosition):getItemById(1949):remove()
            Position(teleportPosition):sendMagicEffect(CONST_ME_POFF)
            Game.createItem(6289, 1, stonePosition)
            item:transform(2772)
        end, teleportTimer * 1000)
    elseif item.itemid == 2773 then
        Position(stonePosition):hasCreature({x = 1924, y = 1987, z = 113})
        Tile(teleportPosition):getItemById(1949):remove()
        Position(teleportPosition):sendMagicEffect(CONST_ME_POFF)
        Game.createItem(6289, 1, stonePosition)
        item:transform(2772)

      
        stopEvent(teleportTimer * 1000)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You came back before the teleport disappeared.")
    end
    return true
end

lever:uid(20007)
lever:register()
 
It does work, thank you.
Post automatically merged:

Lua:
local teleportTimer = 30

local lever = Action()

function lever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local teleportPosition = {x = 1924, y = 1989, z = 13}
    local stonePosition = {x = 1924, y = 1987, z = 13}

    if item.itemid == 2772 then
        local teleport = Game.createItem(1949, 1, teleportPosition)
        if teleport then
            teleport:setDestination({x = 1920, y = 2007, z = 14})
            Position(teleportPosition):sendMagicEffect(CONST_ME_TELEPORT)
        end

        Tile(stonePosition):getItemById(6289):remove()
        item:transform(2773)


        player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have " .. teleportTimer .. " seconds before the teleport disappears.")
        addEvent(function()

            Tile(teleportPosition):getItemById(1949):remove()
            Position(teleportPosition):sendMagicEffect(CONST_ME_POFF)
            Game.createItem(6289, 1, stonePosition)
            item:transform(2772)
        end, teleportTimer * 1000)
    elseif item.itemid == 2773 then
        Position(stonePosition):hasCreature({x = 1924, y = 1987, z = 113})
        Tile(teleportPosition):getItemById(1949):remove()
        Position(teleportPosition):sendMagicEffect(CONST_ME_POFF)
        Game.createItem(6289, 1, stonePosition)
        item:transform(2772)

    
        stopEvent(teleportTimer * 1000)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You came back before the teleport disappeared.")
    end
    return true
end

lever:uid(20007)
lever:register()
I know you have helped me bro but I am going to be a bit cheeky XD You think there is an option to change this so for example:
after clicking lever you get teleported and your outfit changes? If you can't be asked I will understand. Thanks for help
 
Last edited:
It does work, thank you.
Post automatically merged:


I know you have helped me bro but I am going to be a bit cheeky XD You think there is an option to change this so for example:
after clicking lever you get teleported and your outfit changes? If you can't be asked I will understand. Thanks for help
Lua:
player:teleportTo(Position(1000, 1000, 7)
Lua:
player:setOutfit({lookType = 113})
 
View attachment 78487
Is there a way to change looktype back to normal after using second lever?

Lua:
local condition = Condition(CONDITION_OUTFIT)
condition:setTicks(5000) -- 5000 means 5 secs.
condition:setOutfit(outfit) -- Outfit ID

player:addCondition(condition)

Let us know if u cant do it by urself!
 
Last edited:
It does work, thank you.
Post automatically merged:


I know you have helped me bro but I am going to be a bit cheeky XD You think there is an option to change this so for example:
after clicking lever you get teleported and your outfit changes? If you can't be asked I will understand. Thanks for help
not tested.. it should work for you..

Lua:
local teleportTimer = 30
local outfitCondition = Condition(CONDITION_OUTFIT)
outfitCondition:setOutfit({lookType = 50}) -- Sets the Outfit ID
outfitCondition:setTicks(10 * 1000) -- Sets the time in milliseconds for the appearance condition (10 seconds).

local lever = Action()

function lever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local teleportPosition = {x = 1924, y = 1989, z = 13}
    local stonePosition = {x = 1924, y = 1987, z = 13}

    if item.itemid == 2772 then
        local teleport = Game.createItem(1949, 1, teleportPosition)
        if teleport then
            teleport:setDestination({x = 1920, y = 2007, z = 14})
            Position(teleportPosition):sendMagicEffect(CONST_ME_TELEPORT)
        end

        Tile(stonePosition):getItemById(6289):remove()
        item:transform(2773)


        player:addCondition(outfitCondition)

        player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have " .. teleportTimer .. " seconds before the teleport disappears.")
        addEvent(function()
            player:removeCondition(CONDITION_OUTFIT, CONDITIONID_DEFAULT, {lookType = 50})
            Tile(teleportPosition):getItemById(1949):remove()
            Position(teleportPosition):sendMagicEffect(CONST_ME_POFF)
            Game.createItem(6289, 1, stonePosition)
            item:transform(2772)
        end, teleportTimer * 1000)
    elseif item.itemid == 2773 then
        Position(stonePosition):hasCreature({x = 1924, y = 1987, z = 113})
        Tile(teleportPosition):getItemById(1949):remove()
        Position(teleportPosition):sendMagicEffect(CONST_ME_POFF)
        Game.createItem(6289, 1, stonePosition)
        item:transform(2772)

        player:removeCondition(CONDITION_OUTFIT, CONDITIONID_DEFAULT, {lookType = 50})

        stopEvent(teleportTimer * 1000)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You came back before the teleport disappeared.")
    end
    return true
end

lever:uid(20007)
lever:register()
 
Last edited:
Solution
not tested.. it should work for you..

Lua:
local teleportTimer = 30
local outfitCondition = Condition(CONDITION_OUTFIT)
outfitCondition:setOutfit({lookType = 50}) -- Sets the Outfit ID
outfitCondition:setTicks(10 * 1000) -- Sets the time in milliseconds for the appearance condition (10 seconds).

local lever = Action()

function lever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local teleportPosition = {x = 1924, y = 1989, z = 13}
    local stonePosition = {x = 1924, y = 1987, z = 13}

    if item.itemid == 2772 then
        local teleport = Game.createItem(1949, 1, teleportPosition)
        if teleport then
            teleport:setDestination({x = 1920, y = 2007, z = 14})
            Position(teleportPosition):sendMagicEffect(CONST_ME_TELEPORT)
        end

        Tile(stonePosition):getItemById(6289):remove()
        item:transform(2773)


        player:addCondition(outfitCondition)

        player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have " .. teleportTimer .. " seconds before the teleport disappears.")
        addEvent(function()
            player:removeCondition(CONDITION_OUTFIT, CONDITIONID_DEFAULT, {lookType = 50})
            Tile(teleportPosition):getItemById(1949):remove()
            Position(teleportPosition):sendMagicEffect(CONST_ME_POFF)
            Game.createItem(6289, 1, stonePosition)
            item:transform(2772)
        end, teleportTimer * 1000)
    elseif item.itemid == 2773 then
        Position(stonePosition):hasCreature({x = 1924, y = 1987, z = 113})
        Tile(teleportPosition):getItemById(1949):remove()
        Position(teleportPosition):sendMagicEffect(CONST_ME_POFF)
        Game.createItem(6289, 1, stonePosition)
        item:transform(2772)

        player:removeCondition(CONDITION_OUTFIT, CONDITIONID_DEFAULT, {lookType = 50})

        stopEvent(teleportTimer * 1000)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You came back before the teleport disappeared.")
    end
    return true
end

lever:uid(20007)
lever:register()
You're legendary, thank you
 
Back
Top