local ACTIONID = 10100 local LEVERS_STORAGEID = 11000 local EVENT_STORAGEID = 11001 local STONE_ID = 1304 local STONE1_POS = {x = 458, y = 1386, z = 11} local STONE2_POS = {x = 459, y = 1386, z = 11} local CLOSE_DELAY = 15 * 60 * 1000 function close() local stone1 = getTileItemById(STONE1_POS, STONE_ID) local stone2 = getTileItemById(STONE2_POS, STONE_ID) if stone1.uid == 0 then doCreateItem(STONE_ID, 1, STONE1_POS) end if stone2.uid == 0 then doCreateItem(STONE_ID, 1, STONE2_POS) end setGlobalStorageValue(LEVERS_STORAGEID, 0) setGlobalStorageValue(EVENT_STORAGEID, 0) end function onUse(cid, item, frompos, item2, topos) if item.actionid ~= ACTIONID then return 0 end local stone1 = getTileItemById(STONE1_POS, STONE_ID) local stone2 = getTileItemById(STONE2_POS, STONE_ID) local levers = getGlobalStorageValue(LEVERS_STORAGEID) local eventid = getGlobalStorageValue(EVENT_STORAGEID) if levers < 16 then levers = levers + 1 setGlobalStorageValue(LEVERS_STORAGEID, levers) end if levers == 8 then doRemoveItem(stone1.uid, 1) if eventid ~= 0 then stopEvent(eventid) end eventid = addEvent(close, CLOSE_DELAY) setGlobalStorageValue(EVENT_STORAGEID, eventid) elseif levers == 16 then doRemoveItem(stone2.uid, 1) if eventid ~= 0 then stopEvent(eventid) end eventid = addEvent(close, CLOSE_DELAY) setGlobalStorageValue(EVENT_STORAGEID, eventid) end if item.itemid == 1945 then doTransformItem(item.uid, 1946) elseif item.itemid == 1946 then doTransformItem(item.uid, 1945) end addEvent(close, CLOSE_DELAY) end