Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- import time
- import usermsg
- # import popuplib
- import es
- class TimeCounter(threading.Thread):
- round_ended = False
- def __init__(self):
- threading.Thread.__init__(self)
- self.lock = threading.Lock()
- def run(self):
- start_time = time.time()
- es.msg('#multi', 'Thread has been started')
- while True:
- self.lock.acquire()
- if TimeCounter.round_ended:
- break
- self.lock.release()
- tdiff = time.time() - start_time
- round_time = es.ServerVar('mp_roundtime')
- round_time_int = int(round_time)
- round_time_seconds = round_time_int * 60
- remaining_time = round_time_seconds - tdiff
- for player in es.getUseridList():
- usermsg.hudhint(player, 'Time elapsed: %.2f\nTime remaining: %.2f' % (tdiff, remaining_time))
- # popuplib.quicksend(0,
- es.msg('#multi', 'Thread has been stopped')
- def round_start(ev):
- TimeCounter.round_ended = False
- tc = TimeCounter()
- tc.start()
- def round_end(ev):
- TimeCounter.round_ended = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement