So im trying to add an addevent in onUse function. But it doesnt work 
Do someone have any idea why? I will paste script here:
Do someone have any idea why? I will paste script here:
Code:
local config = {
normalLever = 1945,
pulledLever = 1946,
leverUid = 1200,
messageRemoved = "A stone is removed in the distance!",
messagePlaced = "The stone is placed back!",
stonePos = {x=224, y=354, z=5, stackpos=1},
stoneID = 1358,
delay = 1
}
function onUse(cid, item, fromPos, itemEx, toPos)
stone = getThingfromPos(config.stonePos)
if item.itemid == config.normalLever and item.uid == config.leverUid then
doRemoveItem(stone.uid, 1)
doTransformItem(item.uid, config.pulledLever)
doPlayerSendTextMessage(cid, 22, config.messageRemoved)
addEvent(placeStone, item, cid, config.delay * 5000)
end
return true
end
function mapAreas(fromPos, toPos, stack)
local myTable = {}
for _x = fromPos.x, toPos.x do
for _y = fromPos.y, toPos.y do
local thing = getThingFromPos({x = _x, y = _y, z = fromPos.z, stackpos = stack})
if isPlayer(thing.uid) then
table.insert(myTable, thing.uid)
end
end
end
return #myTable > 0 and myTable or nil
end
function placeStone(placeStone, item, cid)
local fromPos = stonePos
local toPos = stonePos
local thing = mapAreas(fromPos, toPos, 253)
if thing then
local pos = getPlayerPosition(cid)
doTeleportThing(cid, {x=pos.x, y=pos.y-1, z=pos.z})
doCreateItem(config.stoneID, 1, config.stonePos)
doPlayerSendTextMessage(cid, 22, config.messagePlaced)
else
doCreateItem(config.stoneID, 1, config.stonePos)
doPlayerSendTextMessage(cid, 22, config.messagePlaced)
end
return true
end
Last edited by a moderator: