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

Lua Duplicate lever when timer ends

Kryzax

The cake is a lie
Joined
May 31, 2012
Messages
18
Reaction score
1
I made a script but it has a problem (always a problem..). After 5 seconds the timer puts the switch back to its original position but if theres a monster or person standing on the lever then it doesn't work. I think it's because of stackpos but I have no idea how to fix it! Here's the code:

Lua:
function onUse(cid, item, fromPos, item2, toPos)
    if getThingFromPos(firstwallpos1).itemid == 8861 and getThingFromPos(firstwallpos2).itemid == 8861 and getThingFromPos(firstwallpos3).itemid == 8861 and item.itemid == 1945 and item.uid == 1001 then --Lever1


doRemoveItem(getThingfromPos(firstwallpos1).uid, 1) -- RemoveWall
doRemoveItem(getThingfromPos(firstwallpos2).uid, 1) -- RemoveWall
doRemoveItem(getThingfromPos(firstwallpos3).uid, 1) -- RemoveWall
doTransformItem(item.uid,1946)
addEvent(onTimer, 10000)

end
        return true
end

function onTimer()
    doTransformItem(getThingFromPos({x=886, y=986, z=7, stackpos=1} ).uid, 1945)--lever pos
doCreateItem(8861,1,{x=901, y=990, z=7})-- Stone pos
doCreateItem(8861,1,{x=902, y=990, z=7})-- Stone pos
doCreateItem(8861,1,{x=903, y=990, z=7})-- Stone pos
end

Advice please!? Thanks
 
Hmm.. you can use "isCreature(cid)", and set stackpos value to 2.
Btw. its duplicating your lever or just doesn't work...?
Something happen after 5 sec, but in script you have "10000".. Its really hard to wrtie good post with all data?
 
Hmm.. you can use "isCreature(cid)", and set stackpos value to 2.
Btw. its duplicating your lever or just doesn't work...?
Something happen after 5 sec, but in script you have "10000".. Its really hard to wrtie good post with all data?

It creates a lever on top of the existing one. And I forgot I had changed it to 10 seconds. Doesn't change the problem though.
 
Okey, u can pass lever uid to function.

Code:
doTransformItem(item.uid,1946)
addEvent(onTimer, 10000, item.uid)

function onTimer(lever)
doTransformItem(lever, 1945)
 
Back
Top