local conf = include("sca_config.lua") local timeSynced = false local function sca_loop() local intervalOffset = os.time() % 60 print("intervalOffset: ", intervalOffset) -- If the function isn't called at HH:MM:00 then readjust the interval if intervalOffset > 0 then timeSynced = false print("[BuildBox] serverChatAdverts: Warning! Timer has not been called at HH:MM:00!! Readjusting interval...") timer.Adjust("sca_chatPrintService", 60 - intervalOffset) -- Otherwise, if timeSynced is false (interval was shorter than 60 seconds) then readjust interval to 60 seconds else if !timeSynced then timeSynced = true timer.Adjust("sca_chatPrintService", 60) -- else check config and print text to players if there is any else end end end local function sca_setup() print("[BuildBox] serverChatAdverts: Started!") -- Calculate an interval that will call a function on HH:MM:00 print("setup time: ", os.time()) print(os.time() % 60) print(60 - (os.time() % 60)) local interval = 60 - (os.time() % 60) print("setup interval: ", interval) timer.Create("sca_chatPrintService", interval, 0, sca_loop) print("[BuildBox] serverChatAdverts: Initialization completed!") end hook.Add("Initialize", "sca_setup", sca_setup)