示例#1
0
def keygroupsort_cmd(args):
    if len(args) > 1:
        keygroup = args[0]
        if es.exists('keygroup', keygroup):
            dc = {}
            kv = keyvalues.getKeyGroup(keygroup)
            sortfield = args[1]
            if es.exists('keyvalue', keygroup, kv.keys()[0], sortfield) or keygroup == sortfield:
                if len(args) > 3:
                    sortorder = 'asc' if args[2].lower() == 'asc' else 'des'
                    sorttype = '#alpha' if args[3].lower() == '#alpha' else '#numeric'
                else:
                    sortorder = 'des'
                    sorttype = '#numeric'
                for key in kv.keys():
                    dc[key] = {}
                    for keyvalue in kv[key].keys():
                        dc[key][keyvalue] = kv[key][keyvalue]
                if keygroup == sortfield:
                    if sortorder == 'asc' and sorttype == '#alpha':
                        keylist = sorted(dc.keys())
                    elif sortorder == 'des' and sorttype == '#alpha':
                        keylist = sorted(dc.keys(), reverse=True)
                    elif sortorder == 'asc' and sorttype == '#numeric':
                        keylist = sorted(dc.keys(), key=lambda x: int(x) if str(x).isdigit() else x)
                    else:
                        keylist = sorted(dc.keys(), key=lambda x: int(x) if str(x).isdigit() else x, reverse=True)
                else:
                    if sortorder == 'asc' and sorttype == '#alpha':
                        keylist = map(lambda x: x[0], sorted(dc.items(), key=lambda x: x[1][sortfield]))
                    elif sortorder == 'des' and sorttype == '#alpha':
                        keylist = map(lambda x: x[0], sorted(dc.items(), key=lambda x: x[1][sortfield], reverse=True))
                    elif sortorder == 'asc' and sorttype == '#numeric':
                        keylist = map(lambda x: x[0], sorted(dc.items(), key=lambda x: int(x[1][sortfield]) if str(x[1][sortfield]).isdigit() else x[1][sortfield]))
                    else:
                        keylist = map(lambda x: x[0], sorted(dc.items(), key=lambda x: int(x[1][sortfield]) if str(x[1][sortfield]).isdigit() else x[1][sortfield], reverse=True))
                # Let's re-create our keygroup with classic ES commands 
                es.keygroupdelete(keygroup)
                es.keygroupcreate(keygroup)
                for key in keylist:
                    es.keycreate(keygroup, key)
                    for keyvalue in dc[key].keys():
                        es.keysetvalue(keygroup, key, keyvalue, dc[key][keyvalue])
            else:
                es.dbgmsg(0, 'keygroupsort: Invalid field to sort provided: %s' % sortfield)
        else:
            es.dbgmsg(0, 'keygroupsort: Invalid keygroup provided: %s' % keygroup)
    else:
        es.dbgmsg(0, 'keygroupsort: Not enough arguments to keygroupsort. Syntax: keygroupsort <keygroup> <field to sort> [<des/asc #numeric/#alpha>]')
def keygroupsort_cmd(args):
    if len(args) > 1:
        keygroup = args[0]
        if es.exists('keygroup', keygroup):
            dc = {}
            kv = keyvalues.getKeyGroup(keygroup)
            sortfield = args[1]
            if es.exists('keyvalue', keygroup, list(kv.keys())[0], sortfield) or keygroup == sortfield:
                if len(args) > 3:
                    sortorder = 'asc' if args[2].lower() == 'asc' else 'des'
                    sorttype = '#alpha' if args[3].lower() == '#alpha' else '#numeric'
                else:
                    sortorder = 'des'
                    sorttype = '#numeric'
                for key in list(kv.keys()):
                    dc[key] = {}
                    for keyvalue in list(kv[key].keys()):
                        dc[key][keyvalue] = kv[key][keyvalue]
                if keygroup == sortfield:
                    if sortorder == 'asc' and sorttype == '#alpha':
                        keylist = sorted(dc.keys())
                    elif sortorder == 'des' and sorttype == '#alpha':
                        keylist = sorted(list(dc.keys()), reverse=True)
                    elif sortorder == 'asc' and sorttype == '#numeric':
                        keylist = sorted(list(dc.keys()), key=lambda x: int(x) if str(x).isdigit() else x)
                    else:
                        keylist = sorted(list(dc.keys()), key=lambda x: int(x) if str(x).isdigit() else x, reverse=True)
                else:
                    if sortorder == 'asc' and sorttype == '#alpha':
                        keylist = [x[0] for x in sorted(list(dc.items()), key=lambda x: x[1][sortfield])]
                    elif sortorder == 'des' and sorttype == '#alpha':
                        keylist = [x[0] for x in sorted(list(dc.items()), key=lambda x: x[1][sortfield], reverse=True)]
                    elif sortorder == 'asc' and sorttype == '#numeric':
                        keylist = [x[0] for x in sorted(list(dc.items()), key=lambda x: int(x[1][sortfield]) if str(x[1][sortfield]).isdigit() else x[1][sortfield])]
                    else:
                        keylist = [x[0] for x in sorted(list(dc.items()), key=lambda x: int(x[1][sortfield]) if str(x[1][sortfield]).isdigit() else x[1][sortfield], reverse=True)]
                # Let's re-create our keygroup with classic ES commands 
                es.keygroupdelete(keygroup)
                es.keygroupcreate(keygroup)
                for key in keylist:
                    es.keycreate(keygroup, key)
                    for keyvalue in list(dc[key].keys()):
                        es.keysetvalue(keygroup, key, keyvalue, dc[key][keyvalue])
            else:
                es.dbgmsg(0, 'keygroupsort: Invalid field to sort provided: %s' % sortfield)
        else:
            es.dbgmsg(0, 'keygroupsort: Invalid keygroup provided: %s' % keygroup)
    else:
        es.dbgmsg(0, 'keygroupsort: Not enough arguments to keygroupsort. Syntax: keygroupsort <keygroup> <field to sort> [<des/asc #numeric/#alpha>]')
示例#3
0
def make_player(steamid):
    es.keygroupdelete(steamid)
    es.keygroupcreate(steamid)
    es.keycreate(steamid, "player_data")
    count = 0
    while count < 200:
        count += 1
        es.keysetvalue(steamid, "player_data", "item%s" %(count), 0)
    es.keysetvalue(steamid, "player_data", "callname", "[Beginner]")
    es.keysetvalue(steamid, "player_data", "xp", 0)
    es.keysetvalue(steamid, "player_data", "nextxp", 9999)
    es.keysetvalue(steamid, "player_data", "skin", "sas")
    es.keysetvalue(steamid, "player_data", "primary_weapon", "none")
    es.keysetvalue(steamid, "player_data", "secondary_weapon", "none")
    es.keysetvalue(steamid, "player_data", "gore", 1)
    es.keysetvalue(steamid, "player_data", "remember_map", 0)
    es.keysetvalue(steamid, "player_data", "ban_time", 0)
    es.keysetvalue(steamid, "player_data", "story", 0)
示例#4
0
def make_player(steamid):
    es.keygroupdelete(steamid)
    es.keygroupcreate(steamid)
    es.keycreate(steamid, "player_data")
    count = 0
    while count < 200:
        count += 1
        es.keysetvalue(steamid, "player_data", "item%s" % (count), 0)
    es.keysetvalue(steamid, "player_data", "callname", "[Beginner]")
    es.keysetvalue(steamid, "player_data", "xp", 0)
    es.keysetvalue(steamid, "player_data", "nextxp", 9999)
    es.keysetvalue(steamid, "player_data", "skin", "sas")
    es.keysetvalue(steamid, "player_data", "primary_weapon", "none")
    es.keysetvalue(steamid, "player_data", "secondary_weapon", "none")
    es.keysetvalue(steamid, "player_data", "gore", 1)
    es.keysetvalue(steamid, "player_data", "remember_map", 0)
    es.keysetvalue(steamid, "player_data", "ban_time", 0)
    es.keysetvalue(steamid, "player_data", "story", 0)
def keygrouprand_cmd(args):
    if len(args) > 0:
        keygroup = args[0]
        if es.exists('keygroup', keygroup):
            if len(args) > 1:
                target = args[1]
            else:
                target = '#all'
            if target in ['#key', '#keyvalue', '#all']:
                dc = {}
                kv = keyvalues.getKeyGroup(keygroup)
                if len(args) > 2 and args[2].isdigit():
                    keylimit = int(args[2])
                else:
                    keylimit = len(list(kv.keys()))
                for key in list(kv.keys()):
                    dc[key] = {}
                    for keyvalue in list(kv[key].keys()):
                        dc[key][keyvalue] = kv[key][keyvalue]
                if target == '#all' or target == '#key':
                    keylist = random.sample(list(dc.keys()), keylimit)
                else:
                    keylist = list(dc.keys())[:keylimit]
                # Let's re-create our keygroup with classic ES commands 
                es.keygroupdelete(keygroup)
                es.keygroupcreate(keygroup)
                for key in keylist:
                    es.keycreate(keygroup, key)
                    if target == '#all' or target == '#keyvalue':
                        for keyvalue in random.sample(list(dc[key].keys()), len(dc[key])):
                            es.keysetvalue(keygroup, key, keyvalue, dc[key][keyvalue])
                    else:
                        for keyvalue in list(dc[key].keys()):
                            es.keysetvalue(keygroup, key, keyvalue, dc[key][keyvalue])
            else:
                es.dbgmsg(0, 'keygrouprand: Invalid target provided: %s' % target)
        else:
            es.dbgmsg(0, 'keygrouprand: Invalid keygroup provided: %s' % keygroup)
    else:
        es.dbgmsg(0, 'keygrouprand: Not enough arguments to keygrouprand. Syntax: keygrouprand <keygroup> [#key/#keyvalue/#all] [keylimit]')
示例#6
0
def keycreate(argv):
  es.keycreate(*argv)
示例#7
0
def keygroupsort_cmd(args):
    if len(args) > 1:
        keygroup = args[0]
        if es.exists("keygroup", keygroup):
            dc = {}
            kv = keyvalues.getKeyGroup(keygroup)
            sortfield = args[1]
            if es.exists("keyvalue", keygroup, kv.keys()[0], sortfield) or keygroup == sortfield:
                if len(args) > 3:
                    sortorder = "asc" if args[2].lower() == "asc" else "des"
                    sorttype = "#alpha" if args[3].lower() == "#alpha" else "#numeric"
                else:
                    sortorder = "des"
                    sorttype = "#numeric"
                for key in kv.keys():
                    dc[key] = {}
                    for keyvalue in kv[key].keys():
                        dc[key][keyvalue] = kv[key][keyvalue]
                if keygroup == sortfield:
                    if sortorder == "asc" and sorttype == "#alpha":
                        keylist = sorted(dc.keys())
                    elif sortorder == "des" and sorttype == "#alpha":
                        keylist = sorted(dc.keys(), reverse=True)
                    elif sortorder == "asc" and sorttype == "#numeric":
                        keylist = sorted(dc.keys(), key=lambda x: int(x) if str(x).isdigit() else x)
                    else:
                        keylist = sorted(dc.keys(), key=lambda x: int(x) if str(x).isdigit() else x, reverse=True)
                else:
                    if sortorder == "asc" and sorttype == "#alpha":
                        keylist = map(lambda x: x[0], sorted(dc.items(), key=lambda x: x[1][sortfield]))
                    elif sortorder == "des" and sorttype == "#alpha":
                        keylist = map(lambda x: x[0], sorted(dc.items(), key=lambda x: x[1][sortfield], reverse=True))
                    elif sortorder == "asc" and sorttype == "#numeric":
                        keylist = map(
                            lambda x: x[0],
                            sorted(
                                dc.items(),
                                key=lambda x: int(x[1][sortfield])
                                if str(x[1][sortfield]).isdigit()
                                else x[1][sortfield],
                            ),
                        )
                    else:
                        keylist = map(
                            lambda x: x[0],
                            sorted(
                                dc.items(),
                                key=lambda x: int(x[1][sortfield])
                                if str(x[1][sortfield]).isdigit()
                                else x[1][sortfield],
                                reverse=True,
                            ),
                        )
                # Let's re-create our keygroup with classic ES commands
                es.keygroupdelete(keygroup)
                es.keygroupcreate(keygroup)
                for key in keylist:
                    es.keycreate(keygroup, key)
                    for keyvalue in dc[key].keys():
                        es.keysetvalue(keygroup, key, keyvalue, dc[key][keyvalue])
            else:
                es.dbgmsg(0, "keygroupsort: Invalid field to sort provided: %s" % sortfield)
        else:
            es.dbgmsg(0, "keygroupsort: Invalid keygroup provided: %s" % keygroup)
    else:
        es.dbgmsg(
            0,
            "keygroupsort: Not enough arguments to keygroupsort. Syntax: keygroupsort <keygroup> <field to sort> [<des/asc #numeric/#alpha>]",
        )