na verdade n precisa nem atribuir storage, a função da anihi no caso para esse codigo, está errada... use assim:
local config = {
from = {x = 22987, y = 19805, z = 7}, -- coordenada do canto superior esquerdo da área.
to = {x = 23024, y = 19992, z = 7}, -- coordenada do canto inferior direito da área.
}
local t = {
lvl = 100,
Time = 2, -- em minutos
entrada =
{
{x = 23052, y = 19991, z = 7}, -- pos players
{x = 23051, y = 19991, z = 7},
{x = 23050, y = 19991, z = 7},
{x = 23049, y = 19991, z = 7}
},
saida =
{
{x = 23017, y = 19985, z = 7}, -- pos para onde eles irão
{x = 23019, y = 19985, z = 7},
{x = 23017, y = 19987, z = 7},
{x = 23019, y = 19987, z = 7}
},
monstros =
{
{{x = 23004, y = 19832, z = 7}, "Juggernaut"}, -- defina pos dos montros e nomes
{{x = 23004, y = 19834, z = 7}, "Ghazbaran"}
}
}
local function getPlayersInArea(fromPos, toPos)
local players = {}
for _, pid in ipairs(getPlayersOnline()) do
if isInRange(getPlayerPosition(pid), fromPos, toPos) then
table.insert(players, pid)
end
end
return players
end
local function VarAnihiPlayer(cid)
if not isCreature(cid) then return LUA_ERROR end
if isInRange(getPlayerPosition(cid), config.from, config.to) then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local check = {}
if #getPlayersInArea(config.from, config.to) > 0 then
doPlayerSendCancel(cid, 'Aguarde, tem jogadores fazendo a quest.') return true
end
for _, k in ipairs(t.entrada) do
local x = getTopCreature(k).uid
if(x == 0 or not isPlayer(x) or getPlayerLevel(x) < t.lvl) then
doPlayerSendCancel(cid, 'Está faltando player ou alguém não possui level '..t.lvl..' ou mais.') return true
end
table.insert(check, x)
end
for _, summon in pairs(t.monstros) do
local creature = getTopCreature(summon[1]).uid
if(creature > 0 and not isPlayer(creature)) then
doRemoveCreature(creature)
end
doCleanTile(summon[1])
doCreateMonster(summon[2], summon[1])
end
for i, tid in ipairs(check) do
doSendMagicEffect(t.entrada[i], CONST_ME_POFF)
doTeleportThing(tid, t.saida[i], false)
addEvent(VarAnihiPlayer, t.Time*60*1000, tid)
doSendMagicEffect(t.saida[i], CONST_ME_ENERGYAREA)
end
doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
return true
end