local function doTransformBack(Position, itemid, transformid)
return doTransformItem(getTileItemById(Position, transformid).uid, itemid)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if itemEx.itemid ~= 1945 and item.actionid ~= 65535 then
return false
end
doSendMagicEffect(toPosition,CONST_ME_ICEAREA)
doTargetCombatHealth(0, cid, COMBAT_ICEDAMAGE, -500, -1000, CONST_ME_ICEAREA)
addEvent(doTransformBack, 1*60*1000, toPosition, itemEx.itemid, 7021)
doTransformItem(itemEx.uid, 7021)
function doSomething(time_, t, itemid, effect)
addEvent(doTransformBack, time_, {x = t[1], y = t[2], z = t[3]}, itemid[2], itemid[1])
if effect then
doSendMagicEffect({x = t[1], y = t[2], z = t[3]}, CONST_ME_ICEAREA)
end
doTransformItem(getTileItemById({x = t[1], y = t[2], z = t[3]}, itemid[1]).uid, itemid[2])
end
function executeFunction(t, itemid, effect)
for k, v in ipairs(t) do
doSomething((k * 1000), v, itemid, effect)
end
end
--stairs at end
local table1 = {
[1] = {774, 1014, 7},
[2] = {774, 1015, 7},
[3] = {773, 1014, 7},
[4] = {773, 1015, 7}
}
--[[
Explanation of the functions:
addEvent is called and put on the waiting list so to speak, for 1 minute it patiently waits to call executeFunction
executeFunction then cycles through the 1st argument (e.g. table1) passing the index of the 1st argument (e.g. {774, 1014, 7})
to doSomething as its 2nd argument, the 2nd argument of executeFunction is then also passed to doSomething as its 3rd argument
since doSomething also uses an addEvent to execute its internal function we use the index value ( k ) of executeFunction's 1st argument
and multiply it by 1000 to tell addEvent we would like this function to execute at 1 second times the value of k for the amount of
elements in the table
The 3rd argument of executeFunction and 4th of doSomething will execute the magic effect, if ommited or set to false it will
not add a magic effect
Explanation of the indexes:
I explicitly use numerical indexes and ipairs for the for loop incase each coordinate needed to execute in that order
If execution of each coordinate doesn't matter you don't need to include the index and ipairs will do its thing regardless,
as long as the index of each element of the table is a non-text based index.. if you don't know what this means don't worry :)
--]]
addEvent(executeFunction, 60*1000, table1, {1388, 6909}, true)
--first dirt after stairs
local table2 = {
[1] = {745, 1012, 7},
[2] = {745, 1011, 7},
[3] = {745, 1013, 7},
[4] = {746, 1011, 7},
[5] = {746, 1012, 7},
[6] = {746, 1013, 7},
[7] = {746, 1014, 7},
[8] = {747, 1013, 7},
[9] = {747, 1012, 7},
[10] = {748, 1012, 7}
}
addEvent(executeFunction, 60*1000, table2, {103, 671}, true)
--second dirt after stairs
local table3 = {
[1] = {748, 1013, 7},
[2] = {748, 1014, 7},
[3] = {749, 1014, 7},
[4] = {749, 1013, 7},
[5] = {747, 1012, 7},
[6] = {749, 1012, 7},
[7] = {750, 1012, 7},
[8] = {750, 1013, 7},
[9] = {750, 1014, 7}
}
addEvent(executeFunction, 60*1000, table3, {103, 671}, true)
end