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

RevScripts monster event appears on the day

lehmartins

New Member
Joined
Jul 20, 2016
Messages
13
Reaction score
1
Could anyone kindly help me?
This code causes the monster to be born on such a day and time, it apparently works, but it gives this error in the console: [2024-11-10 23:09:51.908] [error] [Script::loadCallback] scriptid is not zero, scriptid = 2402, scriptName boss_schedule.lua

LUA:
-- funcionou melhor
local events_by_day = {
    ['Monday'] = {
        ['MONSTER'] = {name = "Glacius Death Monday", position = {x = 32200, y = 32200, z = 7}, time = 15}, -- 15h
    },
    ['Tuesday'] = {
        ['MONSTER'] = {name = "Apocalypse Tuesday", position = {x = 32278, y = 32488, z = 8}, time = 20}, -- 20h
    },
    ['Wednesday'] = {
        ['MONSTER'] = {name = "Infernatil Wednesday", position = {x = 32336, y = 32462, z = 8}, time = 03}, -- 03h
    },
    ['Thursday'] = {
        ['MONSTER'] = {name = "Verminor Thursday", position = {x = 32264, y = 32448, z = 8}, time = 14}, -- 14h
    },
    ['Friday'] = {
        ['MONSTER'] = {name = "Bazir Friday", position = {x = 32520, y = 32358, z = 7}, time = 19}, -- 19h
    },
    ['Saturday'] = {
        ['MONSTER'] = {name = "King Zelos Saturday", position = {x = 32490, y = 32407, z = 6}, time = 23}, -- 17h
    },
    ['Sunday'] = {
        ['MONSTER'] = {name = "Ferumbras Sunday", position = {x = 32020, y = 32315, z = 7}, time = 06}, -- 06h
    },
}

-- Função para criar o monstro
local function createMonster(day)
    local todayEvents = events_by_day[day]
    if todayEvents and todayEvents['MONSTER'] then
        local monsterInfo = todayEvents['MONSTER']
        if monsterInfo and monsterInfo.name and monsterInfo.position then
            local position = monsterInfo.position
            local monsterName = monsterInfo.name
            Game.createMonster(monsterName, position)
            print("Spawned " .. monsterName .. " at position (" .. position.x .. ", " .. position.y .. ", " .. position.z .. ")")
        else
            print("Error: Monster information is incomplete.")
        end
    else
        print("No events found for " .. day)
    end
end

-- Evento que será executado periodicamente para verificar se é a hora de spawnar o monstro
local dailyMonsterSpawnEvent = GlobalEvent("dailyMonsterSpawnEvent")

function dailyMonsterSpawnEvent.onThink(interval)
    local day = os.date('%A') -- Obtém o dia atual
    local currentHour = tonumber(os.date('%H')) -- Obtém a hora atual (24 horas)

    local todayEvents = events_by_day[day]
    if todayEvents and todayEvents['MONSTER'] then
        local monsterInfo = todayEvents['MONSTER']
        local spawnHour = monsterInfo.time -- Hora configurada para spawn

        -- Verifica se a hora atual é igual à hora configurada para o monstro do dia
        if currentHour == spawnHour then
            print("Current time: " .. currentHour .. " on " .. day)
            print("Expected spawn hour: " .. spawnHour)
            createMonster(day)
        else
            print("Current time: " .. currentHour .. " on " .. day)
            print("Expected spawn hour: " .. spawnHour)
            print("Not the correct time to spawn the monster.")
        end
    else
        print("No events configured for today.")
    end
end

-- Função de registro do evento
function dailyMonsterSpawnEvent.onStartup()
    -- Definir o intervalo para 1 minuto (60000 milissegundos)
    dailyMonsterSpawnEvent:interval(60000) -- Verificar a cada 1 minuto
    print("Daily monster spawn event registered with 1 minute interval.")
end

-- Registrar o evento global
dailyMonsterSpawnEvent:register()
 
Back
Top