• 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.2] Which function to use

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
Hi folks, which function can I use to broadcast a message every 20th of the month and with a random time which can vary from 3 am until 8 pm.

Something with %d, don't know. I was trying read this tutorial but I did not able to make it.

Thanks.
 
Code:
local curdate = os.date("*t")
local changehour = true
if curdate.day > 20 then
    curdate.month = curdate.month%12 + 1
elseif curdate.day == 20 then
    changehour = false
end

curdate.day = 20
curdate.min = 0
curdate.sec = 0
if changehour then
    curdate.hour = 3
elseif curdate.hour < 3 then
    curdate.hour = 3
end

local threeam = os.time(curdate)
curdate.hour = 20
local eightpm = os.time(curdate)
local rd = math.random(threeam, eightpm)

if rd-os.time() > 0 then
    addEvent(broadcastFunction, (rd-os.time())*1000)
    print(string.format("Broadcast set for: %s", os.date("%a %d %B %Y, %H:%M", rd)))
end



On every startup. should work
 
Last edited:
Back
Top