Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import es
- import os
- import random
- gamedir = es.ServerVar('eventscripts_gamedir')
- sounddir = os.path.join(str(gamedir), 'sound')
- addonsounddir = os.path.join(sounddir, 'endsounds')
- tsounddir = os.path.join(addonsounddir, 'tsounds')
- ctsounddir = os.path.join(addonsounddir, 'ctsounds')
- tpath = os.path.join('endsounds', 'tsounds')
- ctpath = os.path.join('endsounds', 'ctsounds')
- if not os.path.isdir(addonsounddir):
- os.mkdir(addonsounddir)
- if not os.path.isdir(tsounddir):
- os.mkdir(tsounddir)
- if not os.path.isdir(ctsounddir):
- os.mkdir(ctsounddir)
- tsoundfiles = []
- for tfile in os.listdir(tsounddir):
- fl = tfile.lower()
- if fl.endswith('.mp3') or fl.endswith('.wav'):
- fp = os.path.join(tpath, tfile)
- tsoundfiles.append(fp)
- es.dbgmsg(1, '[ENDSOUND] Found %i sounds for Terrorists' % len(tsoundfiles))
- ctsoundfiles = []
- for ctfile in os.listdir(ctsounddir):
- flower = ctfile.lower()
- if flower.endswith('.mp3') or flower.endswith('.wav'):
- filep = os.path.join(ctpath, ctfile)
- ctsoundfiles.append(filep)
- es.dbgmsg(1, '[ENDSOUND] Found %i sounds for Counter-Terrorists' % len(ctsoundfiles))
- def downloadFiles():
- for tf in tsoundfiles:
- es.stringtable('downloadables', os.path.join('sound', tf))
- for ctf in ctsoundfiles:
- es.stringtable('downloadables', os.path.join('sound', ctf))
- downloadFiles()
- def es_map_start(ev):
- downloadFiles()
- def round_end(ev):
- winner = ev['winner']
- wd = {'2': tsoundfiles, '3': ctsoundfiles}
- if wd.has_key(winner):
- wfiles = wd[winner]
- wsound = random.choice(wfiles)
- for player in es.getUseridList():
- es.playsound(player, wsound, 1.0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement