--config--
local positions = {
red = {
{x=XXX,y=YYY,z=Z},
{x=XXX,y=YYY,z=Z},
{x=XXX,y=YYY,z=Z}
},
-----------------
blue = {
{x=XXX,y=YYY,z=Z},
{x=XXX,y=YYY,z=Z},
{x=XXX,y=YYY,z=Z}
}
}
local destinations = {
red = {
{x=XXX,y=YYY,z=Z},
{x=XXX,y=YYY,z=Z},
{x=XXX,y=YYY,z=Z}
},
-----------------
blue = {
{x=XXX,y=YYY,z=Z},
{x=XXX,y=YYY,z=Z},
{x=XXX,y=YYY,z=Z}
}
}
local vars = {
a = 0,
b = 0,
storages = {
red = 75633,
blue = 75634
}
}
--/config/--
function onUse(cid, item, fromPosition, itemEx, toPosition)
--loops--
for i = 1, #positions.red do
if getTopCreature(positions.red[i]).type == 1 and isPlayer(positions.red[i]) then
vars.a = vars.a + 1
else
if vars.a > 0 then
vars.a = vars.a - 1
end
end
end
for i = 1, #positions.blue do
if getTopCreature(positions.blue[i]).type == 1 and isPlayer(positions.blue[i]) then
vars.b = vars.b + 1
else
if vars.b > 0 then
vars.b = vars.b - 1
end
end
end
--/loops/--
--cancels--
total = vars.a + vars.b
if vars.a < 1 and vars.b < 1 then
return doPlayerSendCancel(cid, "There are no players")
end
if (vars.a < 1 and vars.b > 0) or (vars.a > 0 and vars.b < 1) then
return doPlayerSendCancel(cid, "There are no players in the " .. vars.a < 1 and "first" or "second" .. " team")
end
if isInArray(total,{1,3,5}) then
return doPlayerSendCancel(cid, "The players in both teams must be equal")
end
--/cancels/--
--script--
if isInArray(total,{2,4,6}) then
--red--
if vars.a == 1 then
if getTopCreature(positions.red[1]).type == 1 then
doTeleportThing(positions.red[1],destinations.red[1])
setPlayerStorageValue(positions.red[1], vars.storages.red, 1)
end
elseif vars.a == 2 then
for i = 1, 2 do
if getTopCreature(positions.red[i]).type == 1 then
doTeleportThing(positions.red[i], destinations.red[i])
setPlayerStorageValue(positions.red[i], vars.storages.red, 1)
end
end
elseif vars.a == 3 then
for i = 1, 3 do
if getTopCreature(positions.red[i]).type == 1 then
doTeleportThing(positions.red[i], destinations.red[i])
setPlayerStorageValue(positions.red[i], vars.storages.red, 1)
end
end
end
--blue--
if vars.b == 1 then
if getTopCreature(positions.blue[1]).type == 1 then
doTeleportThing(positions.blue[1],destinations.blue[1])
setPlayerStorageValue(positions.blue[1], vars.storages.blue, 1)
end
elseif vars.b == 2 then
for i = 1, 2 do
if getTopCreature(positions.blue[i]).type == 1 then
doTeleportThing(positions.blue[i], destinations.blue[i])
setPlayerStorageValue(positions.blue[i], vars.storages.blue, 1)
end
end
elseif vars.b == 3 then
for i = 1, 3 do
if getTopCreature(positions.blue[i]).type == 1 then
doTeleportThing(positions.blue[i], destinations.blue[i])
setPlayerStorageValue(positions.blue[i], vars.storages.blue, 1)
end
end
end
end
--/script/--
return true
end