function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 1946 then
return false
end
local p = {getThingFromPos(ma_config.fromPos[1]).uid, getThingFromPos(ma_config.fromPos[2]).uid}
if not(isInArray(p, cid)) then
return true
end
if not(p[1] > 0 and p[2] > 0) then
return doPlayerSendCancel(cid, "You need an other player for this game.")
end
local monsters, players = areaCreatures(ma_config.area)
if #players > 0 then
return arraySendCancel(p, "The arena is currently in use.")
elseif #monsters > 0 then
for _, mid in pairs(monsters) do
doRemoveThing(mid)
end
end
doRemoveFieldsInArea(ma_config.area)
for i = 1, 2 do
doSendMagicEffect(getThingPos(p[i]), CONST_ME_POFF)
doTeleportThing(p[i], ma_config.toPos[i])
doSendMagicEffect(getThingPos(p[i]), CONST_ME_TELEPORT)
local summon = doCreateMonster(ma_config.monsters[math.random(#ma_config.monsters)], getPositionByDirection(ma_config.toPos[i], ma_config.spawnDir[_], 1))
doConvinceCreature(p[i], summon, true)
registerCreatureEvent(summon, "MonsterArenaDeath")
end
return false
end