Ir para conteúdo

[GlobalEvents]Raids Automáticas


Posts Recomendados

Galera não encontrei um tutorial no fórum com esse script, mais caso haja por favor moderadores remova o tópico!

Script útil a todos:

 

TFS 0.4 e OTX

 

Abra data/globalevents/globalevents.xml adicione a seguinte tag:

<globalevent name="raids" interval="60000" event="script" value="raid.lua"/>

Na pasta data/globalevents/scripts crie um arquivo .lua com o nome raid.lua adicione o seguinte code dentro do arquivo:

--[[
- hour should be exact SERVER hour
- to do the raid at clock 00 minutes 00
- to do the raid at exaxt date use type "exact"
- to do the raid weekly use type "weekly"
- days names are used only for weekly type and should be
- "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"
- also should be inside a array -> {}
]]

local raids =
    {
        [1] =
            {
                name = 'Morgaroth',
                type = 'exact',
                date = {day = 15, month = 08},
                hour = 16,
                minu = 27
            },
        [2] =
            {
                name = 'Zulazza the Corruptor',
                type = 'weekly',
                days = {'monday'},
                hour = 20,
                minu = 00
            },
        [3] =
            {
                name = 'RatsThais',
                type = 'exact',
                date = {day = 31, month = 07},
                hour = 03,
                minu = 00
            },
        [4] =
            {
                name = 'OrcsThais',
                type = 'exact',
                date = {day = 03, month = 08},
                hour = 17,
                minu = 00
            },
        [5] =
            {
                name = 'Barbarian',
                type = 'exact',
                date = {day = 05, month = 08},
                hour = 18,
                minu = 00
            },
        [6] =
            {
                name = 'Demodras',
                type = 'exact',
                date = {day = 07, month = 08},
                hour = 19,
                minu = 00
            },
        [7] =
            {
                name = 'Elfos',
                type = 'exact',
                date = {day = 09, month = 08},
                hour = 20,
                minu = 00
            },
        [8] =
            {
                name = 'Ferumbras',
                type = 'exact',
                date = {day = 11, month = 08},
                hour = 21,
                minu = 00
            },
        [9] =
            {
                name = 'Ghazbaran',
                type = 'exact',
                date = {day = 13, month = 08},
                hour = 22,
                minu = 00
            },
        [10] =
            {
                name = 'Horned Fox',
                type = 'exact',
                date = {day = 17, month = 08},
                hour = 23,
                minu = 00
            },
        [11] =
            {
                name = 'Necropharus',
                type = 'exact',
                date = {day = 19, month = 08},
                hour = 00,
                minu = 00
            },
        [12] =
            {
                name = 'Nomads',
                type = 'exact',
                date = {day = 21, month = 08},
                hour = 01,
                minu = 00
            },
        [13] =
            {
                name = 'Orshabaal',
                type = 'exact',
                date = {day = 23, month = 08},
                hour = 14,
                minu = 00
            },
        [14] =
            {
                name = 'Pirates',
                type = 'exact',
                date = {day = 25, month = 08},
                hour = 15,
                minu = 00
            },
        [15] =
            {
                name = 'Quaras',
                type = 'exact',
                date = {day = 27, month = 08},
                hour = 16,
                minu = 00
            },
        [16] =
            {
                name = 'Scarabs',
                type = 'exact',
                date = {day = 29, month = 08},
                hour = 17,
                minu = 00
            },
        [17] =
            {
                name = 'Old Widow',
                type = 'exact',
                date = {day = 31, month = 08},
                hour = 18,
                minu = 00
            },
        [18] =
            {
                name = 'Undead Army',
                type = 'exact',
                date = {day = 02, month = 09},
                hour = 19,
                minu = 00
            },
        [19] =
            {
                name = 'Undead Darashia',
                type = 'exact',
                date = {day = 04, month = 09},
                hour = 20,
                minu = 00
            },
        [20] =
            {
                name = 'Sir Valorcrest',
                type = 'weekly',
                days = {'monday'},
                hour = 20,
                minu = 00
            },
        [21] =
            {
                name = 'Zevelong Duskbringer',
                type = 'weekly',
                days = {'tuesday'},
                hour = 20,
                minu = 00
            },
        [22] =
            {
                name = 'Diblis The Fair',
                type = 'weekly',
                days = {'thursday'},
                hour = 20,
                minu = 00
            },
        [23] =
            {
                name = 'Arachir the Ancient One',
                type = 'weekly',
                days = {'saturday'},
                hour = 20,
                minu = 00
            },
        [24] =
            {
                name = 'Halloween Hare',
                type = 'exact',
                date = {day = 31, month = 10},
                hour = 16,
                minu = 00
            }    
    }
    
local last_execsutes = {}

function onThink(interval, lastExecution, thinkInterval)
    local static_time = os.time()
    for k, raid in ipairs(raids) do
        if (raid.type == 'weekly') then
            local day = os.date("%A", static_time):lower()
            if isInArray(raid.days, day) then
                local hour = tonumber(os.date("%H", static_time))
                if (raid.hour == hour) then
                    local minute = tonumber(os.date("%M", static_time))
                    if (raid.minu == minute) then
                        local day_number = tonumber(os.date("%d", static_time))
                        if (last_execsutes[k] ~= day_number) then
                            last_execsutes[k] = day_number
                            doExecuteRaid(raid.name)
                        end
                    end
                end
            end
        elseif (raid.type == 'exact') then
            local month = tonumber(os.date("%m", static_time))
            if (raid.date.month == month) then
                local day = tonumber(os.date("%d", static_time))
                if (raid.date.day == day) then
                    local hour = tonumber(os.date("%H", static_time))
                    if (raid.hour == hour) then
                        local minute = tonumber(os.date("%M", static_time))
                        if (raid.minu == minute) then
                            if (last_execsutes[k] ~= day) then
                                last_execsutes[k] = day
                                doExecuteRaid(raid.name)
                            end
                        end
                    end
                end
            end
        end
    end
    return true
end

Como funciona? Veja abaixo alguns exemplos:

 

Nessa raid abaixo está configurada pra ser executada, dia X, mês X, hora XX:XX minutos.

        [1] =
            {
                name = 'Morgaroth',
                type = 'exact',
                date = {day = 15, month = 08},
                hour = 16,
                minu = 27
            },

Essa outra abaixo é uma raid pra ser executada semanalmente no dia e horário que você desejar.

        [2] =
            {
                name = 'Zulazza the Corruptor',
                type = 'weekly',
                days = {'monday'},
                hour = 20,
                minu = 00
            },

Lembrado, name = 'Morgaroth', é necessário que essa raid esteja configurada na pasta data/raids.

 

Os créditos eu não sei quem fez, só sei que foi alguém da otland biggrin.png

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...