• 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 Time schedule

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
201
Reaction score
15
Hello, someone helps me with this, I want to know how to configure the schedule of my server, for example I want to place it in your schedule
(GMT-4)

me use otbr tfs1.3

It is that I am trying to place this scripts and I think it is because of the time that it does not work

Lua:
local raids = {
    -- Weekly
    --Segunda-Feira
    ['Monday'] = {
        ['06:00'] = {raidName = 'RatsThais'},
    },

    --Terça-Feira
    ['Tuesday'] = {
        ['16:00'] = {raidName = 'Midnight Panther One'}
    },

    --Quarta-Feira
    ['Friday'] = {
        ['12:55'] = {raidName = 'Draptor'}
    },

    --Quinta-Feira
    ['Thursday'] = {
        ['01:35'] = {raidName = 'Undead Cavebear'}
    },

    --Sexta-feira
    ['Friday'] = {
        ['06:00'] = {raidName = 'Crustacea Gigantica treasure'}
    },

    --Sábado
    ['Saturday'] = {
        ['20:00'] = {raidName = 'Draptor'}
    },

    --Domingo
    ['Sunday'] = {
        ['15:00'] = {raidName = 'Midnight Panther Two'},
        ['13:00'] = {raidName = 'Orc Backpack'}
    },

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

local spawnRaids = GlobalEvent("spawn raids")
function spawnRaids.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

spawnRaids:interval(60000)
spawnRaids:register()
 
Make sure to copy the entire script instead of just part of it...
You're missing getRealDate() and getRealTime()
Lua:
function getRealTime()
    local hours = tonumber(os.date("%H", os.time()))
    local minutes = tonumber(os.date("%M", os.time()))

    if hours < 10 then
        hours = '0' .. hours
    end
    if minutes < 10 then
        minutes = '0' .. minutes
    end
    return hours .. ':' .. minutes
end

function getRealDate()
    local month = tonumber(os.date("%m", os.time()))
    local day = tonumber(os.date("%d", os.time()))

    if month < 10 then
        month = '0' .. month
    end
    if day < 10 then
        day = '0' .. day
    end
    return day .. '/' .. month
end
 
Make sure to copy the entire script instead of just part of it...
You're missing getRealDate() and getRealTime()
Lua:
function getRealTime()
    local hours = tonumber(os.date("%H", os.time()))
    local minutes = tonumber(os.date("%M", os.time()))

    if hours < 10 then
        hours = '0' .. hours
    end
    if minutes < 10 then
        minutes = '0' .. minutes
    end
    return hours .. ':' .. minutes
end

function getRealDate()
    local month = tonumber(os.date("%m", os.time()))
    local day = tonumber(os.date("%d", os.time()))

    if month < 10 then
        month = '0' .. month
    end
    if day < 10 then
        day = '0' .. day
    end
    return day .. '/' .. month
end
Would it be something like this?
sorry that scripts comes by default in otbr tfs 1.3

Lua:
local raids = {
    -- Weekly
    --Segunda-Feira
    ['Monday'] = {
        ['06:00'] = {raidName = 'RatsThais'},
    },

    --Terça-Feira
    ['Tuesday'] = {
        ['16:00'] = {raidName = 'Midnight Panther One'}
    },

    --Quarta-Feira
    ['Friday'] = {
        ['12:55'] = {raidName = 'Draptor'}
    },

    --Quinta-Feira
    ['Thursday'] = {
        ['01:35'] = {raidName = 'Undead Cavebear'}
    },

    --Sexta-feira
    ['Friday'] = {
        ['06:00'] = {raidName = 'Crustacea Gigantica treasure'}
    },

    --Sábado
    ['Saturday'] = {
        ['20:00'] = {raidName = 'Draptor'}
    },

    --Domingo
    ['Sunday'] = {
        ['15:00'] = {raidName = 'Midnight Panther Two'},
        ['13:00'] = {raidName = 'Orc Backpack'}
    },

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

function getRealTime()
    local hours = tonumber(os.date("%H", os.time()))
    local minutes = tonumber(os.date("%M", os.time()))

    if hours < 10 then
        hours = '0' .. hours
    end
    if minutes < 10 then
        minutes = '0' .. minutes
    end
    return hours .. ':' .. minutes
end

function getRealDate()
    local month = tonumber(os.date("%m", os.time()))
    local day = tonumber(os.date("%d", os.time()))

    if month < 10 then
        month = '0' .. month
    end
    if day < 10 then
        day = '0' .. day
    end
    return day .. '/' .. month
end

local spawnRaids = GlobalEvent("spawn raids")
function spawnRaids.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

spawnRaids:interval(60000)
spawnRaids:register()
Post automatically merged:

Would it be something like this?
sorry that scripts comes by default in otbr tfs 1.3

Lua:
local raids = {
    -- Weekly
    --Segunda-Feira
    ['Monday'] = {
        ['06:00'] = {raidName = 'RatsThais'},
    },

    --Terça-Feira
    ['Tuesday'] = {
        ['16:00'] = {raidName = 'Midnight Panther One'}
    },

    --Quarta-Feira
    ['Friday'] = {
        ['12:55'] = {raidName = 'Draptor'}
    },

    --Quinta-Feira
    ['Thursday'] = {
        ['01:35'] = {raidName = 'Undead Cavebear'}
    },

    --Sexta-feira
    ['Friday'] = {
        ['06:00'] = {raidName = 'Crustacea Gigantica treasure'}
    },

    --Sábado
    ['Saturday'] = {
        ['20:00'] = {raidName = 'Draptor'}
    },

    --Domingo
    ['Sunday'] = {
        ['15:00'] = {raidName = 'Midnight Panther Two'},
        ['13:00'] = {raidName = 'Orc Backpack'}
    },

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

function getRealTime()
    local hours = tonumber(os.date("%H", os.time()))
    local minutes = tonumber(os.date("%M", os.time()))

    if hours < 10 then
        hours = '0' .. hours
    end
    if minutes < 10 then
        minutes = '0' .. minutes
    end
    return hours .. ':' .. minutes
end

function getRealDate()
    local month = tonumber(os.date("%m", os.time()))
    local day = tonumber(os.date("%d", os.time()))

    if month < 10 then
        month = '0' .. month
    end
    if day < 10 then
        day = '0' .. day
    end
    return day .. '/' .. month
end

local spawnRaids = GlobalEvent("spawn raids")
function spawnRaids.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

spawnRaids:interval(60000)
spawnRaids:register()

This time that it says in the scripts refers to the schedule of the VPS?
VPS.png
 
Last edited:
Back
Top