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

TFS 1.X+ onTime multiple executions (revscript)

Roddet

Staff member
Global Moderator
Joined
May 1, 2013
Messages
928
Solutions
101
Reaction score
748
Location
Mex
Basically im new at tfs 1.x
Wondering if there is a way to execute multiple times an onTime event?

Lua:
local globalevent = GlobalEvent("SafeStart")
function globalevent.onTime(interval)
    broadcastMessage("Hiho", MESSAGE_STATUS_DEFAULT)
    return true
end

globalevent:time("15:00")
globalevent:register()

Already tried few ways but none seems to actually work, so is possible or is there a workaround for this?
 
Last edited:
Solution
Nice didnt know i could do that too but i meant on the same event instead of creating more, could be possible?
Ah I see.

Then you'd want to make a function and addEvent it.

Lua:
local function doStuff(amount)
    broadcastMessage("Hiho", MESSAGE_STATUS_DEFAULT)
    if amount > 0 then
        addEvent(doStuff, 3000, amount - 1)
    end
end

local globalEvent = GlobalEvent("SafeStart")

function globalEvent.onTime()
    doStuff(5)
    return true
end

globalEvent:time(15:00:00)
globalEvent:register()
Basically im new at tfs 1.x
Wondering if there is a way to execute multiple times an onTime event?

Lua:
local globalevent = GlobalEvent("SafeStart")
function globalevent.onTime(interval)
    broadcastMessage("Hiho", MESSAGE_STATUS_DEFAULT)
    return true
end

globalevent:time("15:00")
globalevent:register()

Already tried few ways but none seems to actually work, so is possible or is there a workaround for this?
Lua:
local startTimes = {"15:01:00", "15:02:00", "15:03:00"}
for i = 1, #startTimes do
    local globalevent = GlobalEvent("SafeStart_" .. i .."") -- needs a unique name, hence the (SafeStart_1, SafeStart_2, SafeStart_3)
 
    function globalevent.onTime()
        broadcastMessage("Hiho", MESSAGE_STATUS_DEFAULT)
        return true
    end

    globalevent:time(startTimes[i])
    globalevent:register()
end
 
Lua:
local startTimes = {"15:01:00", "15:02:00", "15:03:00"}
for i = 1, #startTimes do
    local globalevent = GlobalEvent("SafeStart_" .. i .."") -- needs a unique name, hence the (SafeStart_1, SafeStart_2, SafeStart_3)
 
    function globalevent.onTime()
        broadcastMessage("Hiho", MESSAGE_STATUS_DEFAULT)
        return true
    end

    globalevent:time(startTimes[i])
    globalevent:register()
end

Nice thats clever =D but i meant on the same event instead of creating more, guess nope?
 
Nice didnt know i could do that too but i meant on the same event instead of creating more, could be possible?
Ah I see.

Then you'd want to make a function and addEvent it.

Lua:
local function doStuff(amount)
    broadcastMessage("Hiho", MESSAGE_STATUS_DEFAULT)
    if amount > 0 then
        addEvent(doStuff, 3000, amount - 1)
    end
end

local globalEvent = GlobalEvent("SafeStart")

function globalEvent.onTime()
    doStuff(5)
    return true
end

globalEvent:time(15:00:00)
globalEvent:register()
 
Solution
Basically not possible, nice workarounds tho thanks
Well, it depends.

What situation would require you to fire off the same function multiple times?

Maybe you're just asking the wrong question for the idea you have in mind.
 
I was just curious if it would be possible since on a rev action you can set up several aids for example, so i though it could be possible overwrite time somehow but i guess i should look more carefully into the code to know what can be and what cannot be done as raw, besides workarounds

Its for a game event, which probably use onThink instead as always
 
Last edited:
Back
Top