já existe a função de remover o boss, basta usá-la.
function onUse(cid, item, fromPosition, itemEx, toPosition)
local players = {}
for i = 1, #BossRoom.alavanca do
local v = getTopCreature(BossRoom.alavanca[i]).uid
players[i] = isPlayer(v) and v or nil
end
function checkPlayersInRoom() -- Responsável por verificar se há jogadores na sala enfrentando o boss.
local player_room = 0
for x = BossRoom.areaSalaBoss[1].x, BossRoom.areaSalaBoss[2].x do
for y = BossRoom.areaSalaBoss[1].y, BossRoom.areaSalaBoss[2].y do
for z = BossRoom.areaSalaBoss[1].z, BossRoom.areaSalaBoss[2].z do
local pos = {x=x, y=y, z=z,stackpos = 253}
local thing = getThingfromPos(pos)
if thing.itemid > 0 and isPlayer(thing.uid) == true then
player_room = player_room+1
end
end
end
end
return player_room
end
if #players < BossRoom.minPlayers then
doPlayerSendCancel(cid, "You need at least "..BossRoom.minPlayers.." players to enter.")
return true
end
if checkPlayersInRoom() >= 1 then
doPlayerSendTextMessage(cid,19, "There is already a team in the boss room.")
return true
end
function playersTP(position) -- Responsável por teleportar os jogadores
for i = 1, 6 do
if players[i] then
doTeleportThing(players[i], position)
doSendMagicEffect(position, CONST_ME_TELEPORT)
end
end
end
function removeBoss() -- Responsavel por Remover o BOSS da sala (caso os players nao tenham matado)
for x = BossRoom.areaSalaBoss[1].x, BossRoom.areaSalaBoss[2].x do
for y = BossRoom.areaSalaBoss[1].y, BossRoom.areaSalaBoss[2].y do
for z = BossRoom.areaSalaBoss[1].z, BossRoom.areaSalaBoss[2].z do
local area = {x = x, y = y, z = z}
local creature = getTopCreature(area).uid
if isCreature(creature) then
doRemoveCreature(creature)
end
end
end
end
end
function checkBossTime() -- Responsável por verificar se os jogadores matou ou não o boss após 10 minutos.
for x = BossRoom.areaSalaBoss[1].x - 1, BossRoom.areaSalaBoss[2].x + 1 do
for y = BossRoom.areaSalaBoss[1].y - 1, BossRoom.areaSalaBoss[2].y + 1 do
local pos = {x=x, y=y, z=BossRoom.areaSalaBoss[1].z}
local m = getTopCreature(pos).uid
if m ~= 0 and isMonster(m) and isInArray(BossRoom.name, getCreatureName(m)) then
playersTP(BossRoom.positionKickPlayer)
removeBoss()
end
end
end
return false
end
removeBoss()
playersTP(BossRoom.positionSalaBoss)
doCreateMonster(BossRoom.name, BossRoom.positionSpawnBoss)
addEvent(checkBossTime, BossRoom.timeToKill*60*1000)
return true
end