Ir para conteúdo
  • Cadastre-se

(Resolvido)Sala de boss por alavanca


Ir para solução Resolvido por Vodkart,

Posts Recomendados

Estou com problemas com a sala dos boss por alavanca
estou usando esse script e os problemas sao
quando tem alguem dentro da sala matando o boss e outro jogador puxar a alavanca ele consegui entrar (resetando o boss ou fazendo com que apareça mais 1 na sala)
no caso precisava de alguma alteraçao para travar a entrada enquanto estiver alguem matando o boss
e uma outra para caso o jogador morrer dentro da sala,o boss ser removido ou resetado quando um novo jogador for entrar..para nao ter risco de entrar e encontrar 2 boss dentro da sala
 

Spoiler

local config = {
        cooldown = 60 * 60 * 20, -- in seconds - (Make it 'seconds * minutes * hours' - its will be '60 * 60 * 20' for 20 hours) (player cooldown)
        cooldown_storage = 808856,
        duration = 10, -- time till reset, in minutes (lever cooldown)
        level_req = 8, -- minimum level to do quest
        min_players = 1, -- minimum players to join quest
        lever_id = 1945, -- id of lever before pulled
        pulled_id = 1946, -- id of lever after pulled
    }

    local player_positions = {
        [1] = {fromPos = Position(33395, 32662, 6), toPos = Position(33395, 32658, 6)},
        [2] = {fromPos = Position(33395, 32663, 6), toPos = Position(33395, 32658, 6)},
        [3] = {fromPos = Position(33395, 32663, 6), toPos = Position(33395, 32658, 6)},
        [4] = {fromPos = Position(33395, 32665, 6), toPos = Position(33395, 32658, 6)},
        [5] = {fromPos = Position(33394, 32662, 6), toPos = Position(33395, 32658, 6)}
    }

    local monsters = {
        [1] = {pos = Position(33396, 32642, 6), name = "scarlett etzel"}
    }
    local quest_range = {fromPos = Position(33386, 32639, 6), toPos = Position(33405, 32659, 6)} -- see image in thread for explanation

    local exit_position = Position(33395, 32671, 6) -- Position completely outside the quest area

    function doResetTheBossDukeKrule(position, cid_array)

        local tile = Tile(position)

        local item = tile and tile:getItemById(config.pulled_id)
        if not item then
            return
        end

        local monster_names = {}
        for key, value in pairs(monsters) do
            if not isInArray(monster_names, value.name) then
                monster_names[#monster_names + 1] = value.name
            end
        end

        for i = 1, #monsters do
            local creatures = Tile(monsters[i].pos):getCreatures()
            for key, creature in pairs(creatures) do
                if isInArray(monster_names, creature:getName()) then
                    creature:remove()
                end
            end
        end

        for i = 1, #player_positions do
            local creatures = Tile(player_positions[i].toPos):getCreatures()
            for key, creature in pairs(creatures) do
                if isInArray(monster_names, creature:getName()) then
                    creature:remove()
                end
            end
        end

        for key, cid in pairs(cid_array) do
            local participant = Player(cid)
        if participant and isInRange(participant:getPosition(), quest_range.fromPos, quest_range.toPos) then
                participant:teleportTo(exit_position)
                exit_position:sendMagicEffect(CONST_ME_TELEPORT)
            end
        end

        item:transform(config.lever_id)
    end

    local function removeBoss()
    local specs, spec = Game.getSpectators(Position(33396, 32649, 6), false, false, 10, 10, 10, 10)
        for j = 1, #specs do
            spec = specs[j]
            if spec:getName():lower() == 'scarlett etzel' then
                spec:remove()
            end
        end
    end

    function onUse(player, item, fromPosition, target, toPosition, isHotkey)
        if player:getStorageValue(config.cooldown_storage) >= os.time() then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "try tomorrow")
            return true
        end

        local participants, pull_player = {}, false
        for i = 1, #player_positions do
            local fromPos = player_positions[i].fromPos
            local tile = Tile(fromPos)
            if not tile then
                print(">> ERROR: Annihilator tile does not exist for Position(" .. fromPos.x .. ", " .. fromPos.y .. ", " .. fromPos.z .. ").")
                return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
            end

            local creature = tile:getBottomCreature()
            if creature then
                local participant = creature:getPlayer()
                if not participant then
                    return player:sendCancelMessage(participant:getName() .. " is not a valid participant.")
                end

                if participant:getLevel() < config.level_req then
                    return player:sendCancelMessage(participant:getName() .. " is not the required level.")
                end

                if participant.uid == player.uid then
                    pull_player = true
                end

                participants[#participants + 1] = {participant = participant, toPos = player_positions[i].toPos}
            end
        end

        if #participants < config.min_players then
            return player:sendCancelMessage("You do not have the required amount of participants.")
        end

        if not pull_player then
            return player:sendCancelMessage("You are in the wrong position.")
        end

        for i = 1, #monsters do
            local toPos = monsters[i].pos
            if not Tile(toPos) then
                print(">> ERROR: Annihilator tile does not exist for Position(" .. toPos.x .. ", " .. toPos.y .. ", " .. toPos.z .. ").")
                return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
            end
            removeBoss()
            Game.createMonster(monsters[i].name, monsters[i].pos, false, true)
        end

        local cid_array = {}
        for i = 1, #participants do
            participants[i].participant:teleportTo(participants[i].toPos)
            participants[i].toPos:sendMagicEffect(CONST_ME_TELEPORT)
            cid_array[#cid_array + 1] = participants[i].participant.uid
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have 10 minutes to kill and loot this boss. Otherwise you will lose that chance and will be kicked out.")
        end

        item:transform(config.pulled_id)
        player:setStorageValue(config.cooldown_storage, os.time() + config.cooldown)
        addEvent(doResetTheBossDukeKrule, config.duration * 60 * 1000,  toPosition, cid_array)
        return true
    end

 

 

 

 

 

 

Link para o post
Compartilhar em outros sites
3 horas atrás, leonardo gazim disse:

Estou com problemas com a sala dos boss por alavanca
estou usando esse script e os problemas sao
quando tem alguem dentro da sala matando o boss e outro jogador puxar a alavanca ele consegui entrar (resetando o boss ou fazendo com que apareça mais 1 na sala)
no caso precisava de alguma alteraçao para travar a entrada enquanto estiver alguem matando o boss
e uma outra para caso o jogador morrer dentro da sala,o boss ser removido ou resetado quando um novo jogador for entrar..para nao ter risco de entrar e encontrar 2 boss dentro da sala
 

  Ocultar conteúdo

local config = {
        cooldown = 60 * 60 * 20, -- in seconds - (Make it 'seconds * minutes * hours' - its will be '60 * 60 * 20' for 20 hours) (player cooldown)
        cooldown_storage = 808856,
        duration = 10, -- time till reset, in minutes (lever cooldown)
        level_req = 8, -- minimum level to do quest
        min_players = 1, -- minimum players to join quest
        lever_id = 1945, -- id of lever before pulled
        pulled_id = 1946, -- id of lever after pulled
    }

    local player_positions = {
        [1] = {fromPos = Position(33395, 32662, 6), toPos = Position(33395, 32658, 6)},
        [2] = {fromPos = Position(33395, 32663, 6), toPos = Position(33395, 32658, 6)},
        [3] = {fromPos = Position(33395, 32663, 6), toPos = Position(33395, 32658, 6)},
        [4] = {fromPos = Position(33395, 32665, 6), toPos = Position(33395, 32658, 6)},
        [5] = {fromPos = Position(33394, 32662, 6), toPos = Position(33395, 32658, 6)}
    }

    local monsters = {
        [1] = {pos = Position(33396, 32642, 6), name = "scarlett etzel"}
    }
    local quest_range = {fromPos = Position(33386, 32639, 6), toPos = Position(33405, 32659, 6)} -- see image in thread for explanation

    local exit_position = Position(33395, 32671, 6) -- Position completely outside the quest area

    function doResetTheBossDukeKrule(position, cid_array)

        local tile = Tile(position)

        local item = tile and tile:getItemById(config.pulled_id)
        if not item then
            return
        end

        local monster_names = {}
        for key, value in pairs(monsters) do
            if not isInArray(monster_names, value.name) then
                monster_names[#monster_names + 1] = value.name
            end
        end

        for i = 1, #monsters do
            local creatures = Tile(monsters[i].pos):getCreatures()
            for key, creature in pairs(creatures) do
                if isInArray(monster_names, creature:getName()) then
                    creature:remove()
                end
            end
        end

        for i = 1, #player_positions do
            local creatures = Tile(player_positions[i].toPos):getCreatures()
            for key, creature in pairs(creatures) do
                if isInArray(monster_names, creature:getName()) then
                    creature:remove()
                end
            end
        end

        for key, cid in pairs(cid_array) do
            local participant = Player(cid)
        if participant and isInRange(participant:getPosition(), quest_range.fromPos, quest_range.toPos) then
                participant:teleportTo(exit_position)
                exit_position:sendMagicEffect(CONST_ME_TELEPORT)
            end
        end

        item:transform(config.lever_id)
    end

    local function removeBoss()
    local specs, spec = Game.getSpectators(Position(33396, 32649, 6), false, false, 10, 10, 10, 10)
        for j = 1, #specs do
            spec = specs[j]
            if spec:getName():lower() == 'scarlett etzel' then
                spec:remove()
            end
        end
    end

    function onUse(player, item, fromPosition, target, toPosition, isHotkey)
        if player:getStorageValue(config.cooldown_storage) >= os.time() then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "try tomorrow")
            return true
        end

        local participants, pull_player = {}, false
        for i = 1, #player_positions do
            local fromPos = player_positions[i].fromPos
            local tile = Tile(fromPos)
            if not tile then
                print(">> ERROR: Annihilator tile does not exist for Position(" .. fromPos.x .. ", " .. fromPos.y .. ", " .. fromPos.z .. ").")
                return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
            end

            local creature = tile:getBottomCreature()
            if creature then
                local participant = creature:getPlayer()
                if not participant then
                    return player:sendCancelMessage(participant:getName() .. " is not a valid participant.")
                end

                if participant:getLevel() < config.level_req then
                    return player:sendCancelMessage(participant:getName() .. " is not the required level.")
                end

                if participant.uid == player.uid then
                    pull_player = true
                end

                participants[#participants + 1] = {participant = participant, toPos = player_positions[i].toPos}
            end
        end

        if #participants < config.min_players then
            return player:sendCancelMessage("You do not have the required amount of participants.")
        end

        if not pull_player then
            return player:sendCancelMessage("You are in the wrong position.")
        end

        for i = 1, #monsters do
            local toPos = monsters[i].pos
            if not Tile(toPos) then
                print(">> ERROR: Annihilator tile does not exist for Position(" .. toPos.x .. ", " .. toPos.y .. ", " .. toPos.z .. ").")
                return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
            end
            removeBoss()
            Game.createMonster(monsters[i].name, monsters[i].pos, false, true)
        end

        local cid_array = {}
        for i = 1, #participants do
            participants[i].participant:teleportTo(participants[i].toPos)
            participants[i].toPos:sendMagicEffect(CONST_ME_TELEPORT)
            cid_array[#cid_array + 1] = participants[i].participant.uid
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have 10 minutes to kill and loot this boss. Otherwise you will lose that chance and will be kicked out.")
        end

        item:transform(config.pulled_id)
        player:setStorageValue(config.cooldown_storage, os.time() + config.cooldown)
        addEvent(doResetTheBossDukeKrule, config.duration * 60 * 1000,  toPosition, cid_array)
        return true
    end

 

 

 

 

 

 

-- <action actionid="4627" event="script" value="bosses/scarlet_boss.lua"/> adicionar no actions.xml

local posInicio = {x = 33385, y = 32638, z = 6} --pos inicio da sala
local posFim = {x = 33406, y = 32660, z = 6}--pos final inicio da sala
local posExitTime = {x = 33393, y = 32671, z = 6}-- 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 == 4627 then -- action id da alavanca
		local playerChecked = false
		local teleportToRoom = false

		local stoExhaust = 424148 -- 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 = 33395, y = 32661, z = 6}}, --posições dos pisos
			[2] = {pos = {x = 33394, y = 32662, z = 6}},
			[3] = {pos = {x = 33395, y = 32662, z = 6}},
			[4] = {pos = {x = 33396, y = 32662, z = 6}},
			[5] = {pos = {x = 33395, y = 32663, z = 6}},
		}

		local storageTime = 424149 -- storage de tempo do boss
		

		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 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 = 33396, y = 32656, z = 6}) -- posiçao que player vai cair
					setPlayerStorageValue(player, storageTime, os.time()+72000) -- tempo de 20 horas
					teleportToRoom = true
				end
			end

			if teleportToRoom then
				stopEvent(ResetArea)
				verificaBoss()
				doSendMagicEffect({x = 33396, y = 32642, z = 6}, 10) -- efeito que vai aparece no monstro quando ele nasce, mesma posiçao onde nasce o boss
				doCreateMonster("Scarlett Etzel", {x = 33396, y = 32642, z = 6}) -- onde o boss nasce e nome do boss
				ResetArea = addEvent(function()
					removePlayersTime()
				end, 10 * 60 * 1000) -- tempo dentro da sala para ser kikado tem tera 10 minutos para matar o boss ou sera teleportado de volta
				return false
			end
		else
			doPlayerSendCancel(cid, "Wouldn't you like to go too?")
			doSendMagicEffect(topos,2)
		end

		return true
	end

end

 

Link para o post
Compartilhar em outros sites
5 horas atrás, Kenshiin disse:

-- <action actionid="4627" event="script" value="bosses/scarlet_boss.lua"/> adicionar no actions.xml

local posInicio = {x = 33385, y = 32638, z = 6} --pos inicio da sala
local posFim = {x = 33406, y = 32660, z = 6}--pos final inicio da sala
local posExitTime = {x = 33393, y = 32671, z = 6}-- 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 == 4627 then -- action id da alavanca
		local playerChecked = false
		local teleportToRoom = false

		local stoExhaust = 424148 -- 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 = 33395, y = 32661, z = 6}}, --posições dos pisos
			[2] = {pos = {x = 33394, y = 32662, z = 6}},
			[3] = {pos = {x = 33395, y = 32662, z = 6}},
			[4] = {pos = {x = 33396, y = 32662, z = 6}},
			[5] = {pos = {x = 33395, y = 32663, z = 6}},
		}

		local storageTime = 424149 -- storage de tempo do boss
		

		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 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 = 33396, y = 32656, z = 6}) -- posiçao que player vai cair
					setPlayerStorageValue(player, storageTime, os.time()+72000) -- tempo de 20 horas
					teleportToRoom = true
				end
			end

			if teleportToRoom then
				stopEvent(ResetArea)
				verificaBoss()
				doSendMagicEffect({x = 33396, y = 32642, z = 6}, 10) -- efeito que vai aparece no monstro quando ele nasce, mesma posiçao onde nasce o boss
				doCreateMonster("Scarlett Etzel", {x = 33396, y = 32642, z = 6}) -- onde o boss nasce e nome do boss
				ResetArea = addEvent(function()
					removePlayersTime()
				end, 10 * 60 * 1000) -- tempo dentro da sala para ser kikado tem tera 10 minutos para matar o boss ou sera teleportado de volta
				return false
			end
		else
			doPlayerSendCancel(cid, "Wouldn't you like to go too?")
			doSendMagicEffect(topos,2)
		end

		return true
	end

end

 

Vlw, vou testar aqui

Link para o post
Compartilhar em outros sites
local config = {
	cooldown = 60 * 60 * 20, -- in seconds - (Make it 'seconds * minutes * hours' - its will be '60 * 60 * 20' for 20 hours) (player cooldown)
	cooldown_storage = 808856,
	duration = 10, -- time till reset, in minutes (lever cooldown)
	level_req = 8, -- minimum level to do quest
	min_players = 1, -- minimum players to join quest
	lever_id = 1945, -- id of lever before pulled
	pulled_id = 1946 -- id of lever after pulled
}

local player_positions = {
	[1] = {fromPos = Position(33395, 32662, 6), toPos = Position(33395, 32658, 6)},
	[2] = {fromPos = Position(33395, 32663, 6), toPos = Position(33395, 32658, 6)},
	[3] = {fromPos = Position(33395, 32663, 6), toPos = Position(33395, 32658, 6)},
	[4] = {fromPos = Position(33395, 32665, 6), toPos = Position(33395, 32658, 6)},
	[5] = {fromPos = Position(33394, 32662, 6), toPos = Position(33395, 32658, 6)}
}

local monsters = {
	[1] = {pos = Position(33396, 32642, 6), name = "scarlett etzel"}
}
local quest_range = {fromPos = Position(33386, 32639, 6), toPos = Position(33405, 32659, 6)} -- see image in thread for explanation

local exit_position = Position(33395, 32671, 6) -- Position completely outside the quest area

function doResetTheBossDukeKrule(position, cid_array)
	
	local tile = Tile(position)
	
	local item = tile and tile:getItemById(config.pulled_id)
	if not item then
		return
	end
	
	local monster_names = {}
	for key, value in pairs(monsters) do
		if not isInArray(monster_names, value.name) then
			monster_names[#monster_names + 1] = value.name
		end
	end
	
	for i = 1, #monsters do
		local creatures = Tile(monsters[i].pos):getCreatures()
		for key, creature in pairs(creatures) do
			if isInArray(monster_names, creature:getName()) then
				creature:remove()
			end
		end
	end
	
	for i = 1, #player_positions do
		local creatures = Tile(player_positions[i].toPos):getCreatures()
		for key, creature in pairs(creatures) do
			if isInArray(monster_names, creature:getName()) then
				creature:remove()
			end
		end
	end
	
	for key, cid in pairs(cid_array) do
		local participant = Player(cid)
		if participant and isInRange(participant:getPosition(), quest_range.fromPos, quest_range.toPos) then
			participant:teleportTo(exit_position)
			exit_position:sendMagicEffect(CONST_ME_TELEPORT)
		end
	end
	
	item:transform(config.lever_id)
end

local function removeBoss()
	local specs, spec = Game.getSpectators(Position(33396, 32649, 6), false, false, 10, 10, 10, 10)
	for j = 1, #specs do
		spec = specs[j]
		if spec:getName():lower() == 'scarlett etzel' then
			spec:remove()
		end
	end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	
	if player:getStorageValue(config.cooldown_storage) >= os.time() then
		player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "try tomorrow")
		return true
	end
	local spectators = Game.getSpectators(Position(33396, 32649, 6), false, false, 10, 10, 10, 10)
	for _, spectatorCreature in ipairs(spectators) do
		if spectatorCreature:isPlayer() then
			return player:sendCancelMessage("ja exitem jogadores dentro do evento.")
		end
	end
	local participants, pull_player = {}, false
	for i = 1, #player_positions do
		local fromPos = player_positions[i].fromPos
		local tile = Tile(fromPos)
		if not tile then
			print(">> ERROR: Annihilator tile does not exist for Position(" .. fromPos.x .. ", " .. fromPos.y .. ", " .. fromPos.z .. ").")
			return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
		end
		
		local creature = tile:getBottomCreature()
		if creature then
			local participant = creature:getPlayer()
			if not participant then
				return player:sendCancelMessage(participant:getName() .. " is not a valid participant.")
			end
			
			if participant:getLevel() < config.level_req then
				return player:sendCancelMessage(participant:getName() .. " is not the required level.")
			end
			
			if participant.uid == player.uid then
				pull_player = true
			end
			
			participants[#participants + 1] = {participant = participant, toPos = player_positions[i].toPos}
		end
	end
	
	if #participants < config.min_players then
		return player:sendCancelMessage("You do not have the required amount of participants.")
	end
	
	if not pull_player then
		return player:sendCancelMessage("You are in the wrong position.")
	end
	
	for i = 1, #monsters do
		local toPos = monsters[i].pos
		if not Tile(toPos) then
			print(">> ERROR: Annihilator tile does not exist for Position(" .. toPos.x .. ", " .. toPos.y .. ", " .. toPos.z .. ").")
			return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
		end
		removeBoss()
		Game.createMonster(monsters[i].name, monsters[i].pos, false, true)
	end
	
	local cid_array = {}
	for i = 1, #participants do
		participants[i].participant:teleportTo(participants[i].toPos)
		participants[i].toPos:sendMagicEffect(CONST_ME_TELEPORT)
		cid_array[#cid_array + 1] = participants[i].participant.uid
		player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have 10 minutes to kill and loot this boss. Otherwise you will lose that chance and will be kicked out.")
	end
	
	item:transform(config.pulled_id)
	player:setStorageValue(config.cooldown_storage, os.time() + config.cooldown)
	addEvent(doResetTheBossDukeKrule, config.duration * 60 * 1000, toPosition, cid_array)
	return true
end

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
4 horas atrás, Vodkart disse:

local config = {
	cooldown = 60 * 60 * 20, -- in seconds - (Make it 'seconds * minutes * hours' - its will be '60 * 60 * 20' for 20 hours) (player cooldown)
	cooldown_storage = 808856,
	duration = 10, -- time till reset, in minutes (lever cooldown)
	level_req = 8, -- minimum level to do quest
	min_players = 1, -- minimum players to join quest
	lever_id = 1945, -- id of lever before pulled
	pulled_id = 1946 -- id of lever after pulled
}

local player_positions = {
	[1] = {fromPos = Position(33395, 32662, 6), toPos = Position(33395, 32658, 6)},
	[2] = {fromPos = Position(33395, 32663, 6), toPos = Position(33395, 32658, 6)},
	[3] = {fromPos = Position(33395, 32663, 6), toPos = Position(33395, 32658, 6)},
	[4] = {fromPos = Position(33395, 32665, 6), toPos = Position(33395, 32658, 6)},
	[5] = {fromPos = Position(33394, 32662, 6), toPos = Position(33395, 32658, 6)}
}

local monsters = {
	[1] = {pos = Position(33396, 32642, 6), name = "scarlett etzel"}
}
local quest_range = {fromPos = Position(33386, 32639, 6), toPos = Position(33405, 32659, 6)} -- see image in thread for explanation

local exit_position = Position(33395, 32671, 6) -- Position completely outside the quest area

function doResetTheBossDukeKrule(position, cid_array)
	
	local tile = Tile(position)
	
	local item = tile and tile:getItemById(config.pulled_id)
	if not item then
		return
	end
	
	local monster_names = {}
	for key, value in pairs(monsters) do
		if not isInArray(monster_names, value.name) then
			monster_names[#monster_names + 1] = value.name
		end
	end
	
	for i = 1, #monsters do
		local creatures = Tile(monsters[i].pos):getCreatures()
		for key, creature in pairs(creatures) do
			if isInArray(monster_names, creature:getName()) then
				creature:remove()
			end
		end
	end
	
	for i = 1, #player_positions do
		local creatures = Tile(player_positions[i].toPos):getCreatures()
		for key, creature in pairs(creatures) do
			if isInArray(monster_names, creature:getName()) then
				creature:remove()
			end
		end
	end
	
	for key, cid in pairs(cid_array) do
		local participant = Player(cid)
		if participant and isInRange(participant:getPosition(), quest_range.fromPos, quest_range.toPos) then
			participant:teleportTo(exit_position)
			exit_position:sendMagicEffect(CONST_ME_TELEPORT)
		end
	end
	
	item:transform(config.lever_id)
end

local function removeBoss()
	local specs, spec = Game.getSpectators(Position(33396, 32649, 6), false, false, 10, 10, 10, 10)
	for j = 1, #specs do
		spec = specs[j]
		if spec:getName():lower() == 'scarlett etzel' then
			spec:remove()
		end
	end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	
	if player:getStorageValue(config.cooldown_storage) >= os.time() then
		player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "try tomorrow")
		return true
	end
	local spectators = Game.getSpectators(Position(33396, 32649, 6), false, false, 10, 10, 10, 10)
	for _, spectatorCreature in ipairs(spectators) do
		if spectatorCreature:isPlayer() then
			return player:sendCancelMessage("ja exitem jogadores dentro do evento.")
		end
	end
	local participants, pull_player = {}, false
	for i = 1, #player_positions do
		local fromPos = player_positions[i].fromPos
		local tile = Tile(fromPos)
		if not tile then
			print(">> ERROR: Annihilator tile does not exist for Position(" .. fromPos.x .. ", " .. fromPos.y .. ", " .. fromPos.z .. ").")
			return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
		end
		
		local creature = tile:getBottomCreature()
		if creature then
			local participant = creature:getPlayer()
			if not participant then
				return player:sendCancelMessage(participant:getName() .. " is not a valid participant.")
			end
			
			if participant:getLevel() < config.level_req then
				return player:sendCancelMessage(participant:getName() .. " is not the required level.")
			end
			
			if participant.uid == player.uid then
				pull_player = true
			end
			
			participants[#participants + 1] = {participant = participant, toPos = player_positions[i].toPos}
		end
	end
	
	if #participants < config.min_players then
		return player:sendCancelMessage("You do not have the required amount of participants.")
	end
	
	if not pull_player then
		return player:sendCancelMessage("You are in the wrong position.")
	end
	
	for i = 1, #monsters do
		local toPos = monsters[i].pos
		if not Tile(toPos) then
			print(">> ERROR: Annihilator tile does not exist for Position(" .. toPos.x .. ", " .. toPos.y .. ", " .. toPos.z .. ").")
			return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
		end
		removeBoss()
		Game.createMonster(monsters[i].name, monsters[i].pos, false, true)
	end
	
	local cid_array = {}
	for i = 1, #participants do
		participants[i].participant:teleportTo(participants[i].toPos)
		participants[i].toPos:sendMagicEffect(CONST_ME_TELEPORT)
		cid_array[#cid_array + 1] = participants[i].participant.uid
		player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have 10 minutes to kill and loot this boss. Otherwise you will lose that chance and will be kicked out.")
	end
	
	item:transform(config.pulled_id)
	player:setStorageValue(config.cooldown_storage, os.time() + config.cooldown)
	addEvent(doResetTheBossDukeKrule, config.duration * 60 * 1000, toPosition, cid_array)
	return true
end

 

vodka, testei esse seu aqui e funcionou o player nao consegui entrar quando tem alguem na sala..mais tbm n esta sendo chutado para fora depois dos 10 minutos

Link para o post
Compartilhar em outros sites
  • Solução
31 minutos atrás, leonardo gazim disse:

vodka, testei esse seu aqui e funcionou o player nao consegui entrar quando tem alguem na sala..mais tbm n esta sendo chutado para fora depois dos 10 minutos

 

achei que seu codigo ja fazia isso.

 

 

local config = {
	cooldown = 60 * 60 * 20, -- in seconds - (Make it 'seconds * minutes * hours' - its will be '60 * 60 * 20' for 20 hours) (player cooldown)
	cooldown_storage = 808856,
	storage_control = 78484,
	duration = 10, -- time till reset, in minutes (lever cooldown)
	level_req = 8, -- minimum level to do quest
	min_players = 1, -- minimum players to join quest
	lever_id = 1945, -- id of lever before pulled
	pulled_id = 1946 -- id of lever after pulled
}
local player_positions = {
	[1] = {fromPos = Position(33395, 32662, 6), toPos = Position(33395, 32658, 6)},
	[2] = {fromPos = Position(33395, 32663, 6), toPos = Position(33395, 32658, 6)},
	[3] = {fromPos = Position(33395, 32663, 6), toPos = Position(33395, 32658, 6)},
	[4] = {fromPos = Position(33395, 32665, 6), toPos = Position(33395, 32658, 6)},
	[5] = {fromPos = Position(33394, 32662, 6), toPos = Position(33395, 32658, 6)}
}
local monsters = {
	[1] = {pos = Position(33396, 32642, 6), name = "scarlett etzel"}
}
local quest_range = {fromPos = Position(33386, 32639, 6), toPos = Position(33405, 32659, 6)} -- see image in thread for explanation
local exit_position = Position(33395, 32671, 6) -- Position completely outside the quest area
function getPlayersInBossRoom()
	local spectators, t = Game.getSpectators(Position(33396, 32649, 6), false, false, 10, 10, 10, 10),{}
	for _, spectatorCreature in ipairs(spectators) do
		if spectatorCreature:isPlayer() then
			t[#t+1] = spectatorCreature
		end
	end
	return t
end
function doKickPlayerBoss(id)
	local players = getPlayersInBossRoom() 
	if #players == 0 then return true end
	if Game.getStorageValue(config.storage_control) == id then
			for _, cid in pairs(players) do
			       local participant = Player(cid)
			       participant:teleportTo(exit_position)
			       exit_position:sendMagicEffect(CONST_ME_TELEPORT)
				   participant:sendTextMessage(22,"voce nao matou o boss a tempo.")
			end
			Game.setStorageValue(config.storage_control, 0)
	end
end
function doResetTheBossDukeKrule(position, cid_array)
	
	local tile = Tile(position)
	
	local item = tile and tile:getItemById(config.pulled_id)
	if not item then
		return
	end
	
	local monster_names = {}
	for key, value in pairs(monsters) do
		if not isInArray(monster_names, value.name) then
			monster_names[#monster_names + 1] = value.name
		end
	end
	
	for i = 1, #monsters do
		local creatures = Tile(monsters[i].pos):getCreatures()
		for key, creature in pairs(creatures) do
			if isInArray(monster_names, creature:getName()) then
				creature:remove()
			end
		end
	end
	
	for i = 1, #player_positions do
		local creatures = Tile(player_positions[i].toPos):getCreatures()
		for key, creature in pairs(creatures) do
			if isInArray(monster_names, creature:getName()) then
				creature:remove()
			end
		end
	end
	
	for key, cid in pairs(cid_array) do
		local participant = Player(cid)
		if participant and isInRange(participant:getPosition(), quest_range.fromPos, quest_range.toPos) then
			participant:teleportTo(exit_position)
			exit_position:sendMagicEffect(CONST_ME_TELEPORT)
		end
	end
	
	item:transform(config.lever_id)
end

local function removeBoss()
	local specs, spec = Game.getSpectators(Position(33396, 32649, 6), false, false, 10, 10, 10, 10)
	for j = 1, #specs do
		spec = specs[j]
		if spec:getName():lower() == 'scarlett etzel' then
			spec:remove()
		end
	end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)	
	if player:getStorageValue(config.cooldown_storage) >= os.time() then
		player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "try tomorrow")
		return true
	end
		if #getPlayersInBossRoom() > 0 then
			return player:sendCancelMessage("ja exitem jogadores dentro do evento.")
		end
	local participants, pull_player = {}, false
	for i = 1, #player_positions do
		local fromPos = player_positions[i].fromPos
		local tile = Tile(fromPos)
		if not tile then
			print(">> ERROR: Annihilator tile does not exist for Position(" .. fromPos.x .. ", " .. fromPos.y .. ", " .. fromPos.z .. ").")
			return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
		end
		local creature = tile:getBottomCreature()
		if creature then
			local participant = creature:getPlayer()
			if not participant then
				return player:sendCancelMessage(participant:getName() .. " is not a valid participant.")
			end
			if participant:getLevel() < config.level_req then
				return player:sendCancelMessage(participant:getName() .. " is not the required level.")
			end
			if participant.uid == player.uid then
				pull_player = true
			end			
			participants[#participants + 1] = {participant = participant, toPos = player_positions[i].toPos}
		end
	end	
	if #participants < config.min_players then
		return player:sendCancelMessage("You do not have the required amount of participants.")
	end	
	if not pull_player then
		return player:sendCancelMessage("You are in the wrong position.")
	end	
	for i = 1, #monsters do
		local toPos = monsters[i].pos
		if not Tile(toPos) then
			print(">> ERROR: Annihilator tile does not exist for Position(" .. toPos.x .. ", " .. toPos.y .. ", " .. toPos.z .. ").")
			return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
		end
		removeBoss()
		Game.createMonster(monsters[i].name, monsters[i].pos, false, true)
	end	
	local cid_array = {}
	for i = 1, #participants do
		participants[i].participant:teleportTo(participants[i].toPos)
		participants[i].toPos:sendMagicEffect(CONST_ME_TELEPORT)
		cid_array[#cid_array + 1] = participants[i].participant.uid
		player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have 10 minutes to kill and loot this boss. Otherwise you will lose that chance and will be kicked out.")
	end	
	item:transform(config.pulled_id)
	player:setStorageValue(config.cooldown_storage, os.time() + config.cooldown)
	local r = math.random(1, 9999)
	Game.setStorageValue(config.storage_control, r)
	addEvent(doKickPlayerBoss, config.duration * 60 * 1000, r)
    addEvent(doResetTheBossDukeKrule, config.duration * 60 * 1000, toPosition, cid_array)	
	return true
end

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
7 horas atrás, leonardo gazim disse:

vodka, testei esse seu aqui e funcionou o player nao consegui entrar quando tem alguem na sala..mais tbm n esta sendo chutado para fora depois dos 10 minutos

chego testar oque eu envie ?

Link para o post
Compartilhar em outros sites
9 horas atrás, Kenshiin disse:

chego testar oque eu envie ?

ainda nao,como nao estava com muito tempo para estar fazendo as mudanças dos locais e nomes testei so o do vodka que ja estava td no jeito,mais logo vou testar o seu tbm 
 

na vdd acho que o seu tbm esta ne kkk, acho que vi errado mais amanha testo sem falta

Editado por leonardo gazim (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

kenshiin Testei aqui, quando uso a alavanca fala que eu nao posso usar o objeto, mesmo trocando o id da action para o que esta na alavanca no map

Link para o post
Compartilhar em outros sites
4 horas atrás, leonardo gazim disse:

kenshiin Testei aqui, quando uso a alavanca fala que eu nao posso usar o objeto, mesmo trocando o id da action para o que esta na alavanca no map

voce pode ter feito algo errado, porqe eu uso esse script, no servidor e nao tem erro nenhum confere tudo

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo