• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Lua [TFS 0.X] Global event daily

potinho

Intermediate OT User
Joined
Oct 11, 2009
Messages
1,253
Solutions
17
Reaction score
104
Location
Brazil
Hello everyone, everything good? I have a global event where a TP is created for a room. If I put in the setup just one day, it works. If I put it every day, it doesn't start, it doesn't give an error on the console and it doesn't work. can you help me?

Lua:
local configuration = {
    day = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"},
    to_pos = {x = 503, y = 1246, z = 9},    --Para onde o teleport levará.
    pos = {x = 503, y = 1237, z = 9},       --Onde o teleport será criado.
    teleport_id = 1387,                --ID do teleport.
}
function onTime()
    if os.date("%A") == configuration.day then
        local item = getTileItemById(configuration.pos, configuration.teleport_id).uid
        if item > 0 then
            doRemoveItem(item, 1)
            broadcastMessage("Master Yalahari's portal has closed.", MESSAGE_STATUS_WARNING)
        else
            doCreateTeleport(configuration.teleport_id, configuration.to_pos, configuration.pos)
            broadcastMessage("The portal to defeat the Yalahari master has opened.", MESSAGE_STATUS_WARNING)
        end
    end
    return true
end

in globalevents.xml i have

XML:
    <globalevent name="YalaharBoss" time="08:51" event="script" value="yalaharboss.lua"/>
    <globalevent name="YalaharClose" time="09:01" event="script" value="yalaharboss.lua"/>
Post automatically merged:

Hello everyone, everything good? I have a global event where a TP is created for a room. If I put in the setup just one day, it works. If I put it every day, it doesn't start, it doesn't give an error on the console and it doesn't work. can you help me?

Lua:
local configuration = {
    day = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"},
    to_pos = {x = 503, y = 1246, z = 9},    --Para onde o teleport levará.
    pos = {x = 503, y = 1237, z = 9},       --Onde o teleport será criado.
    teleport_id = 1387,                --ID do teleport.
}
function onTime()
    if os.date("%A") == configuration.day then
        local item = getTileItemById(configuration.pos, configuration.teleport_id).uid
        if item > 0 then
            doRemoveItem(item, 1)
            broadcastMessage("Master Yalahari's portal has closed.", MESSAGE_STATUS_WARNING)
        else
            doCreateTeleport(configuration.teleport_id, configuration.to_pos, configuration.pos)
            broadcastMessage("The portal to defeat the Yalahari master has opened.", MESSAGE_STATUS_WARNING)
        end
    end
    return true
end

in globalevents.xml i have

XML:
    <globalevent name="YalaharBoss" time="08:51" event="script" value="yalaharboss.lua"/>
    <globalevent name="YalaharClose" time="09:01" event="script" value="yalaharboss.lua"/>
Forgot, just remove day config from script. works
 
Last edited:

Dakos

Well-Known Member
Joined
Jan 1, 2010
Messages
162
Solutions
22
Reaction score
88
Lua:
local configuration = {
    day = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"},
    to_pos = {x = 503, y = 1246, z = 9},    --Para onde o teleport levará.
    pos = {x = 503, y = 1237, z = 9},       --Onde o teleport será criado.
    teleport_id = 1387,                --ID do teleport.
}
function onTime()
    local currentDay = os.date("%A")
    if isInArray(configuration.day, currentDay) then
        local item = getTileItemById(configuration.pos, configuration.teleport_id).uid
        if item > 0 then
            doRemoveItem(item, 1)
            broadcastMessage("Master Yalahari's portal has closed.", MESSAGE_STATUS_WARNING)
        else
            doCreateTeleport(configuration.teleport_id, configuration.to_pos, configuration.pos)
            broadcastMessage("The portal to defeat the Yalahari master has opened.", MESSAGE_STATUS_WARNING)
        end
    end
    return true
end
 
Top