Ir para conteúdo
  • 0
Famosiin

Scripting [ERROR] Conversão de script para RevScript

Pergunta

Famosiin    0
Famosiin

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: 

Evento Monter Hunt TFS 1.X

https://************.com/forums/topic/101143-evento-monster-hunt-tfs-1x/

 

Uso o https://github.com/opentibiabr/otservbr-global.git como base para meu servidor

 

Qual é a sua pergunta?

Fala pessoal beleza? peguei um script de evento em um outro fórum, consegui converter para revscript e esta funcionando quase 100%, eu estou com um problema no contador de monstros mortos que seria meu moveevent, vou postar o script abaixo para que deem uma olhada.

 

 

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

Spoiler

script.xml
local monstereventglobal = GlobalEvent("monstereventglobal")

function monstereventglobal.onThink(interval)
	if MONSTER_HUNT.days[os.date("%A")] then
		local hrs = tostring(os.date("%X")):sub(1, 5)
		if isInArray(MONSTER_HUNT.days[os.date("%A")], hrs) then
			MONSTER_HUNT:initEvent()
		end
	end
	return true
end

function onTime(interval)
	MONSTER_HUNT:endEvent()
	return true
end

monstereventglobal:interval(60000) -- will be executed every 1000ms
monstereventglobal:register()

local monstereventcreature = CreatureEvent("monsterHunt")
function monstereventcreature.onKill(player, target)

	if Game.getStorageValue(MONSTER_HUNT.storages.monster) == nil then
		return true
	end

	if not player or not target then
		return true
	end

	if player:getStorageValue(MONSTER_HUNT.storages.player) == -1 then
		player:setStorageValue(MONSTER_HUNT.storages.player, 0)
	end

	if target:isMonster() and target:getName():lower() == (MONSTER_HUNT.list[Game.getStorageValue(MONSTER_HUNT.storages.monster)]):lower() then
		player:setStorageValue(MONSTER_HUNT.storages.player, player:getStorageValue(MONSTER_HUNT.storages.player) + 1)
		player:sendTextMessage(MESSAGE_STATUS_BLUE_LIGHT, MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.kill:format(player:getStorageValue(MONSTER_HUNT.storages.player), target:getName()))
		table.insert(MONSTER_HUNT.players, {player:getId(), player:getStorageValue(MONSTER_HUNT.storages.player)})
	end

	return true
end

monstereventcreature:type("kill")
monstereventcreature:register()

O globalevent desta parte funciona com o anuncio do inicio do evento, porem na parte de fazer a contagem do monstros mortos não esta sendo exibida para o player

lib.xml

Spoiler

 



MONSTER_HUNT = {
    list = {"Falcon Knight", "Rotworm", "Cyclops"},
    days = {
        ["Sunday"] = {"09:49"},
        ["Monday"] = {"09:49"},
        ["Tuesday"] = {"09:49"},
        ["Tuesday"] = {"19:35"},
        ["Wednesday"] = {"09:49"},
        ["Thursday"] = {"09:49"},
        ["Friday"] = {"09:49"},
        ["Saturday"] = {"09:49"},
    },
    messages = {
        prefix = "[Monster Hunt] ",
        warnInit = "O evento ira comecar em %d minuto%s. Seu objetivo sera matar a maior quantidade de monstros escolhidos pelo sistema.",
        init = "O monstro escolhido pelo sistema foi %s. Voce tem 1 hora para matar a maior quantidade desse monstro.",
        warnEnd = "Faltam %d minuto%s para acabar o evento. Se apressem!",
        final = "O jogador %s foi o ganhador do evento! Parabens.",
        noWinner = "Nao houve ganhadores no evento.",
        reward = "Voce recebeu o seu premio no mailbox!",
        kill = "Voce ja matou {%d} %s do evento.",
    },
    rewards = {
        {id = 2160, count = 100},
    },
    storages = {
        monster = 891641,
        player = 891642,
    },
    players = {},
}

function MONSTER_HUNT:initEvent()
    Game.setStorageValue(MONSTER_HUNT.storages.monster, 0)
    Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnInit:format(5, "s"))
    addEvent(function()
        Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnInit:format(3, "s"))
    --end, 2 * 60 * 1000)
    end, 2 * 60 * 1000)
    addEvent(function()
        Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnInit:format(1, ""))
    --end, 4 * 60 * 1000)
    end, 4 * 60 * 1000)
    addEvent(function()
        local rand = math.random(#MONSTER_HUNT.list)
        Game.setStorageValue(MONSTER_HUNT.storages.monster, rand)
        Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.init:format(MONSTER_HUNT.list[rand]))
    --end, 5 * 60 * 1000)
    end, 5 * 60 * 1000)
    return true
end

function MONSTER_HUNT:endEvent()
    Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnEnd:format(5, "s"))
    addEvent(function()
        Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnEnd:format(3, "s"))
    end, 2 * 60 * 1000)
    addEvent(function()
        Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnEnd:format(1, ""))
    end, 4 * 60 * 1000)
    addEvent(function()
        if #MONSTER_HUNT.players == nil then
            Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.noWinner)
            return
        end
        table.sort(MONSTER_HUNT.players, function(a,b) return a[2] > b[2] end)
        local player = Player(MONSTER_HUNT.players[1][1])
        if player then
            Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.final:format(player:getName()))
            player:setStorageValue(MONSTER_HUNT.storages.player, -1)
            for c, d in ipairs(MONSTER_HUNT.rewards) do
                local item = Game.createItem(d.id, d.count)
                player:addItemEx(item)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.reward)
                player:getPosition():sendMagicEffect(30)
            end
        --[[ Função exclusiva (ignore)
        else
            local player = Player(MONSTER_HUNT.players[1][1], true)

            if not player then
                return false
            end

            Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.final:format(player:getName()))
            player:setStorageValue(MONSTER_HUNT.storages.player, -1)
            for c, d in ipairs(MONSTER_HUNT.rewards) do
                local item = Game.createItem(d.id, d.count)
                player:getInbox():addItemEx(item, INDEX_WHEREEVER, FLAG_NOLIMIT)
            end
            player:delete()
        --]]
        end
        for a, b in pairs(MONSTER_HUNT.players) do
            local player = Player(b[1])
            if player then
                player:setStorageValue(MONSTER_HUNT.storages.player, 0)
                MONSTER_HUNT.players[a] = nil
          --[[ Função exclusiva (ignore)
            else
                player = Player(b[1], true)
                player:setStorageValue(MONSTER_HUNT.storages.player, 0)
                MONSTER_HUNT.players[a] = nil
                player:delete()
          --]]
            end
        end
        Game.setStorageValue(MONSTER_HUNT.storages.monster, -1)
    end, 5 * 60 * 1000)
    return true
end

 


 

 

 

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

Spoiler

 

 

Editado por Famosiin
servidor base

Compartilhar este post


Link para o post
Compartilhar em outros sites

2 respostass a esta questão

Recommended Posts

  • 0
Majesty    1755
Majesty

Script:

Spoiler

local monsterEventGlobal = GlobalEvent("MonsterEventGlobal")

function monsterEventGlobal.onThink(interval)
	if MONSTER_HUNT.days[os.date("%A")] then
		local hrs = tostring(os.date("%X")):sub(1, 5)
		if isInArray(MONSTER_HUNT.days[os.date("%A")], hrs) then
			MONSTER_HUNT:initEvent()
		end
	end
	return true
end

function onTime(interval)
	MONSTER_HUNT:endEvent()
	return true
end

monsterEventGlobal:interval(60000) -- will be executed every 1000ms
monsterEventGlobal:register()

local monsterEventCreature = CreatureEvent("MonsterHunt")
function monsterEventCreature.onKill(player, target)

	if Game.getStorageValue(MONSTER_HUNT.storages.monster) == nil then
		return true
	end

	if not player or not target then
		return true
	end

	if player:getStorageValue(MONSTER_HUNT.storages.player) == -1 then
		player:setStorageValue(MONSTER_HUNT.storages.player, 0)
	end

	if target:isMonster() and target:getName():lower() == (MONSTER_HUNT.list[Game.getStorageValue(MONSTER_HUNT.storages.monster)]):lower() then
		player:setStorageValue(MONSTER_HUNT.storages.player, player:getStorageValue(MONSTER_HUNT.storages.player) + 1)
		player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.kill:format(player:getStorageValue(MONSTER_HUNT.storages.player), target:getName()))
		table.insert(MONSTER_HUNT.players, {player:getId(), player:getStorageValue(MONSTER_HUNT.storages.player)})
	end

	return true
end

monsterEventCreature:type("kill")
monsterEventCreature:register()

 

Lib:

Spoiler

MONSTER_HUNT = {
    list = {"Falcon Knight", "Rotworm", "Cyclops"},
    days = {
        ["Sunday"] = {"09:49"},
        ["Monday"] = {"09:49"},
        ["Tuesday"] = {"09:49"},
        ["Tuesday"] = {"19:35"},
        ["Wednesday"] = {"09:49"},
        ["Thursday"] = {"09:49"},
        ["Friday"] = {"09:49"},
        ["Saturday"] = {"09:49"},
    },
    messages = {
        prefix = "[Monster Hunt] ",
        warnInit = "O evento ira comecar em %d minuto%s. Seu objetivo sera matar a maior quantidade de monstros escolhidos pelo sistema.",
        init = "O monstro escolhido pelo sistema foi %s. Voce tem 1 hora para matar a maior quantidade desse monstro.",
        warnEnd = "Faltam %d minuto%s para acabar o evento. Se apressem!",
        final = "O jogador %s foi o ganhador do evento! Parabens.",
        noWinner = "Nao houve ganhadores no evento.",
        reward = "Voce recebeu o seu premio no mailbox!",
        kill = "Voce ja matou %d %s do evento.",
    },
    rewards = {
        {id = 2160, count = 100},
    },
    storages = {
        monster = 891641,
        player = 891642,
    },
    players = {},
}

function MONSTER_HUNT:initEvent()
    Game.setStorageValue(MONSTER_HUNT.storages.monster, 0)
    Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnInit:format(5, "s"))
    addEvent(function()
        Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnInit:format(3, "s"))
    --end, 2 * 60 * 1000)
    end, 2 * 60 * 1000)
    addEvent(function()
        Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnInit:format(1, ""))
    --end, 4 * 60 * 1000)
    end, 4 * 60 * 1000)
    addEvent(function()
        local rand = math.random(#MONSTER_HUNT.list)
        Game.setStorageValue(MONSTER_HUNT.storages.monster, rand)
        Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.init:format(MONSTER_HUNT.list[rand]))
    --end, 5 * 60 * 1000)
    end, 5 * 60 * 1000)
    return true
end

function MONSTER_HUNT:endEvent()
    Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnEnd:format(5, "s"))
    addEvent(function()
        Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnEnd:format(3, "s"))
    end, 2 * 60 * 1000)
    addEvent(function()
        Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnEnd:format(1, ""))
    end, 4 * 60 * 1000)
    addEvent(function()
        if #MONSTER_HUNT.players == nil then
            Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.noWinner)
            return
        end
        table.sort(MONSTER_HUNT.players, function(a,b) return a[2] > b[2] end)
        local player = Player(MONSTER_HUNT.players[1][1])
        if player then
            Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.final:format(player:getName()))
            player:setStorageValue(MONSTER_HUNT.storages.player, -1)
            for c, d in ipairs(MONSTER_HUNT.rewards) do
                local item = Game.createItem(d.id, d.count)
                player:addItemEx(item)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.reward)
                player:getPosition():sendMagicEffect(30)
            end
        --[[ Função exclusiva (ignore)
        else
            local player = Player(MONSTER_HUNT.players[1][1], true)

            if not player then
                return false
            end

            Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.final:format(player:getName()))
            player:setStorageValue(MONSTER_HUNT.storages.player, -1)
            for c, d in ipairs(MONSTER_HUNT.rewards) do
                local item = Game.createItem(d.id, d.count)
                player:getInbox():addItemEx(item, INDEX_WHEREEVER, FLAG_NOLIMIT)
            end
            player:delete()
        --]]
        end
        for a, b in pairs(MONSTER_HUNT.players) do
            local player = Player(b[1])
            if player then
                player:setStorageValue(MONSTER_HUNT.storages.player, 0)
                MONSTER_HUNT.players[a] = nil
          --[[ Função exclusiva (ignore)
            else
                player = Player(b[1], true)
                player:setStorageValue(MONSTER_HUNT.storages.player, 0)
                MONSTER_HUNT.players[a] = nil
                player:delete()
          --]]
            end
        end
        Game.setStorageValue(MONSTER_HUNT.storages.monster, -1)
    end, 5 * 60 * 1000)
    return true
end

 

Estão com as correções postadas pelo @Movie.

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
Movie    5
Movie

Muda essa linha aqui:

player:sendTextMessage(MESSAGE_STATUS_BLUE_LIGHT, MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.kill:format(player:getStorageValue(MONSTER_HUNT.storages.player), target:getName()))

por essa

player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.kill:format(player:getStorageValue(MONSTER_HUNT.storages.player), target:getName()))

e na lib, mude a mensagem de

kill = "Voce ja matou {%d} %s do evento.",

para

kill = "Voce ja matou %d %s do evento.",

 

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.

×