• 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

::continue::
Premium User
Joined
May 1, 2013
Messages
486
Solutions
33
Reaction score
224
Location
mx
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()

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
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
 
OP
OP
Roddet

Roddet

::continue::
Premium User
Joined
May 1, 2013
Messages
486
Solutions
33
Reaction score
224
Location
mx
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?
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
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

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
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.
 

Evil Puncker

I know nothing
TFS Developer
Joined
May 30, 2009
Messages
8,112
Solutions
218
Reaction score
4,031
show 0.4 xml and lua part of the thing you are trying to replicate on 1.x and it will be easier for us to help
 
OP
OP
Roddet

Roddet

::continue::
Premium User
Joined
May 1, 2013
Messages
486
Solutions
33
Reaction score
224
Location
mx
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:
Top