It work 100%
-- rewritten by QuaS~
--Unique ids used;
--Id of main lever = 8080
local tpid = 1387 --id of the teleporter that will be created.
local tppos = {x=1000,y=1000,z=7,stackpos=1} -- place where the teleporter with id =1387 will be created in.
local tpto = {x=1000,y=1000,z=7} --place where player will be teleported to when he enter the tp.
local timee = 10 -- time to remove portal in seconds
local levers = {
[1] = {id = 1946, pos = {x=1000, y=1000, z=7, stackpos=1}}, --Position of First Lever.
[2] = {id = 1946, pos = {x=1000, y=1000, z=7, stackpos=1}}, --Position of Second Lever.
[3] = {id = 1945, pos = {x=1000, y=1000, z=7, stackpos=1}},--Position of Third Lever.
[4] = {id = 1945, pos = {x=1000, y=1000, z=7, stackpos=1}}, --Position of Fourth Lever.
[5] = {id = 1946, pos = {x=1000, y=1000, z=7, stackpos=1}}, --Position of Fifth Lever.
[6] = {id = 1946, pos = {x=1000, y=1000, z=7, stackpos=1}}, --Position of Sixth Lever
[7] = {id = 1946, pos = {x=1000, y=1000, z=7, stackpos=1}} -- MAIN
}
function removePortal_levers() -- changed name to prevent to use this function in another script due popular name.
if getTileItemById(tppos, tpid).itemid > 0 then
doRemoveItem(getTileItemById(tppos, tpid).uid,1)
end
for i=1,#levers do
if getTileItemById(levers.pos,1946).itemid > 0 then
doTransformItem(getTileItemById(levers.pos,1946).uid,1945)
end
end
return TRUE
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local doit = true
for i = 1,6 do
if doit then
if getTileItemById(levers.pos,levers.id).itemid > 0 then
doit = true
else
doit = false
end
else
break
end
end
if item.uid == 8080 then
if item.itemid == 1945 then
if doit then
doCreateTeleport(tpid, tpto, tppos)
doPlayerSendTextMessage(cid,22,"A portal is created and will be removed in "..timee.." sec.")
addEvent(removePortal_levers,(timee*1000))
doTransformItem(item.uid,item.itemid+1)
else
doPlayerSendTextMessage(cid,22,"Levers have to be in correct configuration to open a portal.")
end
elseif item.itemid == 1946 then
doPlayerSendTextMessage(cid,22,"You can not stop running proccess.")
end
end
return TRUE
end
Last edited: