• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Good Time bug in start event.

whiteblXK

Active Member
Joined
Apr 20, 2011
Messages
315
Solutions
9
Reaction score
32
Location
Poland
Hello, I have a problem with [MOD]Good Time Event. I use TFS 0.3.6, i set which days of the week and time to enable/disable event, and it not working. I tried change loading date and time from the array, and again not working.

I tried change this:
Code:
            local daysOpen = {}
          
            for k, v in pairs(newWC.days) do
                table.insert(daysOpen, k)
            end
          
            function onThink(cid, interval)
                print(os.date('%A'))
                if isInArray(daysOpen, os.date('%A')) then
                    for _, d in pairs(newWC.days[os.date('%A')]) do
                        if isInArray(d.from, os.date('%X', os.time())) then
                            if getStorage(newWC.event) ~= 1 then
                                local newRate = newWC.rates[math.random(#newWC.rates)]
  
                                for _, cid in ipairs(getPlayersOnline()) do
                                    doPlayerSetSkills(cid, newRate)
                                    doCreatureSetStorage(cid, newWC.checkEvent, 1)
                                end

                                doSetStorage(newWC.event, 1)
                                doSetStorage(newWC.rateStorage, newRate)

                                                                      
                                for i = 1, newWC.howMuchTimesPoints do
                                    addEvent(randPoints, i * newWC.everyMinPoints * 60 * 1000, newWC.points)
                                end
                                                  
                                doBroadcastMessage('Happy Hours! Rates have changed to: ' .. newRate .. '! Rates will back to normal in ' .. d.to .. ' (server time). Have fun!!', MESSAGE_STATUS_WARNING)
                            end
                        break
                        end
                    end
                end
To this:
Code:
function onThink(interval)
print(os.date('%A'))
local checkCorrectDay = newWC.days[os.date('%A'):lower()]
if not checkCorrectDay then
    return true
end
print(1)
for k, v in pairs(checkCorrectDay) do
    if isInArray(v.to, os.date('%X', os.time())) then
print(2)
        if getStorage(newWC.event) ~= -1 then
                local newRate = newWC.rates[math.random(#newWC.rates)]
  
                                for _, cid in ipairs(getPlayersOnline()) do
                                    doPlayerSetSkills(cid, newRate)
                                    doCreatureSetStorage(cid, newWC.checkEvent, 1)
                                end

                                doSetStorage(newWC.event, 1)
                                doSetStorage(newWC.rateStorage, newRate)

                                                                      
                                for i = 1, newWC.howMuchTimesPoints do
                                    addEvent(randPoints, i * newWC.everyMinPoints * 60 * 1000, newWC.points)
                                end
                                                  
                                doBroadcastMessage('Happy Hours! Rates have changed to: ' .. newRate .. '! Rates will back to normal in ' .. d.to .. ' (server time). Have fun!!', MESSAGE_STATUS_WARNING)
                            end
        break
    end
end
return true
end
And agin no result :(
Here is the MOD:
Code:
http://wklej.org/id/1340039/

Help me with this MOD.
 
Last edited:
That suggests the event definition for onThink() isn't defined correctly in creaturescripts.xml and login.lua. This would mean the script never runs.
 
Back
Top