• 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,332
Reaction score
141
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:
who says im smart ? thats why im here on forum , becouse im naab on it but well atlist i work and i try and do what i understand i work on tibia ots like 5 years got different projecs made and its my hobby aswell.

but anyway thats why i post here on support to recieve postive messages atlist hints with some truly understand able information.

maybe thats why otland has died , cuz people of it became ignorrant and idk how to call people like that PRO guy... hes pro and i can admit it but anyway pushing me in idiot side is not an option for vise guy/man....
 
since this saturday (4 days...) you've created 8 threads asking for help, and not really provided any input at all except "how do i make this someone fix for me pls", and when people give you something that is working, you try to add something and then complain that it isnt working, instead of asking for that feature from the start
 
since this saturday (4 days...) you've created 8 threads asking for help, and not really provided any input at all except "how do i make this someone fix for me pls", and when people give you something that is working, you try to add something and then complain that it isnt working, instead of asking for that feature from the start
yeah in like half year i posted like 10 topics on support , maybe i had time in rl and i asked for help ?
 
The reason to why people have stopped replying to your support (REQUEST) threads is the fact that you are either 1. doing changes in the script that don't follow any logical sense -> leads to the script causing errors -> blames the one who helped you for not helping out enough.
2. you're not taking these opportunities to learn anything from Lua at all. Instead, you're complaining and that doesn't attract the helpful part of this community.

Go to Lua.org/any other sites that has the sole purpose of learning a specific/several languages. Read through all the chapters thoroughly and then you'll be able to understand all the responses you get from doing a support thread.
 
The reason to why people have stopped replying to your support (REQUEST) threads is the fact that you are either 1. doing changes in the script that don't follow any logical sense -> leads to the script causing errors -> blames the one who helped you for not helping out enough.
2. you're not taking these opportunities to learn anything from Lua at all. Instead, you're complaining and that doesn't attract the helpful part of this community.

Go to Lua.org/any other sites that has the sole purpose of learning a specific/several languages. Read through all the chapters thoroughly and then you'll be able to understand all the responses you get from doing a support thread.
1.Yes ofc i try do changes cuz i trying something with pushing me to learning, but if i do something wrong or bad people can notice me thats why im here on support forum to recieve as much as people from from the ones who does help.
2. I never blamed someone on SUPPORT lol , show me where.... i respect every one and it dpopesnt matter who you are , even the PRO guy .
and yet my english skills is not good ,but much better then before.. yeah i suck at english and what ? atlist i don't hide my weaknesess same goes for scripting... but atlist i dont surrender....

3.I watching tutorials on youtube about lua c++ and so then i got free time ,i got rl low time on tibia... But yet another thingy is that that i forgeting things quit fast...

what im always being a honest and always say what i think and my straight opinion...
but if someone thinks that im not gratefull or thankfull for help or even complaining... can you show where i complain ? and where i just tell that the sript not work/ and if i show once again script it can mean that i made some changes in order to fit my needs ye... but if i do something wrong or bad you guys can atlist hint me what stupid bad things i do.
 
Lmao I said that because I made a post that I decided to delete. So I said nevermind on my post. Go learn some engish.


I believe so too.
Learning every day mostly :) but do you think i dont kno'w myself what i need to learn what not ?
or you just wanna look smarter then me ? well you WON you much smarter .
and what of that ? you won somthing here ? i can admit that i sux on scripting and on english and mostly on all things , but there is reasons for evrything.
ahhh... wanted to write so much , but im lossing pozitive way of thinking of how people PUSH here...
 
You know that little red line under the text which appears when you are typing?

That is to let you know the word you are using or attempting to use is spelled incorrectly.. just right click it and select a word for the proper spelling. :)

Also you won't learn anything by editing a script, you need to know the logic behind the code's scope and execution, please don't respond with "well I am not a pro like you" of course you aren't but that does not mean you can't be, you just have to put in some effort.

https://www.google.com/#q=lua+tutorials
 
Last edited:
You know that little red line under the text which appears when you are typing?

That is to let you know the word you are using or attempting to use is spelled incorrectly.. just right click it and select a word for the proper spelling. :)

Also you won't learn anything by editing a script, you need to know the logic behind the code's scope and execution, please don't respond with "well I am not a pro like you" of course you aren't but that does not mean you can't be, you just have to put in some effort.

https://www.google.com/#q=lua+tutorials
why you need to bite ? ;)
 
why you need to bite ? ;)
Bud, I am not trying to be mean to you. You are taking what I am saying the wrong way. We call that assuming. Please, I am more than willing to help anyone on this forum and never try to go into a thread to be aggressive by any means. So, take a second to calm down and realize I am here to help not to attack you.

Now if you would like I can help you re-make this script while showing you how to do it. This way you learn how it works. It will be hard for you to learn how to code because you don't understand English that well. Instead of learning the code you are really just memorizing what it looks like and making up what it means. That is a hard thing to do.

It is obvious you cannot take criticism well so you should just ignore Codex. I respond to him because its funny not because I actually care about anything he is saying.
Codex is usually just telling people they aren't good at coding, well, on this forum that's usually true. Even I have things to learn and I am working on it still. Everyday I check new things and try to understand parts better. I am learning PhP, Java, Lua, and C++ all at once.

Some people on this forum (like Codex) dontt want to help people who aren't learning how to do it themselves. They don't because its annoying, they don't want to make your game for you. If they wanted to do that why not just make their own?

Who is better the one that hands you a fish, or the one that teaches you to fish so you can do it yourself?
 
Bud, I am not trying to be mean to you. You are taking what I am saying the wrong way. We call that assuming. Please, I am more than willing to help anyone on this forum and never try to go into a thread to be aggressive by any means. So, take a second to calm down and realize I am here to help not to attack you.

Now if you would like I can help you re-make this script while showing you how to do it. This way you learn how it works. It will be hard for you to learn how to code because you don't understand English that well. Instead of learning the code you are really just memorizing what it looks like and making up what it means. That is a hard thing to do.

It is obvious you cannot take criticism well so you should just ignore Codex. I respond to him because its funny not because I actually care about anything he is saying.
Codex is usually just telling people they aren't good at coding, well, on this forum that's usually true. Even I have things to learn and I am working on it still. Everyday I check new things and try to understand parts better. I am learning PhP, Java, Lua, and C++ all at once.

Some people on this forum (like Codex) dontt want to help people who aren't learning how to do it themselves. They don't because its annoying, they don't want to make your game for you. If they wanted to do that why not just make their own?

Who is better the one that hands you a fish, or the one that teaches you to fish so you can do it yourself?
Apparently you do care about what I say or you would not be name dropping and justifying your responses to any comments i make.

You don't know a thing about son. :)

I have helped thousands of people on this forum and in life in general, I don't have to help anyone, but I choose to when I choose to, if you think my attitude is shit, well you better take a hard look in the mirror because yours isn't any better (this isn't directly only at you, this goes for all of you that have a problem with my conduct).
 
Apparently you do care about what I say or you would not be name dropping and justifying your responses to any comments i make.

You don't know a thing about son. :)

I have helped thousands of people on this forum and in life in general, I don't have to help anyone, but I choose to when I choose to, if you think my attitude is shit, well you better take a hard look in the mirror because yours isn't any better (this isn't directly only at you, this goes for all of you that have a problem with my conduct).

Was I wrong when I said you would rather teach someone to fish rather then give them fish?
 
Was I wrong when I said you would rather teach someone to fish rather then give them fish?
Using that analogy, I think it would be more like showing someone how to bait the hook, and then letting them figure out what to do from there. When I help people, I don't want to teach them how to code, I want to help them learn how to code.
 
You mean, you want to teach them how to learn how to code.

I would say you are just splitting hairs there.

There would be no point for the support section of this forum if the answer to everyone problem was: Here is a tutorial on that subject. Sometimes people need to hear an answer to the exact problem they are having rather then a general one.

Meaning. Lets say he has a problem with an array:

array = {"hour", "day", "week", "month"}

Instead of him looking up a tutorial which gives him the information

randomarray = {random, random, random, random}

It would be the exact information. It would also be the exact way it needs to execute it.

Being:

if execute[value] == "hour" then

rather then:

if random[random_value] == random then


If you understand what I mean. Yes, he COULD figure it out but as I said that's why the support board is there.
 
Last edited:
You mean, you want to teach them how to learn how to code.

I would say you are just splitting hairs there.

There would be no point for the support section of this forum if the answer to everyone problem was: Here is a tutorial on that subject. Sometimes people need to hear an answer to the exact problem they are having rather then a general one.

Meaning. Lets say he has a problem with an array:

array = {"hour", "day", "week", "month"}

Instead of him looking up a tutorial which gives him the information

randomarray = {random, random, random, random}

It would be the exact information. It would also be the exact way it needs to execute it.

Being:

if execute[value] == "hour" then

rather then:

if random[random_value] == random then


If you understand what I mean. Yes, he COULD figure it out but as I said that's why the support board is there.

You have a point. Normally, I do try to give people exact answers. But, if they don't have any code at all, then there is a chance I will just let someone else answer it, unless it's something new that gets my attention. But if they are trying to code it and they can't get it to work, that's when I'm way more likely to help them get it working. I just don't want to do other people's servers for them. :p I want them to go through some of the same creative learning process that I went through when I first started.
 
Pal... You need help, seriously... I will not feed you anymore, but please, find the peace within...
Says the guy who talks shit about me and when I do about him he wants to play the role of the temple monk.. go blow smoke up someone else's ass.
 
Back
Top