def welcome_handler(userid, choice, popupname): # If they selected to see the included addons list if choice == 1: # If the menu exists, delete it if popuplib.exists('gg_welcome_include'): popuplib.delete('gg_welcome_include') # Create an easylist instance menu = popuplib.easylist('gg_welcome_include', get_loaded_addon_list('included')) elif choice == 2: # If the menu exists, delete it if popuplib.exists('gg_welcome_custom'): popuplib.delete('gg_welcome_custom') # Create an easylist instance menu = popuplib.easylist('gg_welcome_custom', get_loaded_addon_list('custom')) # Set the menu's title menu.settitle(title) # When the menu is closed, go back to the welcome message menu.submenu(0, 'gg_welcome') # Set the timeout for the menu menu.timeout('send', int(gg_welcome_msg_timeout)) menu.timeout('view', int(gg_welcome_msg_timeout)) # Send the popup menu.send(userid)
def welcome_handler(userid, choice, popupname): # If they selected to see the included addons list if choice == 1: # If the menu exists, delete it if popuplib.exists('gg_welcome_include'): popuplib.delete('gg_welcome_include') # Create an easylist instance menu = popuplib.easylist('gg_welcome_include', get_loaded_addon_list('included')) elif choice == 2: # If the menu exists, delete it if popuplib.exists('gg_welcome_custom'): popuplib.delete('gg_welcome_custom') # Create an easylist instance menu = popuplib.easylist('gg_welcome_custom', get_loaded_addon_list('custom')) # Set the menu's title menu.settitle(title) # When the menu is closed, go back to the welcome message menu.submenu(0, 'gg_welcome') # Set the timeout for the menu menu.timeout('send', int(gg_welcome_msg_timeout)) menu.timeout('view', int(gg_welcome_msg_timeout)) # Send the popup menu.send(userid)
def cmd_commands(userid,args): if popuplib.exists('xs_commands_list'): popuplib.send('xs_commands_list',userid) else: c = popuplib.easylist('xs_commands_list') c.settitle(text.getSimple('command list','title')) for x in xs.reggedccmd: c.additem(text.getTokenString('command list','console',[('command',x)])) for x in xs.reggedscmd: c.additem(text.getTokenString('command list','chat',[('command',x)])) c.send(userid)
def displayTop(userid,x,method): pplchck('xs_top_list_%s' % userid) topplayers = xs.getToplist(x,method) totalplayers = len(xs.players) toplist = popuplib.easylist('xs_top_list_%s' % userid) toplist.settitle('Top %s (%s):' % (x,method)) i = 1 for player in topplayers: toplist.additem(text.getCmdString(player[1],'top',method,player[0],i,totalplayers)) i += 1 toplist.send(userid)
def loadMenus(): p = popuplib.easymenu('xs_help_menu','_popup_choice',helpCallback) p.settitle(text.getSimple('helpmenu','title')) p.addoption('about',text.getSimple('helpmenu','about')) pattern = re.compile('__\w*__') doccmds = filter(lambda x: not pattern.search(x),text.strings['help']) for key in doccmds: p.addoption(key,key) p.addoption('nodoc',text.getSimple('helpmenu','nodoc')) nodocl = [text.getSimple('helpmenu','nodoc')] + filter(lambda x: x not in doccmds,uniquecommands) p = popuplib.easylist('xs_doc_nodoc', nodocl if len(nodocl) > 1 else [text.getSimple('helpmenu','no_nodoc')]) p.settitle(text.getSimple('helpmenu','nodoc')) p = popuplib.easylist('xs_doc_about',text.getHelp('__about__')) p.settitle(text.getHelp('__about__title__',[('version',info.version)])[0]) for command in text.strings['help']: p = popuplib.easylist('xs_doc_%s' % command,text.getHelp(command)) p.settitle('eXtended Stats Help: %s' % command)
def weaponstats(userid,choice,popupid): pplchck('xs_ws_%s_%s' % (choice,userid)) p = popuplib.easylist('xs_ws_%s_%s' % (choice,userid)) p.settitle('Weaponstats - %s' % choice) weapons.execute("SELECT kills,damage%s FROM xs_weapons WHERE weapon='%s'" % (',bought' if EE else '',choice)) row = weapons.fetchone() p.additem('Kills: %s' % row[0]) p.additem('Damage: %s' % row[1]) if EE: p.additem('Bought: %s' % row[2]) p.send(userid)
def myweaponstats(userid,choice,popupid): pplchck('xs_ws_my%s_%s' % (choice,userid)) steamid = es.getplayersteamid(userid) p = popuplib.easylist('xs_ws_my%s_%s' % (choice,userid)) p.settitle('Weaponstats - My %s' % choice) weapons.execute("SELECT kill_%s,death_%s,damage_%s%s FROM xs_main WHERE steamid='%s'" % (choice,choice,choice,(',bought_%s' % choice) if EE else '',steamid)) row = weapons.fetchone() p.additem('Kills: %s' % row[0]) p.additem('Killed: %s' % row[1]) p.additem('Damage: %s' % row[2]) if EE: p.additem('Bought: %s' % row[3]) p.send(userid)
def cmd_statsme(userid,args): if str(userid) in xs.pending: es.tell(userid,txt.getSimple('messages','sorry_pending')) return steamid = es.getplayersteamid(userid) methods_used = [] toprank = None lowrank = None refresh = True for method in xs.methods: rank,score,allplayers = xs.getRankScore(steamid,method,refresh) refresh = False # if toprank is None OR rank is smaller (smaller number = higher rank) than toprank if not toprank or rank < toprank[0]: toprank = (rank,score,method) if not lowrank or rank > lowrank[0]: lowrank = (rank,score,method) methods_used.append(toprank[2]) methods_used.append(lowrank[2]) defaultmethod = xs.getMethod() defaultrank,defaultscore = None,None if defaultmethod not in methods_used: defaultrank,defaultscore,allplageyers = xs.getRankScore(steamid,defaultmethod,refresh) refresh = False methods_used.append(defaultmethod) personalrank,personalscore = None,None settings_method = xs.players.query(steamid,'settings_method') if settings_method in xs.methods.keys() and settings_method not in methods_used: personalrank,personalscore,allplayers = xs.getRankScore(steamid,settings_method,refresh) refresh = False methods_used.append(settings_method) pplchck('xs_statshim_%s' % userid) statshim = popuplib.easylist('xs_statshim_%s' % userid) statshim.settitle(text.getSimple('statsme','title')) if defaultrank: statshim.additem(text.getCmdString(steamid,'statsme',xs.dcfg['default_method'],defaultscore,defaultrank,allplayers)) if personalrank: statshim.additem(text.getCmdString(steamid,'statsme',settings_method,personalscore,personalrank,allplayers)) statshim.additem(text.getCmdString(steamid,'statsme_toprank',toprank[2],toprank[1],toprank[0],allplayers)) statshim.additem(text.getCmdString(steamid,'statsme_lowrank',lowrank[2],lowrank[1],lowrank[0],allplayers)) if bool(xs.dcfg['statsme_methods']): mlist = xs.dcfg.as_list('statsme_methods') for method in filter(lambda x: (x in xs.methods or x in xs.players.columns) and x not in methods_used,mlist): methods_used.append(method) rank,score,allplayers = xs.getRankScore(steamid,method,refresh) refresh = False statshim.additem(text.getCmdString(steamid,'statsme',method,score,rank,allplayers)) statshim.send(userid)
def menus(): pplchck('xs_methods_list') m = popuplib.easylist('xs_methods_list', xs.methods.keys()) m.settitle(text.getSimple('methodslist','title'))