konceptz
New Member
- Joined
- Apr 8, 2009
- Messages
- 17
- Reaction score
- 0
I'm trying to make the teleport disappear after I create it, however, it's not disappearing. I have another similar script like this for another quest, so I think it has something to do with the add event.
Code:
function onUse(cid, item, frompos, item2, topos)
-- CONFIG --
idItem = 2159 --Item id required in coal basin
itemPos = {x=635, y=166, z=7, stackpos=1} --Item position in coal basin
getItemPos = getThingfromPos(itemPos)
toPos = {x=636, y=159, z=7} --Teleport player position
createPos = {x=637, y=165, z=7} --Teleport create position
getTeleport = getThingFromPos(createPos) --Teleport create position
local timeToRemove = 5 --in seconds
-- CONFIG END --
if item.itemid == 1945 and getItemPos.itemid == idItem then
doSendMagicEffect(itemPos,6)
doSendMagicEffect(frompos,6)
doCreateTeleport(1387, toPos, createPos)
doRemoveItem(getItemPos.uid,1)
doTransformItem(item.uid,item.itemid+1)
doPlayerSendTextMessage(cid,22,"Click!")
addEvent(doRemoveTeleport, timeToRemove * 1000)
elseif item.itemid == 1946 then
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry, not possible.")
return 1
end
function doRemoveTeleport()
local teleport = getTileItemById(createPos, 1387)
if teleport.uid >= 0 then
doRemoveItem(teleport.uid)
doSendMagicEffect(createPos, CONST_ME_POFF)
end
end
end