Ir para conteúdo
  • 0
lepiigor

Scripting Revscript Lever Boss Con Timer y Storage

Pergunta

lepiigor    16
lepiigor

Antes de fazer a sua pergunta, tenha certeza de ter lido as regras da seção e o guia abaixo:

https://forums.otserv.com.br/index.php?/forums/topic/168583-regras-da-seção/

https://forums.otserv.com.br/index.php?/forums/topic/165121-como-fazer-uma-pergunta-ou-o-grande-guia-do-usuário-com-dúvidas/

Obs: não delete esse formulário pré-definido, preencha-o corretamente para postar o seu tópico!

Descreva em algumas palavras a base utilizada. (Nome do servidor / Nome do cliente / Nome do website / etc.).

Base:

OTServBR-Global

Qual é a sua pergunta?

Olá Tentei adicionar Storage para adicionar por exemplo 4 horas entre cada alavanca, mas não funciona, estou tentando aprender usando as funções dos scripts de antes, mas não consigo, alguém poderia me dizer como eu pode adicionar tempo e armazenamento a ele, por favor?

function: daily nao funciona true / false .

 

Obrigado

 

Você tem o código disponível? Se tiver poste-o na caixa de código que está dentro do spoiler abaixo:

Spoiler

 local setting = {
	-- At what level can do the quest?
	requiredLevel = 100,
	-- Can it be done daily? true = yes, false = no
	daily = false,
	-- Do not change from here down
	centerDemonRoomPosition = {x = 31272, y = 32360, z = 9},
	demonsPositions = {
		{x = 31272, y = 32361, z = 9},
	},
	playersPositions = {
		{fromPos = {x = 31290, y = 32351, z = 6}, toPos = {x = 31272, y = 32364, z = 9}},
		{fromPos = {x = 31290, y = 32350, z = 6}, toPos = {x = 31272, y = 32365, z = 9}},
		{fromPos = {x = 31290, y = 32349, z = 6}, toPos = {x = 31272, y = 32366, z = 9}},
		{fromPos = {x = 31290, y = 32348, z = 6}, toPos = {x = 31272, y = 32367, z = 9}},
	}
}

local lever = Action()

function lever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
	if item.itemid == 1945 then
		-- Checks if there are still players inside the room, if so, return true
		if Position.hasPlayer(setting.centerDemonRoomPosition, 4, 4) then
			player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room.")
			return true
		end

		-- Create monsters
		for i = 1, #setting.demonsPositions do
			Game.createMonster("Horror Sight", setting.demonsPositions[i])
		end

		-- Get players from the tiles "playersPositions" and teleport to the demons room if all of the above requirements are met
		for i = 1, #setting.playersPositions do
			local creature = Tile(setting.playersPositions[i].fromPos):getTopCreature()
			if creature and creature:isPlayer() then
				creature:teleportTo(setting.playersPositions[i].toPos)
				creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
			else
				return false
			end
		end
		item:transform(1946)
	elseif item.itemid == 1946 then
		-- If it has "daily = true" then it will execute this function
		if setting.daily then
			player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
			return true
		end
		-- Not be able to push the lever back if someone is still inside the monsters room
		if Position.hasPlayer(setting.centerDemonRoomPosition, 4, 4) then
			player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room.")
			return true
		end
		-- Removes all monsters so that the next team can enter
		if Position.removeMonster(setting.centerDemonRoomPosition, 4, 4) then
			return true
		end
		item:transform(1945)
	end
	return true
end

lever:uid(42505)
lever:register()

 

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, anexe-a dentro do spoiler abaixo:

Spoiler

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

2 respostass a esta questão

Recommended Posts

  • 0
lepiigor    16
lepiigor

Sim finalemente teste este e me faltava local theUnwelcome = Action () , por isso nao funcionaba ><

 

local config = {
    cooldown = 60 * 60 * 4, -- in seconds - (Make it 'seconds * minutes * hours' - its will be '60 * 60 * 20' for 20 hours) (player cooldown)
    cooldown_storage = 808868,
    duration = 1, -- time till reset, in minutes (lever cooldown)
    level_req = 250, -- 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(33736, 31537, 14), toPos = Position(33707, 31534, 14)},
    [2] = {fromPos = Position(33737, 31537, 14), toPos = Position(33708, 31534, 14)},
    [3] = {fromPos = Position(33738, 31537, 14), toPos = Position(33709, 31534, 14)},
    [4] = {fromPos = Position(33739, 31537, 14), toPos = Position(33710, 31534, 14)}
}

local monsters = {
    [1] = {pos = Position(33708, 31538, 14), name = "The Unwelcome"}
}
local quest_range = {fromPos = Position(33704, 31532, 14), toPos = Position(33713, 31546, 14)} -- see image in thread for explanation

local exit_position = Position(33709, 31547, 14) -- Position completely outside the quest area

local theUnwelcome = 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)
    for j = 1, #specs do
        spec = specs[j]
        if spec:getName():lower() == 'The Unwelcome' then
            spec:remove()
        end
    end
end

function theUnwelcome.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(config.cooldown_storage) >= os.time() then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Try Again in 4 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: Soul Quest 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: Soul Quest 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 30 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 * 2000,  toPosition, cid_array)
    return true
end

theUnwelcome:uid(42606)
theUnwelcome:register()

 

 

Editado por lepiigor

Compartilhar este post


Link para o post
Compartilhar em outros sites
Visitante
Este tópico está impedido de receber novos posts.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×