Exemplo n.º 1
0
def isMember(steamId):
  if not es.exists('keygroup', 'clanMembers'):
    es.keygroupcreate('clanMembers')
    es.keygroupload('clanMembers', '|GlobalBan')

  memberCheck = es.keygetvalue('clanMembers', steamId, 'member')
  if memberCheck == '1':
    return True
  else:
    return False
Exemplo n.º 2
0
 def testKeygroup(self):
     es.keygroupcreate("justice")
     x = es.keygroupgetpointer("justice")
     self.keytest2(x)
     es.keygroupdelete("justice2")
     es.keygroupcreate("justice2")
     x = es.keygroupgetpointer("justice2")
     self.keytest3(x)
     import keyvalues
     y = keyvalues.getKeyGroup("justice2")
     es.keygroupdelete("justice2")
Exemplo n.º 3
0
 def testKeygroup(self):
     es.keygroupcreate("justice")
     x = es.keygroupgetpointer("justice")
     self.keytest2(x)
     es.keygroupdelete("justice2")
     es.keygroupcreate("justice2")
     x = es.keygroupgetpointer("justice2")
     self.keytest3(x)
     import keyvalues
     y = keyvalues.getKeyGroup("justice2")
     es.keygroupdelete("justice2")
Exemplo n.º 4
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, 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>]')
Exemplo n.º 5
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>]')
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
0
def keyfilter_cmd(args):
    if len(args) > 3:
        keygroup = args[0]
        if es.exists('keygroup', keygroup):
            key = args[1]
            if es.exists('key', keygroup, key):
                action = args[2]
                if action in ['not', 'only']:
                    kv = keyvalues.getKeyGroup(keygroup)
                    keyfiltervar = args[3]
                    keyfilterlist = []
                    if len(args) > 4:
                        keyfiltervalue = args[4]
                    else:
                        keyfiltervalue = None
                    if action == 'not':
                        for keyvar in kv[key].keys():
                            if keyfiltervar in keyvar and (str(kv[key][keyvar]) == keyfiltervalue or not keyfiltervalue):
                                keyfilterlist.append(keyvar)
                    elif action == 'only':
                        for keyvar in kv[key].keys():
                            if not keyfiltervar in keyvar or (str(kv[key][keyvar]) != keyfiltervalue and keyfiltervalue):
                                keyfilterlist.append(keyvar)
                    for keyvar in keyfilterlist:
                        if keyvar in kv[key]:
                            kv[key][keyvar] = keyvalues.KeyValues(name=' ')
                    if keyfilterlist:
                        # Let's remove our deleted keys by reloading the keygroup with classic ES commands 
                        es.keygroupsave(keygroup, '|corelib/keyfilter')
                        es.keygroupdelete(keygroup)
                        es.keygroupcreate(keygroup)
                        es.keygroupload(keygroup, '|corelib/keyfilter')
                        os.unlink(es.getAddonPath('corelib/keyfilter')+'/es_%s_db.txt'%keygroup)
                else:
                    es.dbgmsg(0, 'keyfilter: Invalid action provided. Syntax: keyfilter <keygroup> <key> <not/only> <part-of-value-name> [value]')
            else:
                es.dbgmsg(0, 'keyfilter: Invalid key for keygroup "%s" provided: %s' % (keygroup, key))
        else:
            es.dbgmsg(0, 'keyfilter: Invalid keygroup provided: %s' % keygroup)
    else:
        es.dbgmsg(0, 'keyfilter: Not enough arguments to keyfilter. Syntax: <keygroup> <key> <not/only> <part-of-value-name> [value]')
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]')
Exemplo n.º 10
0
def keygroupcreate(argv):
  es.keygroupcreate(*argv)
Exemplo n.º 11
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>]",
        )