• 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 Boss spawn every week at time

Joriku

Working in the mines, need something?
Joined
Jul 16, 2016
Messages
1,085
Solutions
15
Reaction score
379
Location
Sweden
YouTube
Joriku
Hi,
not sure how to do this so I'll request it.

I am in need of revscript for boss spawner which will spawn by the machine's time every week at day and time, would appreciate it. No clue how it would be created even
 
Solution
Lua:
local bossPos = Position(287, 320, 11)
local bossName = "Ferumbras"

-- Globalevent at 18:00 every day
local boss_daily = GlobalEvent("boss_daily")
boss_daily:time("18:00:00")

function boss_daily.onTime(time)
    -- Only run on Saturday
    if (os.date("%A") ~= "Saturday") then
        return false
    end
    
    -- Try to spawn monster
    local bossMonster = Game.createMonster(bossName, bossPos)
    if not bossMonster then
        print("Failed to spawn "..bossName..". (wrong monster name or position?)")
        return false
    end

    -- Spawn magic effect and broadcast to players
    bossPos:sendMagicEffect(CONST_ME_TELEPORT)
    Game.broadcastMessage(bossName.." has been summoned!", MESSAGE_STATUS_WARNING)
    return true...
Lua:
local bossPos = Position(287, 320, 11)
local bossName = "Ferumbras"

-- Globalevent at 18:00 every day
local boss_daily = GlobalEvent("boss_daily")
boss_daily:time("18:00:00")

function boss_daily.onTime(time)
    -- Only run on Saturday
    if (os.date("%A") ~= "Saturday") then
        return false
    end
    
    -- Try to spawn monster
    local bossMonster = Game.createMonster(bossName, bossPos)
    if not bossMonster then
        print("Failed to spawn "..bossName..". (wrong monster name or position?)")
        return false
    end

    -- Spawn magic effect and broadcast to players
    bossPos:sendMagicEffect(CONST_ME_TELEPORT)
    Game.broadcastMessage(bossName.." has been summoned!", MESSAGE_STATUS_WARNING)
    return true
end
boss_daily:register()
 
Solution
Lua:
local bossPos = Position(287, 320, 11)
local bossName = "Ferumbras"

-- Globalevent at 18:00 every day
local boss_daily = GlobalEvent("boss_daily")
boss_daily:time("18:00:00")

function boss_daily.onTime(time)
    -- Only run on Saturday
    if (os.date("%A") ~= "Saturday") then
        return false
    end
   
    -- Try to spawn monster
    local bossMonster = Game.createMonster(bossName, bossPos)
    if not bossMonster then
        print("Failed to spawn "..bossName..". (wrong monster name or position?)")
        return false
    end

    -- Spawn magic effect and broadcast to players
    bossPos:sendMagicEffect(CONST_ME_TELEPORT)
    Game.broadcastMessage(bossName.." has been summoned!", MESSAGE_STATUS_WARNING)
    return true
end
boss_daily:register()
Thanks, possible to do it on a sertant date aswell?
example 25th of december
 
Yes, os.date("STRING_ARGUMENT") takes these values:
%aabbreviated weekday name (e.g., Wed)
%Afull weekday name (e.g., Wednesday)
%babbreviated month name (e.g., Sep)
%Bfull month name (e.g., September)
%cdate and time (e.g., 09/16/98 23:48:10)
%dday of the month (16) [01-31]
%Hhour, using a 24-hour clock (23) [00-23]
%Ihour, using a 12-hour clock (11) [01-12]
%Mminute (48) [00-59]
%mmonth (09) [01-12]
%peither "am" or "pm" (pm)
%Ssecond (10) [00-61]
%wweekday (3) [0-6 = Sunday-Saturday]
%xdate (e.g., 09/16/98)
%Xtime (e.g., 23:48:10)
%Yfull year (1998)
%ytwo-digit year (98) [00-99]
%%the character `%´

So you can do etc:
Lua:
    -- Only run during December
    if (os.date("%B") ~= "December") then
        return false
    end
   -- You can also combine string arguments:
   if (os.date("%d %B") ~= "25 December") then
        return false
    end
 
Back
Top