• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Raids (Hours and Days)

ban how i install in my OT?

Code:
- 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 = 'test',
                type = 'exact',
                date = {day = 30, month = 07},
                hour = 19,
                minu = 27
            },
        [2] = 
            {
                name = 'test',
                type = 'weekly',
                days = {'friday'},
                hour = 19,
                minu = 25
            },
        [3] = 
            {
                name = 'example_of_many_days',
                type = 'weekly',
                days = {"monday", "friday", "sunday"},
                hour = 13,
                minu = 40
            },
        [4] = 
            {
                name = 'Pirates',
                type = 'weekly',
                days = {"monday"},
                hour = 15,
                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

In Raids, Globalevents ?
 
Back
Top