Ir para conteúdo

Featured Replies

Postado

.Qual servidor ou website você utiliza como base? 

OTX

Qual o motivo deste tópico? 

SCRIPT

Está surgindo algum erro? Se sim coloque-o aqui. 

Citar

boa noite pessoal,

esse script esta funcionando ao levar os player para a boss room e nascendo o boss

Mas se alguem puxar depois, ele n reconhece que tem gente na sala e manda um novo time pra dentro fazendo com que o boss volte a full life

queria que colocassem esse check de players la dentro. obrigado

 

Você tem o código disponível? Se tiver publique-o aqui: 

local posInicio = {x = 833, y = 2879, z = 7} --pos inicio da sala 
local posFim = {x = 833, y = 2902, z = 7} --pos final inicio da sala
local posExitTime = {x = 855, y = 2885, z = 7} -- pos para onde o player vai sair
 
local function verificaPlayers()
    for x = posInicio.x, posFim.x do
        for y = posInicio.y, posFim.y do
            if isPlayer(getThingFromPos({x = x, y = y, z = posInicio.z, stackpos = 253}).uid) then
                return 1
            end
        end
    end
end
 
local function verificaBoss()
    for x = posInicio.x, posFim.x  do
        for y = posInicio.y, posFim.y do
            if isMonster(getThingFromPos({x = x, y = y, z = posInicio.z, stackpos = 253}).uid) then
                doRemoveCreature(getThingFromPos({x = x, y = y, z = posInicio.z, stackpos = 253}).uid)
            end
        end
    end
end
 
local function removePlayersTime()
    for x = posInicio.x, posFim.x  do
        for y = posInicio.y, posFim.y do
            local remove, clean = true, true
            local pos = {x = x, y = y, z = posInicio.z}
            local m = getTopCreature(pos).uid
            if m ~= 0 and isPlayer(m) then
                doTeleportThing(m, posExitTime)
            end
        end
    end
    doSendMagicEffect(posExitTime, 10)
    return true
end
 
function onUse(cid, item, frompos, item2, topos)
 
    -- Lever Boss
    if item.aid == 6301 then -- action id da alavanca
        local playerChecked = false
        local teleportToRoom = false
 
        local stoExhaust = 5534241 -- staorage de segurança para exhaust
        local stoExhaustPlayer = getPlayerStorageValue(cid, stoExhaust)
        if stoExhaustPlayer > os.time() then
            doPlayerSendCancel(cid, "You have to wait " .. stoExhaustPlayer - os.time() .. " seconds to try again.")
            return true
        end
        if verificaPlayers() then
            doPlayerSendCancel(cid, "There are other players inside the room at the moment.")
            doSendMagicEffect(topos,2)
            setPlayerStorageValue(cid, stoExhaust, os.time()+5)
            return true
        end
 
        local config = {
            [1] = {pos = {x = 832, y = 2909, z = 7}}, --posições dos pisos
            [2] = {pos = {x = 833, y = 2909, z = 7}},
            [3] = {pos = {x = 834, y = 2909, z = 7}},
            [4] = {pos = {x = 835, y = 2909, z = 7}},
            [5] = {pos = {x = 836, y = 2909, z = 7}},
        }
 
        local storageTime = 5534240 -- storage de tempo
       
 
        for i, v in pairs(config) do
            if isPlayer(getTopCreature(config[i].pos).uid) then
                player = getTopCreature(config[i].pos).uid
                if getPlayerStorageValue(player, storageTime) > os.time() then
                    time = (getPlayerStorageValue(player, storageTime)-os.time())/60
                    str = "minutes"
                    if time > 60 then
                        time = time/60
                        str = "hours"
                        end
                    if player == cid then name = "You" else name = getCreatureName(player) end
                    doPlayerSendCancel(cid, name .. " need to wait more " .. math.floor(time+0.5) .. " " .. str .. " to do again.")
                    doSendMagicEffect(topos,2)
                    return true
                end
                if player == cid then
                    playerChecked = true
                end
            end
        end
		if verificaPlayers() then
			doPlayerSendCancel(cid, "There are other players inside the room at the moment.")
			doSendMagicEffect(topos,2)
			setPlayerStorageValue(cid, stoExhaust, os.time()+5)
			return true
		end
 
        if playerChecked then
            for i, v in pairs(config) do
                if isPlayer(getTopCreature(config[i].pos).uid) then
                    player = getTopCreature(config[i].pos).uid
                    doSendMagicEffect(getCreaturePosition(player), 2)
                    doTeleportThing(player, {x = 833, y = 2899, z = 7}) -- posiçao que player vai cair dentro da sala
                    setPlayerStorageValue(player, storageTime, os.time()+72000) -- 20 horas
                    teleportToRoom = true
                end
            end
 
            if teleportToRoom then
                stopEvent(ResetArea)
                verificaBoss()
                doSendMagicEffect({x = 833, y = 2881, z = 7}, 10) -- efeito aonde o boss nasce
                doCreateMonster("An Observer Eye", {x = 833, y = 2881, z = 7}) -- onde o boss nasce
                ResetArea = addEvent(function()
                    removePlayersTime()
                end, 20 * 60 * 1000) -- tempo dentro da sala
                return false
            end
        else
            doPlayerSendCancel(cid, "Wouldn't you like to go too?")
            doSendMagicEffect(topos,2)
        end
 
        return true
    end
 
end 

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui. 

 

Editado por Reinaldo Worona (veja o histórico de edições)

  • Respostas 5
  • Visualizações 509
  • Created
  • Última resposta

Top Posters In This Topic

Posted Images

Postado

Testa dessa maneira:

local teamPositions = {
    [1] = { x = 100, y = 100, z = 7 }, -- posição do jogador 1
    [2] = { x = 101, y = 100, z = 7 }, -- posição do jogador 2
    [3] = { x = 102, y = 100, z = 7 }, -- posição do jogador 3
    [4] = { x = 103, y = 100, z = 7 }, -- posição do jogador 4
    [5] = { x = 104, y = 100, z = 7 } -- posição do jogador 5
}

local monster_name = "nome_da_criatura"
local monster_position = { x = 110, y = 100, z = 7 } -- posição da criatura

local room_fromPosition = { x = 90, y = 90, z = 7 } -- posição inicial da sala
local room_toPosition = { x = 120, y = 110, z = 7 } -- posição final da sala
local room_centerPosition = { x = 105, y = 105, z = 7 } -- posição central da sala

local team_teleportPosition = { x = 105, y = 95, z = 7 } -- posição de teleporte do time
local monster_teleportPosition = { x = 105, y = 115, z = 7 } -- posição de teleporte da criatura

local time_limit = 7 * 60 -- limite de tempo para o time em segundos

local exit_position = { x = 999, y = 999, z = 7 } -- posição de teleporte dos jogadores ao acabar o tempo

local function isTeamReady(team)
    for i = 1, #team do
        local player = team[i]
        local playerPos = player:getPosition()
        local diffX = math.abs(playerPos.x - teamPositions[i].x)
        local diffY = math.abs(playerPos.y - teamPositions[i].y)
        local diffZ = math.abs(playerPos.z - teamPositions[i].z)
        if diffX > 1 or diffY > 1 or diffZ > 1 then
            return false
        end
    end
    return true
end

local function isRoomAvailable()
    local tile = Tile(room_centerPosition)
    if not tile then
        return false
    end
    local creature = tile:getTopCreature()
    if creature and creature:isMonster() and creature:getName() == monster_name then
        return false
    end
    local spectators = tile:getSpectators()
    for i = 1, #spectators do
        local spectator = spectators[i]
        if spectator:isPlayer() then
            local spectatorPos = spectator:getPosition()
            local diffX = math.abs(spectatorPos.x - room_centerPosition.x)
            local diffY = math.abs(spectatorPos.y - room_centerPosition.y)
            local diffZ = math.abs(spectatorPos.z - room_centerPosition.z)
            if diffX <= 5 and diffY <= 5 and diffZ <= 1 then
                return false
            end
        end
    end
    return true
end

local function removeMonsterFromRoom()
    local tile = Tile(room_centerPosition)
    if not tile then
        return
    end
    local creature = tile:getTopCreature()
    if creature and creature:isMonster() and creature:getName() == monster_name then
        creature:remove()
    end
end

local function teleportTeamAndMonster(team)
    for i = 1, #team do
        local player = team[i]
        player:teleportTo(team_teleportPosition)
    end
    local monster = Game.createMonster(monster_name, monster_position, true, true)
    monster:teleportTo(monster_teleportPosition)
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local team = {}
    for i = 1, 5 do
        local player = Tile(teamPositions[i]):getTopCreature()
        if not player or not player:isPlayer() then
            player:sendCancelMessage("Todos os jogadores precisam estar em suas posições para acionar a alavanca.")
            return true
        end
        table.insert(team, player)
    end
    if not isTeamReady(team) then
        player:sendCancelMessage("Todos os jogadores precisam estar em suas posições para acionar a alavanca.")
        return true
    end
    if not isRoomAvailable() then
        player:sendCancelMessage("A sala já está em uso. Tente novamente mais tarde.")
        return true
    end
    removeMonsterFromRoom()
    teleportTeamAndMonster(team)
    addEvent(function()
        removeMonsterFromRoom()
        for i = 1, #team do
            local player = team[i]
            player:teleportTo(exit_position)
        end
    end, time_limit * 1000)
    return true
end

 

Editado por Anderson Sacani (veja o histórico de edições)

Postado
  • Autor
6 horas atrás, Anderson Sacani disse:

Testa dessa maneira:


local teamPositions = {
    [1] = { x = 100, y = 100, z = 7 }, -- posição do jogador 1
    [2] = { x = 101, y = 100, z = 7 }, -- posição do jogador 2
    [3] = { x = 102, y = 100, z = 7 }, -- posição do jogador 3
    [4] = { x = 103, y = 100, z = 7 }, -- posição do jogador 4
    [5] = { x = 104, y = 100, z = 7 } -- posição do jogador 5
}

local monster_name = "nome_da_criatura"
local monster_position = { x = 110, y = 100, z = 7 } -- posição da criatura

local room_fromPosition = { x = 90, y = 90, z = 7 } -- posição inicial da sala
local room_toPosition = { x = 120, y = 110, z = 7 } -- posição final da sala
local room_centerPosition = { x = 105, y = 105, z = 7 } -- posição central da sala

local team_teleportPosition = { x = 105, y = 95, z = 7 } -- posição de teleporte do time
local monster_teleportPosition = { x = 105, y = 115, z = 7 } -- posição de teleporte da criatura

local time_limit = 7 * 60 -- limite de tempo para o time em segundos

local exit_position = { x = 999, y = 999, z = 7 } -- posição de teleporte dos jogadores ao acabar o tempo

local function isTeamReady(team)
    for i = 1, #team do
        local player = team[i]
        local playerPos = player:getPosition()
        local diffX = math.abs(playerPos.x - teamPositions[i].x)
        local diffY = math.abs(playerPos.y - teamPositions[i].y)
        local diffZ = math.abs(playerPos.z - teamPositions[i].z)
        if diffX > 1 or diffY > 1 or diffZ > 1 then
            return false
        end
    end
    return true
end

local function isRoomAvailable()
    local tile = Tile(room_centerPosition)
    if not tile then
        return false
    end
    local creature = tile:getTopCreature()
    if creature and creature:isMonster() and creature:getName() == monster_name then
        return false
    end
    local spectators = tile:getSpectators()
    for i = 1, #spectators do
        local spectator = spectators[i]
        if spectator:isPlayer() then
            local spectatorPos = spectator:getPosition()
            local diffX = math.abs(spectatorPos.x - room_centerPosition.x)
            local diffY = math.abs(spectatorPos.y - room_centerPosition.y)
            local diffZ = math.abs(spectatorPos.z - room_centerPosition.z)
            if diffX <= 5 and diffY <= 5 and diffZ <= 1 then
                return false
            end
        end
    end
    return true
end

local function removeMonsterFromRoom()
    local tile = Tile(room_centerPosition)
    if not tile then
        return
    end
    local creature = tile:getTopCreature()
    if creature and creature:isMonster() and creature:getName() == monster_name then
        creature:remove()
    end
end

local function teleportTeamAndMonster(team)
    for i = 1, #team do
        local player = team[i]
        player:teleportTo(team_teleportPosition)
    end
    local monster = Game.createMonster(monster_name, monster_position, true, true)
    monster:teleportTo(monster_teleportPosition)
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local team = {}
    for i = 1, 5 do
        local player = Tile(teamPositions[i]):getTopCreature()
        if not player or not player:isPlayer() then
            player:sendCancelMessage("Todos os jogadores precisam estar em suas posições para acionar a alavanca.")
            return true
        end
        table.insert(team, player)
    end
    if not isTeamReady(team) then
        player:sendCancelMessage("Todos os jogadores precisam estar em suas posições para acionar a alavanca.")
        return true
    end
    if not isRoomAvailable() then
        player:sendCancelMessage("A sala já está em uso. Tente novamente mais tarde.")
        return true
    end
    removeMonsterFromRoom()
    teleportTeamAndMonster(team)
    addEvent(function()
        removeMonsterFromRoom()
        for i = 1, #team do
            local player = team[i]
            player:teleportTo(exit_position)
        end
    end, time_limit * 1000)
    return true
end

 

salve, obrigado pela resposta.

Mas não funcionou... apareceu esse erro com sua script

image.thumb.png.c6bbee7f4791f5240875fbc1c149d0a7.png

Postado
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	local player_fromPosition = { x = 100, y = 100, z = 7 } -- coordenadas mínimas para que os jogadores possam puxar a alavanca
	local player_toPosition = { x = 110, y = 110, z = 7 } -- coordenadas máximas para que os jogadores possam puxar a alavanca
	local room_fromPosition = { x = 90, y = 90, z = 7 } -- coordenadas mínimas da área da sala
	local room_toPosition = { x = 120, y = 120, z = 7 } -- coordenadas máximas da área da sala
	local room_playerPosition = { x = 100, y = 120, z = 7 } -- coordenadas onde os jogadores serão teleportados após puxar a alavanca
	local room_monsterPosition = { x = 110, y = 100, z = 7 } -- coordenadas onde o boss será invocado
	local exit_room = { x = 130, y = 130, z = 7 } -- coordenadas onde os jogadores serão teleportados após os 7 minutos
	local boss_name = "Orshabaal" -- nome do boss que será sumonado

	-- verifica se há jogadores na área da sala
	local hasPlayers = false
	for _, pid in ipairs(Game.getPlayers()) do
		if pid:getPosition().x >= room_fromPosition.x and pid:getPosition().y >= room_fromPosition.y and pid:getPosition().x <= room_toPosition.x and pid:getPosition().y <= room_toPosition.y then
			hasPlayers = true
			break
		end
	end

	if hasPlayers then
		player:sendTextMessage(MESSAGE_STATUS_WARNING, "Há jogadores na sala.")
		return true
	end

	-- verifica se todos os jogadores estão na área da alavanca
	local playersInRange = 0
	for _, pid in ipairs(Game.getPlayers()) do
		if pid:getPosition().x >= player_fromPosition.x and pid:getPosition().y >= player_fromPosition.y and pid:getPosition().x <= player_toPosition.x and pid:getPosition().y <= player_toPosition.y then
			playersInRange = playersInRange + 1
		end
	end

	if playersInRange < 5 then
		player:sendTextMessage(MESSAGE_STATUS_WARNING, "São necessários pelo menos 5 jogadores na área da alavanca.")
		return true
	end

	-- teleporta os jogadores para a sala
	for _, pid in ipairs(Game.getPlayers()) do
		if pid:getPosition().x >= player_fromPosition.x and pid:getPosition().y >= player_fromPosition.y and pid:getPosition().x <= player_toPosition.x and pid:getPosition().y <= player_toPosition.y then
			pid:teleportTo(room_playerPosition)
			pid:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
		end
	end

	-- invoca o boss
	local monster = Game.createMonster(boss_name, room_monsterPosition)
	if not monster then
		player:sendTextMessage(MESSAGE_STATUS_WARNING, "Não foi possível invocar o boss.")
		return true
	end

	-- define o tempo para matar o boss
	local time = 7 * 60 -- 7 minutos em segundos
	addEvent(function()
		-- expulsa os jogadores da sala após o tempo definido
		for _, pid in ipairs(Game.getPlayers()) do
			if pid:getPosition().x >= room_fromPosition.x and pid:getPosition().y >= room_fromPosition.y and pid:getPosition().x <= room_toPosition.x and pid:getPosition().y <= room_toPosition.y then
				pid:teleportTo(exit_room)
				pid:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
			end
		end
		-- se o boss não foi morto, o destrói
		if monster:isAlive() then
			monster:remove()
			broadcastMessage("O boss foi destruído após o tempo limite ter expirado.")
		end
	end, time * 1000)

	return true
end

 

Editado por Anderson Sacani (veja o histórico de edições)

Postado

pelo oque vi vc precisa configurar apenas essa parte do seu script para funcionar como quer :

local posInicio = {x = 833, y = 2879, z = 7} --pos inicio da sala (é o tile no canto noroeste da sala do boss/\<)
local posFim = {x = 833, y = 2902, z = 7} --pos final inicio da sala (é o tile no sudeste da sala do boss \/>)

 

Host bom para hospedar seu jogo => https://shre.ink/OminiHost

 

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo