Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import es
- import cmdlib
- import popuplib
- import random
- import votelib
- VoteNo = {}
- saveMa = set()
- vote_maps = 6 # random maps choosen from mapfile
- def load():
- cmdlib.registerSayCommand('nominate', NominateV, "Nominate a Map")
- cmdlib.registerSayCommand('rtv', rockV, "rockthevotes")
- def NominateV(userid, args):
- nominationmenu = popuplib.easymenu('nomination_menu', '_popup_choice', nomination_result)
- nominationmenu.settitle('Nomination Menu')
- f = open(es.getString('eventscripts_gamedir') + '/mapcycle.txt')
- maps = f.read().split('\n')
- f.close()
- for x in maps:
- nominationmenu.addoption(x, x)
- nominationmenu.send(userid)
- def nomination_result(userid, choice, popupname):
- global VoteNo
- steamid = es.getplayersteamid(userid)
- if not VoteNo.has_key(choice):
- VoteNo[choice] = []
- if not steamid in VoteNo[choice]:
- VoteNo[choice].append(steamid)
- saveMa.add(choice)
- def rockV(userid, args):
- for choice in VoteNo:
- if len(VoteNo[choice]) >= round(es.getplayercount()/2)+ 1:
- rtv_add()
- def rtv_add():
- random_maps = []
- f = open(es.getString('eventscripts_gamedir') + '/mapcycle.txt')
- maps = f.read().split('\n')
- f.close()
- for x in xrange(0, min( len(saveMa), int(vote_maps))):
- random.shuffle(saveMa)
- random_maps.append(saveMa.pop(0))
- maps = filter(lambda x: x not in random_maps, maps)
- while len(random_maps) < vote_maps and maps:
- random.shuffle(maps)
- random_maps.append(maps.pop(0))
- random_maps = sorted(random_maps)
- myVote = votelib.create('rtv_vote', vote_end, vote_submit)
- myVote.setquestion('RTV?')
- for mapName in random_maps:
- myVote.addoption(mapName, mapName)
- myVote.start(90)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement