tenho um script de anihi para 2 player queria edita para 1 player so n precisa de 2 player so um
function getMonstersInArea(pos1,pos2)
local players = {}
if pos1.x and pos1.y and pos2.x and pos2.y and pos1.z and pos2.z then
for a = pos1.x, pos2.x do
for b = pos1.y,pos2.y do
local pos = {x=a,y=b,z=pos1.z}
if isMonster(getTopCreature(pos).uid) then
table.insert(players,getTopCreature(pos).uid)
end
end
end
return players
else
return false
end
end
function getPlayersInArea(pos1,pos2)
local players = {}
if pos1.x and pos1.y and pos2.x and pos2.y and pos1.z and pos2.z then
for a = pos1.x, pos2.x do
for b = pos1.y,pos2.y do
for z=pos1.z,pos2.z do
local pos = {x=a,y=b,z=z}
if isPlayer(getTopCreature(pos).uid) then
table.insert(players,getTopCreature(pos).uid)
end
end
end
end
return players
else
return false
end
end
function onUse(cid, item, fromPos, itemEx, toPos)
local pos = {
p1 = {x=35, y=1041, z=7}, -- posições dos jogadores antes da anihi
p2 = {x=35, y=1042, z=7},
anihi1 = {x=456, y=1317, z=7}, -- posições de início e fim da anihi (coloque um z=6 e outro z=7 e todos os números tem que ser em ordem crescente)
anihi2 = {x=468, y=1322, z=7},
top1 = {x=19, y=1053, z=7}, -- posições para onde cada player irá na anihi
top2 = {x=20, y=1053, z=7},
}
anihiStorage = 23602 -- storage pra checar se já fez a anihi (esse código não vai mudar, só nos baús)
local beezer = {
[1] = {x=44, y=1129, z=7}, -- posição de cada beezer
[2] = {x=45, y=1129, z=7},
[3] = {x=46, y=1129, z=7},
[4] = {x=47, y=1129, z=7},
[5] = {x=48, y=1129, z=7},
[6] = {x=49, y=1129, z=7},
}
local player1 = getTopCreature(pos.p1)
local player2 = getTopCreature(pos.p2)
if item.itemid == 1945 then
if isPlayer(player1.uid) and isPlayer(player2.uid) then
local players = {[1] = player1.uid, [2] = player2.uid}
local playersInAnihi = getPlayersInArea(pos.anihi1, pos.anihi2)
local j = 0
if #playersInAnihi > 0 then
for _, pid in ipairs(players) do
doPlayerSendCancel(pid, 'You have to wait until another team clears off the room before you can enter.')
end
j = 1
end
if j == 1 then
doTransformItem(item.uid, item.itemid+1)
return true
end
if getPlayerLevel(player1.uid) >= 250 and getPlayerLevel(player2.uid) >= 250 then
local i = 0
for _,pid in ipairs(players) do
if getPlayerStorageValue(pid, anihiStorage) > -1 then
i = 1
for _,pad in ipairs(players) do
doPlayerSendCancel(pad, 'Someone in your team has already done this quest.')
end
break
end
end
if i == 1 then
doTransformItem(item.uid, item.itemid+1)
return true
end
local monstersInAnihi = getMonstersInArea(pos.anihi1,pos.anihi2)
if #monstersInAnihi > 0 then
for _, monst in ipairs(monstersInAnihi) do
doRemoveCreature(monst)
end
end
for _, position in ipairs(beezer) do
doCreateMonster('beezer', position)
end
doTeleportThing(player1.uid, pos.top1)
doSendMagicEffect(pos.top1,10)
doTeleportThing(player2.uid, pos.top2)
doSendMagicEffect(pos.top2,10)
else
for _,pid in ipairs(players) do
if getPlayerLevel(pid) < 250 then
doPlayerSendCancel(pid, 'You have to be level 250 to enter this quest.')
else
doPlayerSendCancel(pid, 'Someone in your team is under level 250.')
end
end
end
else
doPlayerSendCancel(cid, 'You need 2 players for this quest.')
end
doTransformItem(item.uid, item.itemid+1)
return true
elseif item.itemid == 1946 then
doTransformItem(item.uid, item.itemid-1)
return true
end
return true
end