RevScript Boss Lever 1-4 Players

Alex

Miembro del equipo
Webdesigner
LV
58
 
Awards
38
Hola a todos,

Aquí les comparto el RevScript Boss Lever, si deseáis cambiar un script de acceso a una quest para un acceso de 1 a 4 players ( o mas ) podréis utilizar este, lo que hace, es que si solamente hay 1 Player podrá entrar en la zona , si hay 2, 3, 4, 10 también !

Hay que tomar nota que funciona con un sistema de cooldown de palanca, que es muy interesante para algunas zonas, para evitar el Flood de personas dentro, pero también podréis crear un Monstruo/Boss que aparezca al activar la palanca ( en donde ? Donde queráis en la zona en donde llegara el player, pero también lo podréis quitar ).

Vamos alla:

cooldown : Tiempo para poder hacerlo de nuevo, en este caso del ejemplo son 24 Horas
cooldown storage: la storage del cooldown, un numero que no esté cogido en vuestro servidor
duration: duracion en la cual la palanca se resetea
level req: Nivel minimo requerido
min players: numero de players minimo
lever id: la ID de la palanca
pulled id: la ID de la palanca activada

Código:
local config = {
    cooldown = 60 * 60 * 24, -- in seconds - (Make it 'seconds * minutes * hours' - its will be '60 * 60 * 20' for 20 hours) (player cooldown)
    cooldown_storage = 811381,
    duration = 30, -- time till reset, in minutes (lever cooldown)
    level_req = 100, -- 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(32215, 32289, 6), toPos = Position(31746, 31889, 7)}
}

local monsters = {
    [1] = {pos = Position(31751, 31884, 11), name = "Spider King"},
    [2] = {pos = Position(31793, 31885, 11), name = "Abyssal Hydra"},
    [3] = {pos = Position(31834, 31886, 11), name = "Purple Dragon"}
}
local quest_range = {fromPos = Position(31727, 31879, 11), toPos = Position(31836, 31891, 11)}

local exit_position = Position(32215, 32268, 6) -- Position completely outside the quest area

local firstDungeon = Action()

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(33919, 31646, 8), false, false, 18, 18, 18, 18) -- Do not change
    for j = 1, #specs do
        spec = specs[j]
        if spec:getName():lower() == 'Goshnar Hatred' then
            spec:remove()
        end
    end
end

function firstDungeon.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(config.cooldown_storage) >= os.time() then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Try Again in 24 Hours.")
        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: First Dungeon 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 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: First Dungeon 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 60 minutes to kill and loot all bosses. 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 * 60000,  toPosition, cid_array)
    return true
end

firstDungeon:uid(41392)
firstDungeon:register()

Creditos a @marcuz por haber corregido la funcion siguiente que daba un error usando un summon en la consola:

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

En este caso hemos cogido el Script que hemos utilizado en el servidor Hellgrave RPG, que consiste en activar una palanca para acceder a un dungeon.
Puede ser utilizado para cualquier palanca en el juego, ferumbras, heart , anihilator, cualquiera.

Tomar nota de modificar la palabra "firstDungeon", si vais a utilizar varias veces este script para diferentes quests. ( La palabra esta inscrita 4 veces en el script, cambiar las 4 por el mismo nombre distinto cada vez. )
También tomar nota en cambiar el "41392" que es la UniqueID que pondréis en la Palanca en el remeres map editor.

Si solamente vais a cambiar el script de uno existente, copiar las informaciones del existente en este script, borrar el anterior y añadir este nuevo, resetear el servidor.
 
Última edición:
Y

yosoyjuanx

Invitado
Hola el script es funcional pero tengo un problema es que si hay un jugador matando un boss otro jugador puede entrar sabes como puedo solucionar esto?
 
Y

yosoyjuanx

Invitado
Código:
local config = {
    cooldown = 60 * 60 * 24, -- in seconds - (Make it 'seconds * minutes * hours' - its will be '60 * 60 * 20' for 20 hours) (player cooldown)
    cooldown_storage = 811382,
    duration = 15, -- time till reset, in minutes (lever cooldown)
    level_req = 200, -- minimum level to do quest
    min_players = 1, -- minimum players to join quest
    lever_id = 9825, -- id of lever before pulled
    pulled_id = 9826, -- id of lever after pulled
}

local player_positions = {
    [1] = {fromPos = Position(33455, 31493, 13), toPos = Position(33456, 31479, 13)},
    [2] = {fromPos = Position(33456, 31493, 13), toPos = Position(33456, 31479, 13)},
    [3] = {fromPos = Position(33457, 31493, 13), toPos = Position(33456, 31479, 13)},
    [4] = {fromPos = Position(33458, 31493, 13), toPos = Position(33456, 31479, 13)},
    [5] = {fromPos = Position(33459, 31493, 13), toPos = Position(33456, 31479, 13)}
}

local monsters = {
    [1] = {pos = Position(33456, 31472, 13), name = "Duke Krule"}
}
local quest_range = {fromPos = Position(33453, 31464, 13), toPos = Position(33459, 31481, 13)}

local exit_position = Position(33456, 31496, 13) -- Position completely outside the quest area

local firstDungeon = Action()

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(33919, 31646, 8), false, false, 18, 18, 18, 18) -- Do not change
    for j = 1, #specs do
        spec = specs[j]
        if spec:getName():lower() == 'Goshnar Hatred' then
            spec:remove()
        end
    end
end

function firstDungeon.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(config.cooldown_storage) >= os.time() then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Try Again in 24 Hours.")
        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: First Dungeon 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: First Dungeon 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 15 minutes to kill and loot all bosses. 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 * 15 * 15000,  toPosition, cid_array)
    return true
end

firstDungeon:uid(41392)
firstDungeon:register()

Te posteo el codigo
 

Alex

Miembro del equipo
Webdesigner
LV
58
 
Awards
38
Código:
local config = {
    cooldown = 60 * 60 * 24, -- in seconds - (Make it 'seconds * minutes * hours' - its will be '60 * 60 * 20' for 20 hours) (player cooldown)
    cooldown_storage = 811382,
    duration = 15, -- time till reset, in minutes (lever cooldown)
    level_req = 200, -- minimum level to do quest
    min_players = 1, -- minimum players to join quest
    lever_id = 9825, -- id of lever before pulled
    pulled_id = 9826, -- id of lever after pulled
}

local player_positions = {
    [1] = {fromPos = Position(33455, 31493, 13), toPos = Position(33456, 31479, 13)},
    [2] = {fromPos = Position(33456, 31493, 13), toPos = Position(33456, 31479, 13)},
    [3] = {fromPos = Position(33457, 31493, 13), toPos = Position(33456, 31479, 13)},
    [4] = {fromPos = Position(33458, 31493, 13), toPos = Position(33456, 31479, 13)},
    [5] = {fromPos = Position(33459, 31493, 13), toPos = Position(33456, 31479, 13)}
}

local monsters = {
    [1] = {pos = Position(33456, 31472, 13), name = "Duke Krule"}
}
local quest_range = {fromPos = Position(33453, 31464, 13), toPos = Position(33459, 31481, 13)}

local exit_position = Position(33456, 31496, 13) -- Position completely outside the quest area

local firstDungeon = Action()

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(33919, 31646, 8), false, false, 18, 18, 18, 18) -- Do not change
    for j = 1, #specs do
        spec = specs[j]
        if spec:getName():lower() == 'Goshnar Hatred' then
            spec:remove()
        end
    end
end

function firstDungeon.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(config.cooldown_storage) >= os.time() then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Try Again in 24 Hours.")
        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: First Dungeon 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: First Dungeon 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 15 minutes to kill and loot all bosses. 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 * 15 * 15000,  toPosition, cid_array)
    return true
end

firstDungeon:uid(41392)
firstDungeon:register()

Te posteo el codigo
Hola,

La tercera línea dice cooldown 15 , es el cooldown de la palanca , si en 15 minutos no ha matado el monstruo , otro player puede entrar, en este caso aumentalo.
Y si es muy solicitado, en este caso lo que puede hacer , es agregar 2 acessos al Boss en la misma sala, si uno está en una palanca , el otro podrá ir hacia la otra palanca. ( En este caso copias y pegas el mapa al lado para la segunda palanca ).
 
Arriba