local t = {
playerPositions = {
{x = 100, y = 200, z = 7},
{x = 100, y = 200, z = 7},
{x = 100, y = 200, z = 7},
{x = 100, y = 200, z = 7}
},
monstersPosition = {
{x = 100, y = 200, z = 7},
{x = 100, y = 200, z = 7},
{x = 100, y = 200, z = 7},
{x = 100, y = 200, z = 7}
},
teleportPos = {
{x = 100, y = 200, z = 7},
{x = 100, y = 200, z = 7},
{x = 100, y = 200, z = 7},
{x = 100, y = 200, z = 7}
}
}
local players, summonPos = {}, {}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 1945 or item.itemid == 1946 then
for _, player in ipairs(t.playerPositions) do
local c = getTopCreature(player).uid
if c > 0 and isPlayer(c) then table.insert(players, c) end
end
if #players == 4 then
for i, summon in ipairs(monstersPosition) do
summonPos[i] = summon
end
for i, v in ipairs(players) do
doSendMagicEffect(t.playerPositions[i], CONST_ME_POFF)
doTeleportThing(v, t.teleportPos[i], true)
doSendMagicEffect(t.teleportPos[i], CONST_ME_TELEPORT)
end
for _, s in ipairs(summonPos) do
doSummonCreature("Demon", s)
end
else
doPlayerSendDefaultCancel(player[1], RETURNVALUE_NOTPOSSIBLE)
end
end
return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end