local lvl = 400
local stor_time = 787687
local hours = 24
local pos_die = {x=1429, y=1549, z=9}
local t = {
{vocations = {1, 13},Pos = {{x=1397, y=1505, z=9},{x=1429, y=1549, z=9}},item= {2349,{x=1398, y=1502, z=9}}}, -- TANK OR DRUNK
{vocations = {14, 15},Pos = {{x=1396, y=1505, z=9},{x=1429, y=1549, z=9}},item= {2349,{x=1398, y=1508, z=9}}}, -- ATTACK OR DRUNK
{vocations = {16, 17},Pos = {{x=1395, y=1505, z=9},{x=1429, y=1549, z=9}},item= {2349,{x=1393, y=1508, z=9}}}, -- SUPPORT OR DRUNK
{vocations = {18, 19},Pos = {{x=1394, y=1505, z=9},{x=1429, y=1549, z=9}},item= {2349,{x=1393, y=1502, z=9}}}, -- PARALYZE OR DRUNK
{vocations = {18, 19},Pos = {{x=1394, y=1505, z=9},{x=1429, y=1549, z=9}},item= {2349,{x=1393, y=1502, z=9}}}, -- PARALYZE
{vocations = {18, 19},Pos = {{x=1394, y=1505, z=9},{x=1429, y=1549, z=9}},item= {2349,{x=1393, y=1502, z=9}}} -- SUPPORT
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local check = {}
local items = {}
for _, k in ipairs(t) do
local x = getTopCreature(k.Pos[1]).uid
local v = getTileItemById(k.item[2], k.item[1])
if x == 0 or not isPlayer(x) or getPlayerLevel(x) < lvl or isInArray(k.vocations, getPlayerVocation(x)) == FALSE or getPlayerStorageValue(x, stor_time) - os.time() > 0 then
doPlayerSendCancel(cid, 'Está faltando player ou alguém não possui level '..lvl..' ou mais ou não tem a vocação ou so pode participar 1x no dia.') return true
elseif v.uid == 0 then
doPlayerSendCancel(cid, "Todos os itens precisão estar na posição.") return true end
table.insert(check, x)
table.insert(items, v)
end
local sort = check[math.random(1, #check)]
for k, tid in ipairs(check) do
doSendMagicEffect(getCreaturePosition(tid), CONST_ME_POFF)
if tid ~= sort then
doTeleportThing(tid, t[k].Pos[2])
else
doTeleportThing(tid, pos_die)
end
doSendMagicEffect(getCreaturePosition(tid), CONST_ME_TELEPORT)
setPlayerStorageValue(tid, stor_time, os.time()+hours*3600)
end
for _, remove in ipairs(items) do
doRemoveItem(remove.uid)
end
doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
return true
end