• 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!

Lua Globalevent script

Lbtg

Intermediate OT User
Joined
Nov 22, 2008
Messages
2,324
Reaction score
136
Hello once again i got an issue with raids script i cant set hourly raids can someone please help me or fix the code? :)
no errors. i use 0.4
what i want to do is that i can set some raids to happend every 15 minutes , or every 2 hour or 1 :)
would be nice if someone could help :)

script
PHP:
--[[
- 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 = 'morga',
                type = 'hourly',
                minu = 1
            },
        [2] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'tuesday'},
                hour = 20,
                minu = 00
            },
        [3] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'monday'},
                hour = 8,
                minu = 00
            },
        [4] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'wednesday'},
                hour = 12,
                minu = 00
            },
        [5] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'thursday'},
                hour = 10,
                minu = 00
            },
        [6] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'sunday'},
                hour = 15,
                minu = 00
            },
        [7] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'tuesday'},
                hour = 10,
                minu = 00
            },
        [8] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'saturday'},
                hour = 22,
                minu = 00
            },
        [9] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'monday'},
                hour = 16,
                minu = 00
            },
        [10] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'sunday'},
                hour = 8,
                minu = 00
            },
        [11] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'thursday'},
                hour = 20,
                minu = 00
            },
        [12] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'wednesday'},
                hour = 8,
                minu = 00
            },
        [13] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'sunday'},
                hour = 18,
                minu = 00
            },
        [14] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'saturday'},
                hour = 6,
                minu = 00
            },
        [15] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'friday'},
                hour = 4,
                minu = 00
            },
        [16] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'tuesday'},
                hour = 5,
                minu = 00
            },
        [17] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'wednesday'},
                hour = 19,
                minu = 00
            },
        [18] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'thursday'},
                hour = 20,
                minu = 00
            },
        [19] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'friday'},
                hour = 12,
                minu = 00
            },
        [20] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'monday'},
                hour = 11,
                minu = 00
            },
        [21] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'tuesday'},
                hour = 3,
                minu = 00
            },
        [22] =
            {
                name = 'apocalypses',
                type = 'weekly',
                days = {'tuesday'},
                hour = 20,
                minu = 00
            },
        [23] =
            {
                name = 'apocalypses',
                type = 'weekly',
                days = {'friday'},
                hour = 18,
                minu = 00
            },
        [24] =
            {
                name = 'goblins',
                type = 'exact',
                date = {day = 28, month = 5},
                hour = 17,
                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 == 'hourly') then
            local minute = tonumber(os.date("%M", static_time))
                if (00 == minute) then
                    doExecuteRaid(raid.name)
                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
 
Last edited:
I've checked this a couple times.
Hourly seems to spawn the raid on the hour.
Code:
1:00am
2:00am
3:00am
.
.
22:00pm
23:00pm
Make sure your global event is checking every minute, otherwise it may miss the hourly raids.
 
I've checked this a couple times.
Hourly seems to spawn the raid on the hour.
Code:
1:00am
2:00am
3:00am
.
.
22:00pm
23:00pm
Make sure your global event is checking every minute, otherwise it may miss the hourly raids.
its checking every 1 sec xml

but i wanted to do hourly like , every 1 hour spawn raid
 
Lol such pathetic sentense from you, you rolling down bro... thats shame.
Such a pathetic excuse for a human being..

If you are going to build a server there are a few things you need to know before you watch some tutorial, like how to use a search box, tackle a few written languages.. most importantly not be exceptionally rude to others especially when they are the ones trying to help you.
 
can someone help with this script please ? it doesnt debug or so but i dont get how to set hourly raids , so it can be like every 1 hour or every 15 minutes and so on.
there is the script
PHP:
--[[
- 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 = 'morga',
                type = 'hourly',
                minu = 1
            },
        [2] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'tuesday'},
                hour = 20,
                minu = 00
            },
        [3] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'monday'},
                hour = 8,
                minu = 00
            },
        [4] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'wednesday'},
                hour = 12,
                minu = 00
            },
        [5] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'thursday'},
                hour = 10,
                minu = 00
            },
        [6] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'sunday'},
                hour = 15,
                minu = 00
            },
        [7] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'tuesday'},
                hour = 10,
                minu = 00
            },
        [8] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'saturday'},
                hour = 22,
                minu = 00
            },
        [9] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'monday'},
                hour = 16,
                minu = 00
            },
        [10] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'sunday'},
                hour = 8,
                minu = 00
            },
        [11] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'thursday'},
                hour = 20,
                minu = 00
            },
        [12] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'wednesday'},
                hour = 8,
                minu = 00
            },
        [13] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'sunday'},
                hour = 18,
                minu = 00
            },
        [14] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'saturday'},
                hour = 6,
                minu = 00
            },
        [15] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'friday'},
                hour = 4,
                minu = 00
            },
        [16] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'tuesday'},
                hour = 5,
                minu = 00
            },
        [17] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'wednesday'},
                hour = 19,
                minu = 00
            },
        [18] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'thursday'},
                hour = 20,
                minu = 00
            },
        [19] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'friday'},
                hour = 12,
                minu = 00
            },
        [20] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'monday'},
                hour = 11,
                minu = 00
            },
        [21] =
            {
                name = 'morga',
                type = 'weekly',
                days = {'tuesday'},
                hour = 3,
                minu = 00
            },
        [22] =
            {
                name = 'apocalypses',
                type = 'weekly',
                days = {'tuesday'},
                hour = 20,
                minu = 00
            },
        [23] =
            {
                name = 'apocalypses',
                type = 'weekly',
                days = {'friday'},
                hour = 18,
                minu = 00
            },
        [24] =
            {
                name = 'goblins',
                type = 'exact',
                date = {day = 28, month = 5},
                hour = 17,
                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 == 'hourly') then
            local minute = tonumber(os.date("%M", static_time))
                if (00 == minute) then
                    doExecuteRaid(raid.name)
                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
 
Back
Top