import es import random import keymenulib import gamethread import playerlib info = es.AddonInfo() info.name = 'CutWires' info.version = '2.1' info.url = 'forums.mattie.info/cs/forums/viewtopic.php?t=12310' info.basename = 'CutWires' info.author = '7355608' cw_haskit,cw_rightwire,cw_c4index = 0, 0, 0 cw_blankwires = [] cw_blankwireskit = [] """ **************************************************************************************************************** """ """ ****** Config Section ***** """ """ **************************************************************************************************************** """ """ These are for non-random settings """ """ **************************************************************************************************************** """ cw_wires = 5 cw_blanks = 2 """ **************************************************************************************************************** """ """ These are for random settings for non-random set the mins to 0, anything higher will use only the random settings """ """ Setting the max random to 0 will result it being set to the total length of your colors list """ """ The random min is 3, any lower and it will be set to 0 """ """ **************************************************************************************************************** """ cw_blanksmin = 1 cw_randommin = 5 cw_randommax = 9 cw_badwiresmin = 1 """ **************************************************************************************************************** """ """ This enables random number of blanks 0/1 """ """ **************************************************************************************************************** """ cw_randomblanks = 1 """ **************************************************************************************************************** """ """ This is the list of wire colors that are shuffled and chosen from randomly each round """ """ You can add as many as you want to this. You cannot set max wires past the number of colors in this list """ """ By default there are 11 colors in this list, however I do not suggest using more then 9 of them at a time """ """ The mod will support probably as many as you like, the menus just don't look as pretty after 9. """ """ I would also suggest you do not duplicate anything in this list. It may cause problems. """ """ **************************************************************************************************************** """ cw_colors = ["Yellow", "Red", "Blue", "Orange", "Brown", "Purple", "Green", "Black", "Indigo", "Magenta", "White"] """ **************************************************************************************************************** """ """ **************************************************************************************************************** """ """ ******* End of Config ***** """ """ **************************************************************************************************************** """ """ **************************************************************************************************************** """ def load(): global cw_blanks,cw_wires,cw_badwiresmin,cw_blanksmin,cw_randommax,cw_randommin es.server.cmd('es_xset cw_version 2.1') es.server.cmd('es_makepublic cw_version') if keymenulib.exists('wiremenu'): keymenulib.delete('wiremenu') if es.exists('keygroup','cw_menu'): es.keygroupdelete('cw_menu') es.keygroupcreate('cw_menu') if cw_blanks < 0: cw_blanks = 0 elif cw_blanks > cw_wires and cw_wires > 1: cw_blanks = cw_wires - 2 elif cw_wires < 2 and cw_blanks > 0: cw_blanks = 0 if cw_wires < 2: cw_wires = 2 elif cw_wires > len(cw_colors): cw_wires = len(cw_colors) if cw_badwiresmin < 1: cw_badwiresmin = 1 elif cw_badwiresmin >= cw_wires and cw_randommin == 0: cw_badwiresmin = cw_wires - 1 elif cw_badwiresmin >= cw_randommin: cw_badwiresmin = cw_randommin - 1 cw_tmp = cw_badwiresmin + cw_blanksmin cw_tmp += 1 if cw_randommin < 3: cw_randommin = 0 elif cw_randommin >= len(cw_colors): cw_randommin = len(cw_colors) - 1 elif cw_randommin < cw_tmp: cw_randommin = cw_tmp if len(cw_colors) < cw_randommax <= 0: cw_randommax = len(cw_colors) elif cw_randommax < cw_randommin: cw_randommax = cw_randommin + 1 def bomb_begindefuse(event_var): global cw_c4index cw_c4index = es.getentityindex('planted_c4') cw_defuser = playerlib.getPlayer(event_var['userid']) if cw_defuser.get('defuser'): keymenulib.create('wiremenu','cw_haskit',cw_cutwire,'cw_menu2','#keyvalue menutxt','#key','Cut A Wire?') if keymenulib.exists('wiremenu'): keymenulib.send('wiremenu',event_var['userid']) else: keymenulib.create('wiremenu','cw_haskit',cw_cutwire,'cw_menu','#keyvalue menutxt','#key','Cut A Wire?') if keymenulib.exists('wiremenu'): keymenulib.send('wiremenu',event_var['userid']) def bomb_abortdefuse(event_var): if keymenulib.exists('wiremenu'): keymenulib.unsend('wiremenu',event_var['userid']) keymenulib.delete('wiremenu') def round_start(event_var): global cw_blankwires,cw_rightwire,cw_c4index,cw_wires,cw_blanks,cw_colors,cw_haskit cw_haskit,cw_blanksmax,cw_rightwire,cw_c4index = 0, 0, 0, 0 cw_blankwires = [] cw_tmplist = [] random.shuffle(cw_colors) if es.exists('keygroup','cw_menu'): es.keygroupdelete('cw_menu') es.keygroupcreate('cw_menu') if es.exists('keygroup','cw_menu2'): es.keygroupdelete('cw_menu2') es.keygroupcreate('cw_menu2') if len(cw_colors) > cw_randommin > 1: cw_wires = random.randint(cw_randommin,cw_randommax) if cw_wires > 2 and cw_randomblanks: cw_blanksmax = cw_wires - 1 cw_blanksmax = cw_blanksmax - cw_badwiresmin cw_blanks = random.randint(cw_blanksmin,cw_blanksmax) if keymenulib.exists('wiremenu'): keymenulib.delete('wiremenu') if keymenulib.exists('wiremenu2'): keymenulib.delete('wiremenu2') i = 0 while i < cw_wires: s = str(i) es.keycreate('cw_menu',s) es.keysetvalue('cw_menu',s,'menutxt',cw_colors[i]) es.keycreate('cw_menu2',s) es.keysetvalue('cw_menu2',s,'menutxt',cw_colors[i]) cw_tmplist += s i += 1 cw_blankwires = random.sample(cw_tmplist,cw_blanks + 1) cw_rightwire = cw_blankwires.pop() i = 0 while i < len(cw_blankwires): es.keydelete('cw_menu2',cw_blankwires[i]) i += 1 def cw_cutagain(cw_tmpuserid): keymenulib.send('wiremenu',cw_tmpuserid) def cw_cutwire(cw_userid, cw_wirecut, cw_menuid): global cw_menu cw_defusing = int(cw_userid) if cw_wirecut == cw_rightwire: es.setindexprop(cw_c4index,'CPlantedC4.m_flDefuseCountDown',1.0) elif cw_wirecut in cw_blankwires: es.sexec(cw_defusing,'menuselect 10') keymenulib.delete('wiremenu') es.keydelete('cw_menu',cw_wirecut) keymenulib.create('wiremenu','cw_placeholder',cw_cutwire,'cw_menu','#keyvalue menutxt','#key','Cut A Wire?') gamethread.delayed(0.1,cw_cutagain,cw_defusing) else: es.setindexprop(cw_c4index,'CPlantedC4.m_flC4Blow',1.0)