Hello again... I need help with this script ... this script that i have just done should remove and create 6 doors specified in the positions, but only it removes and create one of them, why this happens?
Here is the script...
Look the image =d!
Help! =)
Here is the script...
Code:
[COLOR="Blue"]function onThink(interval, lastExecution)
local config = {
timeToClose = 5,
doorId = 9485,
doorPositions = {
{ x = 408, y = 445, z = 11, stackpos = 1 },
{ x = 409, y = 445, z = 11, stackpos = 1 },
{ x = 410, y = 445, z = 11, stackpos = 1 },
{ x = 411, y = 445, z = 11, stackpos = 1 },
{ x = 412, y = 445, z = 11, stackpos = 1 },
{ x = 413, y = 445, z = 11, stackpos = 1 }
}
}
for i = 1, table.maxn(config.doorPositions) do
local getDoors = getThingfromPos(config.doorPositions[i])
if getDoors.itemid == config.doorId then
doRemoveItem(getDoors.uid,1)
doSendMagicEffect(config.doorPositions[i], CONST_ME_BLOCKHIT)
doBroadcastMessage("The doors of the vampire castle are opened!", MESSAGE_STATUS_CONSOLE_ORANGE)
addEvent(closeCastle, (1000*config.timeToClose))
return TRUE
end
end
end
function closeCastle()
local doorId = 9485
local doorPositions = {
{ x = 408, y = 445, z = 11, stackpos = 1 },
{ x = 409, y = 445, z = 11, stackpos = 1 },
{ x = 410, y = 445, z = 11, stackpos = 1 },
{ x = 411, y = 445, z = 11, stackpos = 1 },
{ x = 412, y = 445, z = 11, stackpos = 1 },
{ x = 413, y = 445, z = 11, stackpos = 1 }
}
for k = 1, table.maxn(doorPositions) do
local getDoors = getThingfromPos(doorPositions[k])
if getDoors.itemid == 0 then
doCreateItem(doorId,1,doorPositions[k])
doBroadcastMessage("The doors of the vampire castle are closed!", MESSAGE_STATUS_CONSOLE_ORANGE)
return TRUE
end
end
end[/COLOR]
Look the image =d!
Help! =)