Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | None | 0 0
  1. import es
  2. import cmdlib
  3. import popuplib
  4. import random
  5. import votelib
  6.  
  7. VoteNo    = {}
  8. saveMa = set()
  9. vote_maps = 6 # random maps choosen from mapfile
  10.  
  11. def load():
  12.     cmdlib.registerSayCommand('nominate', NominateV, "Nominate a Map")
  13.     cmdlib.registerSayCommand('rtv', rockV, "rockthevotes")
  14.  
  15. def NominateV(userid, args):
  16.     nominationmenu = popuplib.easymenu('nomination_menu', '_popup_choice', nomination_result)
  17.     nominationmenu.settitle('Nomination Menu')
  18.     f = open(es.getString('eventscripts_gamedir') + '/mapcycle.txt')
  19.     maps = f.read().split('\n')
  20.     f.close()
  21.     for x in maps:
  22.         nominationmenu.addoption(x, x)
  23.     nominationmenu.send(userid)
  24.    
  25.    
  26. def nomination_result(userid, choice, popupname):
  27.     global VoteNo
  28.     steamid = es.getplayersteamid(userid)
  29.     if not VoteNo.has_key(choice):
  30.         VoteNo[choice] = []
  31.     if not steamid in VoteNo[choice]:
  32.         VoteNo[choice].append(steamid)
  33.         saveMa.add(choice)
  34.  
  35. def rockV(userid, args):
  36.     for choice in VoteNo:
  37.         if len(VoteNo[choice]) >= round(es.getplayercount()/2)+ 1:
  38.             rtv_add()
  39.  
  40.  
  41.  
  42. def rtv_add():
  43.     random_maps = []
  44.     f = open(es.getString('eventscripts_gamedir') + '/mapcycle.txt')
  45.     maps = f.read().split('\n')
  46.     f.close()
  47.     for x in xrange(0, min( len(saveMa), int(vote_maps))):
  48.         random.shuffle(saveMa)
  49.         random_maps.append(saveMa.pop(0))
  50.     maps = filter(lambda x: x not in random_maps, maps)
  51.     while len(random_maps) < vote_maps and maps:
  52.         random.shuffle(maps)
  53.         random_maps.append(maps.pop(0))
  54.     random_maps = sorted(random_maps)
  55.     myVote = votelib.create('rtv_vote', vote_end, vote_submit)
  56.     myVote.setquestion('RTV?')
  57.     for mapName in random_maps:
  58.         myVote.addoption(mapName, mapName)
  59.     myVote.start(90)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement