Help with Delay
Posted: Mon May 23, 2016 1:28 am
Hey,
Im currently thinking about writing up a script which prints the time until mapchange
It seems like the "named delays" from this thread viewtopic.php?p=6622#p6622 are not realy canceling the Delay after the mp_timelimit has been changed, so How do I properly use here the Delay function?
Im currently thinking about writing up a script which prints the time until mapchange
Syntax: Select all
mp_timelimit = 0
mapStartTime = 0
@OnLevelInit
def OnMapStart(mapName):
global mapStartTime
mapStartTime = time.time()
startGamethreads()
def startGamethreads():
value = float(mp_timelimit)
endTime = mapStartTime + 60 * value
timeleft = endTime - time.time()
named_delays.cancel_delay("EndMapAnnouncer")
named_delays.delay("EndMapAnnouncer", timeleft-120, announceEndMap, 120)
named_delays.delay("EndMapAnnouncer", timeleft-60, announceEndMap, 60)
named_delays.delay("EndMapAnnouncer", timeleft-30, announceEndMap, 30)
named_delays.delay("EndMapAnnouncer", timeleft-10, announceEndMap, 10)
def announceEndMap(timeleft):
#do anything
@Event("server_cvar")
def server_cvar(GameEvent):
global mp_timelimit
if GameEvent["cvarname"] == "mp_timelimit":
mp_timelimit = int(GameEvent["cvarvalue"])
startGamethreads()
It seems like the "named delays" from this thread viewtopic.php?p=6622#p6622 are not realy canceling the Delay after the mp_timelimit has been changed, so How do I properly use here the Delay function?