Greetings everyone!
I was searching the forums for something like this but didn't quite find it so I attempted to make it myself (check http://otland.net/f132/help-adding-timer-event-into-lua-action-20914/).
With the help and suggestions of StreamSide, xxgoosexx, Pitufo and Colandus I managed to modify the script to do as intended:
When you hit the lever on the right (of course you'd have to assign it a uniqueID in your map aswell as inserting a line for it in actions.xml) a teleport will appear and the pink stone will disappear. You will not be able to use the lever again, however after 20 seconds it will flip itself back making the teleport vanish and the pink stone re-appear!
The code (tested with TFS 0.3beta3) is as thus:
Remember to change the coordinates according to your map aswell as the itemID's (incase you are not using a pink stone or use a different lever etc).
Have fun!
I was searching the forums for something like this but didn't quite find it so I attempted to make it myself (check http://otland.net/f132/help-adding-timer-event-into-lua-action-20914/).
With the help and suggestions of StreamSide, xxgoosexx, Pitufo and Colandus I managed to modify the script to do as intended:
When you hit the lever on the right (of course you'd have to assign it a uniqueID in your map aswell as inserting a line for it in actions.xml) a teleport will appear and the pink stone will disappear. You will not be able to use the lever again, however after 20 seconds it will flip itself back making the teleport vanish and the pink stone re-appear!
The code (tested with TFS 0.3beta3) is as thus:
PHP:
local pinkstonepos1 = {x=634, y=664, z=13} -- Remember to
local TeleportToPos = { x = 645, y = 660, z = 12} -- adjust the
local TeleportInPos = { x = 636, y = 662, z = 13} -- coordinates here
local LeverPos = { x = 647, y = 663, z = 13} -- to your map :)
local timeToRemove = 20 -- in seconds
function onUse(cid, item, frompos, item2, topos)
local pinkstone1 = getTileItemById(pinkstonepos1, 1355) -- If you do not want a pink stone, change this itemID to whatever itemID you want to use
local teleport = getTileItemById(TeleportInPos, 1387)
if item.itemid == 1945 then
doRemoveItem(pinkstone1.uid, 1)
doCreateTeleport(1387, TeleportToPos, TeleportInPos)
doSendMagicEffect(TeleportInPos, CONST_ME_TELEPORT)
doPlayerSendTextMessage(cid,22,"Click!")
addEvent(doRemoveTeleport, timeToRemove * 1000)
else if item.itemid == 1946 then
doPlayerSendCancel(cid,"Sorry, not possible.")
return 1
end
end
end
function doRemoveTeleport()
local teleport = getTileItemById(TeleportInPos, 1387)
local Lever = getTileItemById(LeverPos, 1946)
if teleport.uid > 0 then
doCreateItem(1355, 1, pinkstonepos1)
doRemoveItem(teleport.uid)
doSendMagicEffect(TeleportInPos, CONST_ME_POFF)
doTransformItem(Lever.uid, 1945)
end
end
Remember to change the coordinates according to your map aswell as the itemID's (incase you are not using a pink stone or use a different lever etc).
Have fun!