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

add delay lever

popitox

Member
Joined
Jul 8, 2008
Messages
63
Reaction score
8
i need a hand with a script that im trying to use, its working at 100%, the only thing i want is to know how to add a delay to use it again.
thank you so much <3
Lua:
local doorPos = {x=, y=, z=}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1946 then
        local v = getTileItemById(doorPos, 1219)
        if v.itemid == 1219 then
            doRelocate(doorPos, {x=doorPos.x+1, y=doorPos.y, z=doorPos.z})
            doTransformItem(v.uid, 1220)
        end
    else
        local v = getTileItemByType(doorPos, ITEM_TYPE_DOOR)
        if v.itemid == 1219 or v.itemid == 1220 then
            doTransformItem(v.uid, 1219)
        end
    end
    return doTransformItem(item.uid, item.itemid == 1946 and 1945 or 1946)
end
 
Last edited by a moderator:
Code:
local openDoor = 1220
local closedDoor = 1219

local doorPos = {x = 1000, y = 1000, z = 7}

local globalStorage = 15455

local waitTime = 5 -- 5 seconds

function onUse(cid, item, fromPosition, itemEx, toPosition)

if globalStorage == 1 then
    return doPlayerSendCancel("You must wait to use the lever again.")
end

if item.itemid == 1946 then
    local DOOR = getTileItemById(doorPos, closedDoor)
        if DOOR.itemid == closedDoor then
            doRelocate(doorPos, {x=doorPos.x+1, y=doorPos.y, z=doorPos.z})
            doTransformItem(DOOR.uid, openDoor)
            setGlobalStorageValue(globalStorage, 1)
            addEvent(resetLever, timeToWait, * 1000)
    end
else
    local DOOR = getTileItemByType(doorPos, ITEM_TYPE_DOOR)
        if DOOR.itemid == closedDoor or DOOR.itemid == openDoor then
            doTransformItem(DOOR.uid, closedDoor)
            setGlobalStorageValue(globalStorage, 1)
            addEvent(resetLever, timeToWait * 1000)
        end
end
return doTransformItem(item.uid, item.itemid == 1946 and 1945 or 1946)
end

function resetLever()
    setGlobalStorageValue(globalStorage, 0)
return true
end
 
Last edited:
Back
Top