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

[8.6] Lever that removes an item and has a timer.

Ranyo13

ManCausingMayhem
Joined
Aug 22, 2009
Messages
981
Reaction score
38
Hey there,

I came up with a script made by me but I snatched out the "Event Timer" from a very old script made by Cykotitan. I hope the script will come in handy to any of you.

The script does the following:
  • You right click a lever. (Default ItemID: 1945)
  • The player gets a message informing him that something has happened.
  • An item of your choice present in a position of your choice disappears.
  • Sets a timer.
  • If the timer hasn't finished yet and the player clicks the lever, he/she gets a message saying "Please wait until the timer resets."
  • When timer is finished, the lever switches back to its normal ID.
  • The item is created again with a Magic Effect.
Here's what you need to do for the script to work:
1. Create in actions/other folder: leverwithtimer.lua
2. Copy and paste the script into it:
Code:
local function reset(p)
doTransformItem(getTileItemById(p, 1946).uid, 1945)
doCreateItem(387, 1, {x=989, y=998, z=7}) --Item's ID AND Position that you want to remove
doSendMagicEffect({x=989, y=998, z=7}, 34) --Item's Position and magic effect for the item that's going to be removed.
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid ==1946 then
doPlayerSendCancel(cid, "Please wait until the timer resets")
else if item.itemid == 1945 then
doRemoveItem (getTileItemById({x= 989, y=998, z=7}, 387).uid) --Same item's ID AND Position that you want to remove
doSendMagicEffect({x= 989, y=998, z=7}, 2)
doTransformItem(item.uid, 1946)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You hear a noise from the west.") --A message that the player gets informing him that something has happened.
addEvent(reset, 2 * 60 * 1000, toPosition) --Timer for the item to be created again.
else
stopEvent(event)
reset(toPosition)
end
end
return true
end
--Ranyo13
3. Goto actions.xml then copy and paste this anywhere between <actions> and </actions>:
Code:
    <action actionid="ID OF YOUR CHOICE" event="script" value="other/leverwithtimer.lua"/>
4. You're done!:)

Please note that this script has been tested on client version [8.6] only.
(TFS 0.3.6 CryingDamson V8)
Good luck!
 
Last edited:
elseif don't need end so one should be removed.

I don't see any use of it so i wont make for tfs 1.2 but i give you tabs and correct ends if you want ^^
Code:
local function reset(p)
    doTransformItem(getTileItemById(p, 1946).uid, 1945)
    doCreateItem(387, 1, {x=989, y=998, z=7}) --Item's ID AND Position that you want to remove
    doSendMagicEffect({x=989, y=998, z=7}, 34) --Item's Position and magic effect for the item that's going to be removed.
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
   
        if item.itemid == 1946 then
            doPlayerSendCancel(cid, "Please wait until the timer resets")
        elseif item.itemid == 1945 then
            doRemoveItem (getTileItemById({x= 989, y=998, z=7}, 387).uid) --Same item's ID AND Position that you want to remove
            doSendMagicEffect({x= 989, y=998, z=7}, 2)
            doTransformItem(item.uid, 1946)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You hear a noise from the west.") --A message that the player gets informing him that something has happened.
            addEvent(reset, 2 * 60 * 1000, toPosition) --Timer for the item to be created again.
        else
        stopEvent(event)
        reset(toPosition)
        end
    return true
end
--Ranyo13
 
elseif don't need end so one should be removed.

I don't see any use of it so i wont make for tfs 1.2 but i give you tabs and correct ends if you want ^^
Code:
local function reset(p)
    doTransformItem(getTileItemById(p, 1946).uid, 1945)
    doCreateItem(387, 1, {x=989, y=998, z=7}) --Item's ID AND Position that you want to remove
    doSendMagicEffect({x=989, y=998, z=7}, 34) --Item's Position and magic effect for the item that's going to be removed.
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
  
        if item.itemid == 1946 then
            doPlayerSendCancel(cid, "Please wait until the timer resets")
        elseif item.itemid == 1945 then
            doRemoveItem (getTileItemById({x= 989, y=998, z=7}, 387).uid) --Same item's ID AND Position that you want to remove
            doSendMagicEffect({x= 989, y=998, z=7}, 2)
            doTransformItem(item.uid, 1946)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You hear a noise from the west.") --A message that the player gets informing him that something has happened.
            addEvent(reset, 2 * 60 * 1000, toPosition) --Timer for the item to be created again.
        else
        stopEvent(event)
        reset(toPosition)
        end
    return true
end
--Ranyo13
Ty for your contribution.
 
Back
Top