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

Help with Teleport Script

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
 
Example to remove whatever you whant from position:

PHP:
local teleportPos = {x=123, y=123, z=7, stackpos=1}
getTele = getThingFromPos(teleportPos)

if getTele.itemid == 1387 then
doRemoveItem(getTele.uid, 1)
end

Simple, you just need those functions!
 
I want to define the function doRemoveTeleport, so I put the script like this:

Code:
function doRemoveTeleport()
local teleportPos = {x=637, y=165, z=7, stackpos=1}
getTele = getThingFromPos(teleportPos)

	if getTele.itemid == 1387 then
		doRemoveItem(getTele.uid, 1) 
 		doSendMagicEffect(createPos, CONST_ME_POFF)

end
end

But this still doesn't make the teleport disappear =/
 
You need to addEvent to your function (onUse, onStepIn, etc)

Example:

PHP:
function onUse(cid, item, position)
addEvent(doRemoveTeleport, 5*1000)
end

function doRemoveTeleport()
local teleportPos = {x=637, y=165, z=7, stackpos=1}
getTele = getThingFromPos(teleportPos)
   if getTele.itemid == 1387 then
	doRemoveItem(getTele.uid, 1) 
 	doSendMagicEffect(createPos, CONST_ME_POFF)
    end
end

You really dont need to make a function in there... but is just an example, that script above will execute the function "doRemoveTeleport" when you use the function "onUse" and then after 5 sec the addEvent will be executed :D
 
Take a look at my script, it already has an addEvent, it still doesn't work somehow. The first teleport I make never disappears, however, the teleports I make after that disapear.
 
Back
Top