Advertisement
Brainsucker

Untitled

Oct 9th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.57 KB | None | 0 0
  1. import es
  2. import os
  3. import random
  4.  
  5.  
  6. gamedir = es.ServerVar('eventscripts_gamedir')
  7. sounddir = os.path.join(str(gamedir), 'sound')
  8. addonsounddir = os.path.join(sounddir, 'endsounds')
  9. tsounddir = os.path.join(addonsounddir, 'tsounds')
  10. ctsounddir = os.path.join(addonsounddir, 'ctsounds')
  11.  
  12. tpath = os.path.join('endsounds', 'tsounds')
  13. ctpath = os.path.join('endsounds', 'ctsounds')
  14.  
  15.  
  16. if not os.path.isdir(addonsounddir):
  17.     os.mkdir(addonsounddir)
  18.  
  19. if not os.path.isdir(tsounddir):
  20.     os.mkdir(tsounddir)
  21.    
  22. if not os.path.isdir(ctsounddir):
  23.     os.mkdir(ctsounddir)
  24.    
  25.    
  26. tsoundfiles = []
  27. for tfile in os.listdir(tsounddir):
  28.     fl = tfile.lower()
  29.     if fl.endswith('.mp3') or fl.endswith('.wav'):
  30.         fp = os.path.join(tpath, tfile)
  31.         tsoundfiles.append(fp)
  32. es.dbgmsg(1, '[ENDSOUND] Found %i sounds for Terrorists' % len(tsoundfiles))
  33.  
  34. ctsoundfiles = []
  35. for ctfile in os.listdir(ctsounddir):
  36.     flower = ctfile.lower()
  37.     if flower.endswith('.mp3') or flower.endswith('.wav'):
  38.         filep = os.path.join(ctpath, ctfile)
  39.         ctsoundfiles.append(filep)
  40. es.dbgmsg(1, '[ENDSOUND] Found %i sounds for Counter-Terrorists' % len(ctsoundfiles))
  41.  
  42.  
  43. def downloadFiles():
  44.     for tf in tsoundfiles:
  45.         es.stringtable('downloadables', os.path.join('sound', tf))
  46.        
  47.     for ctf in ctsoundfiles:
  48.         es.stringtable('downloadables', os.path.join('sound', ctf))
  49.  
  50.        
  51. downloadFiles()
  52.  
  53.  
  54. def es_map_start(ev):
  55.     downloadFiles()
  56.    
  57. def round_end(ev):
  58.     winner = ev['winner']
  59.     wd = {'2': tsoundfiles, '3': ctsoundfiles}
  60.     if wd.has_key(winner):
  61.         wfiles = wd[winner]
  62.         wsound = random.choice(wfiles)
  63.         for player in es.getUseridList():
  64.             es.playsound(player, wsound, 1.0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement