Hi, I have a simple switch which creates/removes the walls. I want to add a delay for both, removing and creating the walls, but it only works if there is a delay for createWall2 function. if I add a removeWall2 function and use addEvent, it never removes the walls and multiple walls are created on top of the previous ones:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
wall_pos1 = {x=1496, y=1488, z=5, stackpos=1}
wall_pos2 = {x=1497, y=1488, z=5, stackpos=1}
wall1 = getThingfromPos(wall_pos1)
wall2 = getThingfromPos(wall_pos2)
if item.itemid == 1945 then
addEvent(createWall2, 1 * 1000)
doTransformItem(item.uid, 1946)
elseif item.itemid == 1946 and wall1.itemid == 1052 and wall2.itemid == 1052 then
addEvent(removeWall2, 1 * 1000)
doTransformItem(item.uid, 1945)
else
doPlayerSendCancel(cid,"Sorry, not possible.")
end
return TRUE
end
function createWall2()
doCreateItem(1052, wall_pos1)
doSendMagicEffect(wall_pos1, 10)
doCreateItem(1052, wall_pos2)
doSendMagicEffect(wall_pos2, 10)
end
function removeWall2()
doSendMagicEffect(wall_pos1, 10)
doRemoveItem(wall1.uid, 1)
doSendMagicEffect(wall_pos2, 10)
doRemoveItem(wall2.uid, 1)
end
function removeWall2()