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

Solved [TFS 1.0] Raid System (Time&Date)

Sentinel3

New Member
Joined
Oct 16, 2014
Messages
180
Reaction score
0
Hello everyone,

I wanted to make a raid for every day or something like that, and I got this error in console, i don't know how can I fix this type of problems with time and date?

Error in console:
HTML:
Lua Script Error: [GlobalEvent Interface]
data/globalevents/scripts/spawn/raids.lua:onThink
data/globalevents/scripts/spawn/raids.lua:15: attempt to call global 'getRealDate' (a nil value)
stack traceback:
        [C]: in function 'getRealDate'
        data/globalevents/scripts/spawn/raids.lua:15: in function <data/globalevents/scripts/spawn/raids.lua:14>
[Error - GlobalEvents::think] Failed to execute event: RaidSystem

/data/globalevent.xml (TAG)
HTML:
<globalevent name="RaidSystem" interval="10000" script="spawn/raids.lua"/>
/data/globalevents/raids.lua
HTML:
local raids = {
    -- Weekly
    ['Monday'] = {
        ['08:00'] = {raidName = 'RatsThais'},

        ['15:00'] = {raidName = 'Arachir the Ancient One'}
    },

    ['Wednesday'] = {
        ['12:00'] = {raidName = 'OrcsThais'}
    },

    -- By date (Day/Month)
    ['31/10'] = {
        ['16:00'] = {raidName = 'Halloween Hare'}
    }
}

function onThink(interval, lastExecution, thinkInterval)
    local day, date = os.date('%A'), getRealDate()

    local raidDays = {}
    if raids[day] then
        table.insert(raidDays, raids[day])
    end
    if raids[date] then
        table.insert(raidDays, raids[date])
    end

    if #raidDays == 0 then
        return true
    end

    for i = 1, #raidDays do
        local settings = raidDays[i][getRealTime()]
        if settings and not settings.alreadyExecuted then
                Game.startRaid(settings.raidName)
                settings.alreadyExecuted = true
        end
    end

    return true
end
 
You missing these functions:
https://github.com/PrinterLUA/FORGOTTENSERVER-ORTS/blob/master/data/lib/050-functions.lua#L33
https://github.com/PrinterLUA/FORGOTTENSERVER-ORTS/blob/master/data/lib/050-functions.lua#L46

paste them into your global.lua and also update your raid script to this:
Code:
local raids = {
    -- Weekly
    ['Monday'] = {
        ['08:00'] = {raidName = 'RatsThais'},

        ['15:00'] = {raidName = 'Arachir the Ancient One'}
    },

    ['Wednesday'] = {
        ['12:00'] = {raidName = 'OrcsThais'}
    },

    -- By date (Day/Month)
    ['31/10'] = {
        ['16:00'] = {raidName = 'Halloween Hare'}
    }
}

function onThink(interval, lastExecution, thinkInterval)
    local day, date = os.date('%A'), getRealDate()

    local raidDays = {}
    if raids[day] then
        raidDays[#raidDays + 1] = raids[day]
    end
   
    if raids[date] then
        raidDays[#raidDays + 1] = raids[date]
    end

    if #raidDays == 0 then
        return true
    end

    for i = 1, #raidDays do
        local settings = raidDays[i][getRealTime()]
        if settings and not settings.alreadyExecuted then
            Game.startRaid(settings.raidName)
            settings.alreadyExecuted = true
        end
    end

    return true
end
 
Back
Top