local c = {
pos = {x = 220, y = 1479, z = 8},
itemid = 1304,
time = 900,
msg = "You have clicked the switch"
}
local function Remove(c)
doCreateItem(c.itemid, 1, c.pos)
doTransformItem(getTileItemById(c.fromPosition, 1946).uid, 1945)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
c.fromPosition = fromPosition
if item.itemid == 1945 then
doRemoveItem(getTileItemById(c.pos, c.itemid).uid)
addEvent(Remove, c.time * 1000, c)
doTransformItem(item.uid, 1946)
elseif item.itemid == 1946 then
if getTileItemById(c.pos, c.itemid).uid > 0 then
doTransformItem(item.uid, 1945)
else
doPlayerSendCancel(cid, "It seems the lever has been already used.")
end
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, c.msg)
return true
end