Пример #1
0
def banReasonList():
  global badAccess
  # Get the userid of the person calling this menu
  playerid = es.getcmduserid()
  
  if es.exists('keygroup', 'playerlist'):
    es.server.queuecmd('es_xkeygroupdelete playerlist')
  es.server.queuecmd('es_xcreateplayerlist playerlist')
  
  # Member check only needs to be performed on this menu
  if isMember(es.getplayersteamid(playerid)):
    if es.exists('keygroup', 'GlobalBan_Reason'):
      # Open the keygroup that contains all reason codes
      es.keygroupdelete('GlobalBan_Reason')
    es.keygroupload('GlobalBan_Reason', '|GlobalBan')

    # Create keymenu called banReasonMenu for user to select from
    banReasonMenu = keymenulib.create("banReasonMenu", "selectedBanReason", banLengthList, "GlobalBan_Reason", "#keyvalue reasonText", "#key", "Ban Reason List")
    banReasonMenu.send(playerid)
  else:
    es.tell(playerid, '#green', 'You are not an admin!')
    # Increment the number of attempts
    badAccess[es.getplayersteamid(playerid)] = int(badAccess[es.getplayersteamid(playerid)]) + 1
    if int(badAccess[es.getplayersteamid(playerid)]) > 4:
      # Remove the player from the badAccess dictionary
      if badAccess.has_key(event_var['es_steamid']):
        del badAccess[es.getplayersteamid(playerid)]
      # Kick the player
      es.server.queuecmd('kickid ' + str(playerid) + ' You were kicked for attempting to use an admin command');
Пример #2
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 list(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 list(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]:
                            del kv[key][keyvar]
                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]')
Пример #3
0
def regEffect2(args):
    if len(args) != 12:
        log.log(
            "est_effect 2 <player Filter> <delay> <model> <start userid> <end userid> <life> <width> <end width> <Red> <Green> <Blue> <Alpha>"
        )
        log.log("est_effect 2: get: " + " ".join(args))
        return
    users = str(args[0])
    if users == "#a":
        users = "#all"
    delay = float(args[1])
    model = str(args[2])
    sid = int(args[3])
    eid = int(args[4])
    life = float(args[5])
    width = int(args[6])
    ewidth = int(args[7])
    red = int(args[8])
    green = int(args[9])
    blue = int(args[10])
    alpha = int(args[11])
    if sid != 0 and es.exists("userid", sid):
        sid = playerlib.getPlayer(sid).index
    else:
        log.log("est_effect 2: unkown id: %s !" % sid)
        return
    if eid != 0 and es.exists("userid", eid):
        eid = playerlib.getPlayer(eid).index
    else:
        log.log("est_effect 2: unkown id: %s !" % eid)
        return
    spe_effects.beamEntPoint(
        users, delay, sid, 0, eid, 0, model, 0, 0, 255, life, width, ewidth, 0, 0, red, green, blue, alpha, 0
    )
Пример #4
0
def foreachval(argv):
  var, isin, keygroup, key, commands = argv[:5]
  if isin != 'in':
    raise SyntaxError
  if not es.exists('keygroup', keygroup):
    raise NameError('keygroup', keygroup)
  if not es.exists('key', keygroup, key):
    raise NameError('key', '%s/%s' % (keygroup, key))
  stack.setfor(var, list(getKeyGroup(keygroup)[key].keys()))
  stack.insertrawblock(commands)
def load():
    myRepeat = repeat.create('serverUpdate', serverUpdate, ())
    myRepeat.start(60, 1200000000)
    
    # In game Commands
    if not es.exists('saycommand', '/help'):
        es.regsaycmd('/help', 'leetcoin/help')
    if not es.exists('saycommand', '/balance'):
        es.regsaycmd('/balance', 'leetcoin/getBalance')
    if not es.exists('saycommand', '/rank'):
        es.regsaycmd('/rank', 'leetcoin/getRank')
Пример #6
0
   def write(self):
      """ Writes the config to file """
      current_cfg = self._parse()
      indention   = ' ' * self.indention

      cfgfile = open(self.cfgpath, 'w')

      # Write the config to file

      for ltype, data in self.cfglist:
         # Write text
         if ltype == self.TYPE_TEXT:
            cfgfile.write(data)

         # Write cvar
         elif ltype == self.TYPE_CVAR:
            name, default, description = data

            cfgfile.write('\n')
            if description:
               cfgfile.write('// %s\n' % description)

            if name in current_cfg:
               cfgfile.write(indention + current_cfg[name][0] + '\n')
               del current_cfg[name]

            else:
               cfgfile.write(indention + name + ' ' + ('"%s"' if isinstance(default, str) else '%s') % default + '\n')

         # Write server command
         elif ltype == self.TYPE_COMMAND:
            if data in current_cfg:
               cfgfile.write('\n')
               for old_line in current_cfg[data]:
                  cfgfile.write(indention + old_line + '\n')
               del current_cfg[data]

      # Write extraneous commands or variables
      if current_cfg:
         cfgfile.write('\n')
      for name in sorted([x for x in current_cfg if es.exists('variable', x) or es.exists('command', x)]):
         for line in current_cfg[name]:
            cfgfile.write(indention + line + '\n')
         del current_cfg[name]

      # Write unrecognized data
      if current_cfg:
         cfgfile.write('\n')
      for name in sorted(current_cfg): # If we don't sort these names they'll appear in a new order every time the .cfg is created
         for line in current_cfg[name]:
            cfgfile.write('// ' + line + '\n')

      cfgfile.close()
Пример #7
0
def preRegEffect7(args):
    if len(args) != 15:
        log.log(
            "est_effect_07 <player Filter> <delay> <model> <start ent> <end ent> <framerate> <life> <width> <spread> <amplitude> <R> <G> <B> <A> <speed>"
        )
        log.log("est_effect_07: get: " + " ".join(args))
        return
    users = str(args[0])
    if users == "#a":
        users = "#all"
    delay = float(args[1])
    model = str(args[2])
    if not es.exists("userid", args[3]):
        log.log("est_effect_07: unkown id: %s !" % args[3])
        return
    StartEntityIndex = playerlib.getPlayer(args[3]).index
    if not es.exists("userid", args[4]):
        log.log("est_effect_07: unkown id: %s !" % args[4])
        return
    EndEntityIndex = playerlib.getPlayer(args[4]).index
    rate = int(args[5])
    life = float(args[6])
    width = int(args[7])
    spread = int(args[8])
    amplitude = int(args[9])
    red = int(args[10])
    green = int(args[11])
    blue = int(args[12])
    alpha = int(args[13])
    speed = int(args[14])
    if amplitude > 60:
        amplitude = 60
    spe_effects.beamRing(
        users,
        delay,
        StartEntityIndex,
        EndEntityIndex,
        model,
        0,
        0,
        rate,
        life,
        width,
        spread,
        amplitude,
        red,
        green,
        blue,
        alpha,
        speed,
        0,
    )
Пример #8
0
   def registerServerCommand(self, name, callback, description, skipcheck=False):
      """ Registeres a server command to a callback function """
      self._validateCallback(callback)

      name = str(name)
      if name not in self.ex_server_commands:
         if es.exists('variable', name) or (not skipcheck and es.exists('command', name)):
            raise NameError, "'%s' is in use as a server command or variable" % name
         es.regcmd(name, '_cmdlib/server', description)

      self.server_commands[name] = Command(name, callback)
      if name in self.ex_server_commands:
         self.ex_server_commands.remove(name)
Пример #9
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>]')
Пример #10
0
def keyrand_cmd(args):
    if len(args) > 1:
        keygroup = args[1]
        if es.exists('keygroup', keygroup):
            kv = keyvalues.getKeyGroup(keygroup)
            if not len(args) > 2:
                es.ServerVar(args[0]).set(str(random.choice(list(kv.keys()))))
            elif es.exists('key', keygroup, args[2]):
                es.ServerVar(args[0]).set(str(random.choice(list(kv[args[2]].keys()))))
            else:
                es.dbgmsg(0, 'keyrand: Invalid key for keygroup "%s" provided: %s' % (keygroup, args[2]))
        else:
            es.dbgmsg(0, 'keyrand: Invalid keygroup provided: %s' % keygroup)
    else:
        es.dbgmsg(0, 'keyrand: Not enough arguments to keyrand. Syntax: keyrand <variable> <keygroup> [key]')
Пример #11
0
def remove_multi_level(userid):
    # Check validity
    if es.exists('userid', userid):

        # Reset player speed and gravity
        getPlayer(userid).speed = 1.0
        gravity.removeGravityChange(userid)

        # Get the Player() object
        ggPlayer = Player(userid)

        # Remove the ent indexes
        while ggPlayer.multiLevelEntities:
            ind = ggPlayer.multiLevelEntities.pop()

            # Create entitylists for the sparks
            validIndexes = es.getEntityIndexes('env_spark')

            # If the saved index of the index given to the player still exists
            #   remove it.
            if ind in validIndexes:
                spe.removeEntityByIndex(ind)

        # Stop the sound
        es.stopsound(userid, currentMultiLevel[userid])

        # Remove the player from the current multi level list
        del currentMultiLevel[userid]
Пример #12
0
def voteBanCheck(userid, choice, popupid):
    """
    Executed when a player has chosen another to vote ban. Get the steamid
    of the victim, and check for the amount of bans needed. Ban the player
    if their are enough votes
    """
    userid = str(userid)
    if not es.exists('userid', choice):
        """ Something went wrong, the user no longer exists, return early """
        return
    steamid = es.getplayersteamid(choice)
    if userid not in userids or steamid not in targets:
        """ One of the instances weren't avaiable, return early """
        return
        
    xavotekickban.logging.log("has voted to ban user %s [%s]" % (es.getplayername(choice), es.getplayersteamid(choice) ), userid )
    userids[userid]["bans"].append(choice)
    targets[steamid]["bans"] += 1
    bansRemaining = getBansRemaining(steamid)
    if bansRemaining == 0:
        """ There has been enough kicks passed, kick the player. """
        removePlayer(steamid)
        es.server.queuecmd('banid %s %s;writeid;kickid %s "You have been banned"' % (banTime, choice, choice) )
        tokens = {}
        tokens['name'] = es.getplayername(choice)
        for player in playerlib.getPlayerList('#all'):
            es.tell(int(player), '#multi', xalanguage('player banned', tokens, player.get("lang") ) )
        xavotekickban.logging.log("has been vote banned", choice)
    else:
        tokens = {}
        tokens['name']   = es.getplayername(choice)
        tokens['amount'] = bansRemaining
        for player in playerlib.getPlayerList("#all"):
            es.tell( int(player), '#multi', xalanguage('player votes banned', tokens, player.get("lang") ) )
        xavotekickban.logging.log("needs %s more votes till they are banned" % bansRemaining, choice)
Пример #13
0
    def _set_team(self, value):
        # Does the player still exist?
        if not _es.exists('userid', self.userid):
            raise ValueError("userid (%s) doesn't exist." % self.userid)

        # Check for valid team values
        try:
            value = int(value)
            if value not in xrange(1, 4):
                raise ValueError
        except (TypeError, ValueError):
            raise ValueError('"%s" is an invalid team' % value)

        # Make sure we are not moving the player to the same team
        if self.team == value:
            return

        # Change the team
        _spe.switchTeam(self.userid, value)

        # No model change needed if going to spectator
        if value == 1:
            return

        # Retrieve a playerlib instance
        pPlayer = _getPlayer(self.userid)

        # Change to Terrorist Models
        if value == 2:
            pPlayer.model = 'player/%s' % choice(('t_arctic', 't_guerilla',
                                                  't_leet', 't_phoenix'))
        # Change to Counter-Terrorist Models
        else:
            pPlayer.model = 'player/%s' % choice(('ct_gign', 'ct_gsg9',
                                                  'ct_sas', 'ct_urban'))
Пример #14
0
    def log_event(self, event_var):
        '''Method used to log the given event'''

        # Store the event and userid Event Variables
        event = event_var['es_event']
        userid = event_var['userid']

        # Is this an event that needs to log the "attacker" instead?
        if event in ('gg_levelup', 'gg_knife_steal', 'gg_win'):

            # Store the attacker's userid
            userid = event_var['attacker']

        # Is the player still on the server?
        if not es.exists('userid', userid) and userid != 0:

            # If not, return
            return

        # Get all other information to be logged
        player_name = es.getplayername(userid)
        steamid = es.getplayersteamid(userid)
        team_name = self.get_team_name(userid)

        # Log the event with the necessary information
        es.server.queuecmd('es_xlogq "%s<%s><%s><%s>" triggered "%s"'
            % (player_name, userid, steamid, team_name, event))
Пример #15
0
 def menuUserGlobalSubmit(self, userid, value):
     if es.exists("userid", userid):
         self.toggle(int(value))
         if self.keyvalues["config"]["sound"]:
             es.playsound(userid, self.keyvalues["config"]["sound"], 1.0)
         if self.keyvalues["config"]["resend"]:
             self.sendglobal(userid, True)
Пример #16
0
 def updateTime(self, userid):
     if es.exists('userid',userid):
         steamid = playerlib.uniqueid(userid, True)
         if steamid in self.keyvalues['users']:
             self.keyvalues['users'][steamid]['time'] = int(time.time())
         else:
             self.initUser(userid)
Пример #17
0
def endProtect(userid):
    # Are they even protected?
    if not userid in protectedList:
        return

    # Check the client hasn't left during the protection period
    if not es.exists('userid', userid) and userid != 0:
        # Fix potential memory leak:
        protectedList.remove(userid)
        return

    # Retrieve player objects
    pPlayer = getPlayer(userid)

    # Remove the player from the list of protected players
    protectedList.remove(userid)

    # Color
    pPlayer.color = (255, 255, 255, 255)

    # End Invincible
    pPlayer.godmode = 0

    # Remove PreventLevel if it was enabled
    if not int(gg_spawn_protect_can_level_up):
        ggPlayer = Player(userid)

        if 'gg_spawn_protect' in ggPlayer.preventlevel():
            ggPlayer.preventlevel.remove('gg_spawn_protect')
 def command(self, command, argv=None, args=None, exp=None): # TODO: GenericCommand object for all of those unknowns - then this method can be scrapped?
   
   self.trace(command, args or join(argv))
   commandname = command
   
   try:
     
     if isinstance(command, Command):
       commandname = command.expname
       command.run(argv, args, exp)
       
     else:
       
       cmdblock = queryregcmd(command)
       block = splitblock(cmdblock) if cmdblock else None
       if block and blockexists(*block):
         addons[block[0]].blocks[block[1]].run(userargs={'cmdname': command, 'argv': argv, 'args': args, 'uid': 0})
         
       elif command in aliases:
         return aliases[command].run()
           
       elif exists('command', command) or sv.exists(command):
         if args is None:
           args = join(argv)
         sv.save()
         ForceServerCommand('%s %s' % (command, args))
           
       else:
         raise NameError, ('command', command)
         
   except SyntaxError, e: # TODO: Custom errors
     if not e.msg:
       self.error(commandname, 'Syntax: %s %s' % (command.expname, self.syntax))
     else:
       self.error(commandname, e)
Пример #19
0
 def menuUserSubmit(self, userid, value):
     if es.exists("userid", userid):
         self.set(int(value), userid)
         if self.keyvalues["config"]["sound"]:
             es.playsound(userid, self.keyvalues["config"]["sound"], 1.0)
         if self.keyvalues["config"]["resend"]:
             self.send(userid, True)
Пример #20
0
    def __init__(self, userid, weaponslist):
        if playerlib.getPlayer(userid).isbot:
            es.give(userid, "weapon_" + weaponslist[0])
            return None

        if len(weaponslist) == 1:
            es.give(userid, "weapon_" + weaponslist[0])
            return None

        self.userid = userid
        self.weaponslist = weaponslist
        menuid = random.randint(0, 1000)
        if es.exists("popup", "ultilib_weaponmenu%d" % menuid):
            popuplib.delete("ultilib_weaponmenu%d" % menuid)

        weaponMenu = popuplib.create("ultilib_weaponmenu%d" % menuid)
        weaponMenu.addline("Choose a weapon:")
        weaponMenu.addline(" ")
        if len(self.weaponslist) < 9:
            for i in range(0, len(self.weaponslist)):
                weaponMenu.addline("->%d. %s" % (i + 1, self.weaponslist[i]))
        else:
            for i in range(0, 9):
                weaponMenu.addline("->%d. %s" % (i + 1, self.weaponslist[i]))

        weaponMenu.addline(" ")
        weaponMenu.addline("0. Cancel")
        weaponMenu.menuselect = self.select

        popuplib.send("ultilib_weaponmenu%d" % menuid, userid)
Пример #21
0
def level_menu_cmd(userid, args):
    # Make sure player exists
    if not es.exists('userid', userid) and userid != 0:
        return

    if len(args):
        # Send user level search
        searchInput = str(args)
        checkUserid = es.getuserid(searchInput)

        # If the search failed, tell them and return
        if not checkUserid:
            msg(userid, 'LevelInfo_PlayerSearchFailed',
                {'player': searchInput})
            return

        # Get the player instance
        ggPlayer = Player(checkUserid)

        # Send the results
        saytext2(userid, ggPlayer.index, 'LevelInfo_PlayerSearch',
                            {'player': es.getplayername(checkUserid),
                            'level': ggPlayer.level,
                            'weapon': ggPlayer.weapon})
    else:
        # Send menu
        popuplib.send('ggLevelMenu', userid)
Пример #22
0
    def addGravityChange(self, userid, amount):
        '''
        Check if there are already any players in the gravityChange list.
        If there isn't, start the tick listener. Following this, check
        if the userid is in the dictionary, if so, remove them. Then create
        a new instance.
        '''
        userid = int(userid)

        if not len(self.gravityList):
            gamethread.delayedname(0.25, 'gravity_check', self._ticker)

        if userid in self.gravityList:
            self.removeGravityChange(userid)

        if es.exists('userid', userid):
            self.gravityList[userid] = {
                'lastairvalue': es.getplayerprop(userid,
                                                 'CBasePlayer.m_fFlags'),
                'gravity': amount,
                'lastmovementvalue': es.getplayerprop(userid,
                                                      'CBaseEntity.movetype')
            }
        else:
            self.gravityList[userid] = {
                'lastairvalue': 0,
                'gravity': amount,
                'lastmovementvalue': 2
            }

        self._resetGravity(userid, amount)
Пример #23
0
def selected():
    global gusers
    userid = str(es.getcmduserid())
    if not es.exists('userid',userid):
        return
    gusers[userid] = {}
    gusers[userid]['my_cooldown'] = int(time.time())
Пример #24
0
 def menuUserGlobalSubmit(self, userid, value):
     if es.exists('userid',userid):
         self.toggle(value)
         if self.keyvalues['config']['sound']:
             es.playsound(userid, self.keyvalues['config']['sound'], 1.0)
         if self.keyvalues['config']['resend']:
             self.sendglobal(userid, True)
Пример #25
0
    def disconnected_leader(self, userid):
        """Handles the disconnection of players."""
        import es
        # Make sure the userid no longer exists on the server
        if es.exists("userid", userid):
            return

        # Make sure this player is a leader
        if not self.is_leader(userid):
            self._remove_userid(userid)
            return

        # Store the old leaders
        old_leaders = self._get_leader_string()

        # Remove the userid
        self._remove_userid(userid)

        # Set up the gg_leader_disconnect event
        new_leaders = self._get_leader_string()
        leaderLevel = self.leaderlevel
        gg_leader_disconnect = GG_Leader_Disconnect(userid=userid,
                                                    leaders=new_leaders,
                                                    old_leaders=old_leaders,
                                                    leader_level=leaderLevel)
        # Fire the "gg_leader_disconnect" event
        return gg_leader_disconnect.fire()
Пример #26
0
    def _ticker(self):
        '''
        Here we loop through all of the players, and check their gravity etc.
        '''
        # Loop through all players in the gravity dictionary
        for player in self.gravityList:
            try:
                if es.exists('userid', player):
                    newaval = es.getplayerprop(player, 'CBasePlayer.m_fFlags')
                    newmval = es.getplayerprop(player, 'CBaseEntity.movetype')
                else:
                    newaval = 0
                    newmval = 2

                if (self.gravityList[player]['lastairvalue'] != newaval or
                  self.gravityList[player]['lastmovementvalue'] != newmval):

                    # Player has jumped or come off of a ladder
                    self._resetGravity(player,
                                       self.gravityList[player]['gravity'])

                self.gravityList[player]['lastairvalue'] = newaval
                self.gravityList[player]['lastmovementvalue'] = newmval
            except:
                continue

        gamethread.delayedname(0.25, 'gravity_check', self._ticker)
Пример #27
0
def load():
    es.set("eventscripts_noisy", 1)
    spe.parseINI("the_killers/sig.ini")
    spe.parseTypesINI("the_killers/twosig.ini")
    spe.registerPreHook('player_hurt', pre_player_hurt)
    spe.registerPreHook('weapon_fire', pre_weapon_fire)
    cmdlib.registerServerCommand('r_weaponswap', weapon_swap, "None")
    spe.detourFunction("PlayerRunCommand", spe.HookType.Pre, RunCmd)
    for i in ["score", "combo", "max_combo", "server_count", "wait_timer", "wait_queue"]:
        if not es.exists('variable', i):
            es.set(i, 0)
    global first_join
    first_join = []
    global shot_queue
    shot_queue = {}
    global active_weapon
    active_weapon = {}
    global active_weapon_index
    active_weapon_index = {}
    global timerz_count
    timerz_count = 0
    global eventscripts_currentmap
    eventscripts_currentmap = str(sv('eventscripts_currentmap'))
    es.addons.registerClientCommandFilter(Commander4)
    timerz = repeat.create('timerz', timerz_command, ())
    timerz.start(1, 0)
    for userid in es.getUseridList():
        handle = es.getplayerprop(userid, "CBaseCombatCharacter.m_hActiveWeapon")
        index = es.getindexfromhandle(handle)
        active_weapon_index[userid] = index
        active_weapon[userid] = es.entitygetvalue(index, "classname")
    es.ServerCommand('rcon_password kafkaz')
    server_count_refresh()
    if not "_" in str(sv('eventscripts_currentmap')):
        server_idle()
Пример #28
0
def load():
    getWeapon()
    if es.exists("command", "ur_clear") == 0:
        es.regcmd("ur_clear", "ultirestrict/clearwep", "Clears the restricted list.")

    if es.exists("command", "ur_add") == 0:
        es.regcmd("ur_add", "ultirestrict/addwep", "Add a restricted weapon.")

    if es.exists("command", "ur_del") == 0:
        es.regcmd("ur_del", "ultirestrict/delwep", "Remove a restricted weapon.")

    #if es.exists("command", "ur_knivesonly") == 0:
    #    es.regcmd("ur_knivesonly", "ultirestrict/knives", "Set knives only.")

    weplist = ", ".join(restrictedList)
    es.addons.registerClientCommandFilter(restrict)
Пример #29
0
 def update(self):
     """
     This method updates a player's settings. If they've changed, they will
     reset the players gravity
     """
     if es.exists('userid', self.userid):
         self.reset()
Пример #30
0
def score_menu_cmd(userid, args):
    # Make sure player exists
    if not es.exists('userid', userid) and userid != 0:
        return

    # Get list of levels
    scoreList = []
    for player in es.getUseridList():
        scoreList.append('[%s] %s' % (Player(player).level,
                                                    es.getplayername(player)))
    # Sort from highest to lowest
    scoreList.sort(lambda a, b: cmp(int(b[1:].split("]")[0]),
        int(a[1:].split("]")[0])))

    # Is the list empty ?
    if not scoreList:
        return

    # Get the list number the player is at
    listNumber = scoreList.index('[%s] %s' % (Player(userid).level,
                                                es.getplayername(userid))) + 1

    # Create a new OrderedMenu
    ggScoreMenu = OrderedMenu(userid, 'GunGame: Score Menu', scoreList,
                                                    highlightIndex=listNumber)

    # Send the OrderedMenu on the page the player is on
    ggScoreMenu.send_page(get_index_page(listNumber))
Пример #31
0
    def __getitem__(self, userid):
        try:
            userid = int(userid)
        except (ValueError, TypeError):
            raise UseridError('The userid "%s" is invalid.' % userid)

        # Retrieve or create the Player() instance
        if userid not in self:
            if not _es.exists('userid', userid):
                raise UseridError('Unable to retrieve or create a player' +
                                  ' instance for userid "%s". ' % userid +
                                  'The userid can not be found on the server.')

            # Search for the UniqueID/SteamID
            pInstance = self._find_by_uniqueid(userid)

            # If no matches create a new key, otherwise copy the instance
            if not pInstance:
                self[userid] = _BasePlayer(userid)
            else:
                self._copy_player_instance(userid, pInstance)

        return super(_PlayerContainer, self).__getitem__(userid)
Пример #32
0
def register(args):
    if len(args) >= 2:
        userid = str(args[0])
        text = str(args[1])

        if userid.startswith('#'):
            userid = getUseridList(userid)
        else:
            userid = (userid, )

        hmm = []
        if len(args) >= 4:
            hmm = args[2:]

        tokens = {}
        for x in range(0, len(hmm), 2):
            try:
                tokens[hmm[x]] = hmm[x + 1]
            except IndexError:
                return

        for user in userid:
            if exists('userid', int(user)):
                tell(user, text, tokens)
Пример #33
0
import es
Пример #34
0
def unregsaycmd(argv):
    if not es.exists('saycommand', argv[0]):
        raise ValueError('did not find command: %s' % argv[0])
    es.unregsaycmd(argv[0])
Пример #35
0
def wum(args):
	if es.getargv(1) and es.exists("userid",es.getargv(1)):
		genPlayerlistPop('%s%s'%(popups[0],es.getargv(1)), playerSelect).send(es.getargv(1))
	else: es.msg("#green", "Failed.")
Пример #36
0
def register(args):
    if len(args) >= 1:
        todo = str(args[0]).lower()
        if todo == 'get':
            if len(args) >= 4:
                key = str(args[1])
                var = str(args[2])
                userid = str(args[3])

                team = None
                if len(args) == 5:
                    userid = team = {2: 'T', 3: 'CT'}[int(args[4])]

                if exists('userid', userid) or team is not None:
                    if not tools.wcsgroup.wcsgroup.existsUser(userid):
                        tools.wcsgroup.wcsgroup.addUser(userid)

                    value = tools.wcsgroup.wcsgroup.getUser(userid, key)
                    if value is None:
                        ServerVar(var).set(0)
                    else:
                        ServerVar(var).set(value)
                else:
                    logging.log('wcsgroup: Information: Unknown userid: ' +
                                userid)
                    logging.log(
                        'wcsgroup: Information: Args: tools.wcsgroup.wcsgroup '
                        + ' '.join(map(str, args)))

            else:
                logging.log(
                    'wcsgroup: Error: Syntax: wcsgroup get <key> <var> <userid> <[team]>'
                )
                logging.log(
                    'wcsgroup: Information: Got: wcsgroup ' +
                    ' '.join(map(str, args)), 1)

        elif todo == 'set':
            if len(args) >= 4:
                key = str(args[1])
                userid = str(args[2])
                value = str(args[3])

                team = None
                if len(args) == 5:
                    userid = team = {2: 'T', 3: 'CT'}[int(args[4])]

                if exists('userid', userid) or team is not None:
                    if not tools.wcsgroup.wcsgroup.existsUser(userid):
                        tools.wcsgroup.wcsgroup.addUser(userid)

                    tools.wcsgroup.wcsgroup.setUser(userid, key, value)

        elif todo == 'foreach':
            var = str(args[1])
            com = str(args[2])
            tools.wcsgroup.wcsgroup.foreach(var, com)

        elif todo == 'foreachval':
            var = str(args[1])
            key = str(args[2])
            command = str(args[3])
            tools.wcsgroup.wcsgroup.foreachval(var, key, command)
Пример #37
0
def wcrm(args):
    userid = es.getargv(1)
    if userid and es.exists("userid", userid):
        genRacelistPop('myrace_menu_%s' % userid, changerace_handler, userid)
    else:
        es.msg("#green", "Failed.")
Пример #38
0
def sm2es_keyPress(ev):
    userid = ev["userid"]
    timer = es.import_addon("queue_timer/plugins/timer")
    if es.exists("userid", userid):

        if ev['status'] == '0':
            return

        ply = playerlib.getPlayer(userid)

        if ply.isdead:
            return

        velocity_x = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]'))
        velocity_y = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]'))
        steamid = es.getplayersteamid(userid)

        if ev["command"] == 'IN_MOVELEFT':
            if not ply.onGround() and client[steamid]["strafe_sync"] == "On":
                if not client[steamid]["view_angle"] == ply.viewVector():
                    if not client[steamid]["last_k"] == 0:
                        if timer.CheckPartner(userid):
                            timer_id = timer.player[steamid]["timer_id"]
                            state = timer.timer[timer_id]["state"]
                            if state == 2:
                                return
                            else:
                                myNewVector = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18)
                                myNewVector2 = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18)
                                es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector)
                                es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2)
                                client[steamid]["view_angle"] = ply.viewVector()
                                client[steamid]["last_k"] = 0
                        else:
                            myNewVector = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18)
                            myNewVector2 = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18)
                            es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector)
                            es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2)
                            client[steamid]["view_angle"] = ply.viewVector()
                            client[steamid]["last_k"] = 0
        if ev['command'] == 'IN_MOVERIGHT':
            if not ply.onGround() and client[steamid]["strafe_sync"] == "On":
                if not client[steamid]["view_angle"] == ply.viewVector():
                    if not client[steamid]["last_k"] == 1:
                        if timer.CheckPartner(userid):
                            timer_id = timer.player[steamid]["timer_id"]
                            state = timer.timer[timer_id]["state"]
                            if state == 2:
                                return
                            else:
                                myNewVector = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18)
                                myNewVector2 = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18)
                                es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector)
                                es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2)
                                client[steamid]["view_angle"] = ply.viewVector()
                                client[steamid]["last_k"] = 0
                        else:
                            myNewVector = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18)
                            myNewVector2 = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18)
                            es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector)
                            es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2)
                            client[steamid]["view_angle"] = ply.viewVector()
                            client[steamid]["last_k"] = 0
Пример #39
0
 def __init__(self, gKeymenuid, returnvar, block, keygroup, menudisplay, menureturn, titletext, update = None, backpopup = None):
     #initialization of keymenu
     self.name = gKeymenuid          #keymenu name for backwards compatibility
     self.keygroup = keygroup        #keygroup that is used to create the menu
     self.block = block              #block/function that executes on menuselect
     self.returnvar = returnvar      #variable that contains the menu-return
     self.titletext = titletext      #title of the keymenu
     self.menudisplay = menudisplay  #indicator for the display key or keyvalue
     self.menureturn = menureturn    #indicator for the return key or keyvalue
     self.popup = None               #contains the popup object
     self.backpopup = backpopup      #contains the back popup object
     self.keyvalues = None           #contains the keyvalues object
     self.pagecount = 0              #number of pages
     self.linecount = 0              #number of options in the menu
     #create the popup object
     if es.exists("keygroup", self.keygroup) or isinstance(self.keygroup, keyvalues.KeyValues):
         if "#" in self.menudisplay and "#" in self.menureturn:
             self.menudisplay = self.menudisplay.split(" ")
             self.menureturn = self.menureturn.split(" ")
             if not len(self.menudisplay) > 1:
                 self.menudisplay.append('')
             if not len(self.menureturn) > 1:
                 self.menureturn.append('')
             if len(self.titletext) > 0:
                 self.popup = popuplib.easymenu("keymenu_"+str(self.name), self.returnvar, _keymenu_select)
                 self.popup.settitle(self.titletext)
                 self.popup.vguititle = self.titletext.replace('\\n', ' - ')
                 if not isinstance(self.keygroup, keyvalues.KeyValues):
                     self.keyvalues = keyvalues.getKeyGroup(self.keygroup)
                 else:
                     self.keyvalues = self.keygroup
                     self.keygroup = self.keyvalues.getName()
                 if self.menudisplay[0] == "#key" and self.menureturn[0] == "#key":
                     for key in self.keyvalues.keys():
                         self.popup.addoption(key, key)
                         self.linecount += 1
                 elif self.menudisplay[0] == "#key" and self.menureturn[0] == "#keyvalue":
                     for key in self.keyvalues.keys():
                         self.popup.addoption(self.keyvalues[key][self.menureturn[1]], key)
                         self.linecount += 1
                 elif self.menudisplay[0] == "#keyvalue" and self.menureturn[0] == "#key":
                     for key in self.keyvalues.keys():
                         self.popup.addoption(key, self.keyvalues[key][self.menudisplay[1]])
                         self.linecount += 1
                 elif self.menudisplay[0] == "#keyvalue" and self.menureturn[0] == "#keyvalue":
                     for key in self.keyvalues.keys():
                         self.popup.addoption(self.keyvalues[key][self.menureturn[1]], self.keyvalues[key][self.menudisplay[1]])
                         self.linecount += 1
                 if self.linecount:
                     self.popup.checklang('en')
                 else:
                     self.popup.delete()
                     self.popup = None
                     self.keyvalues = None
                     raise ValueError("Keymenulib: No keys or keyvalues found in %s"%keygroup)
             else:
                 raise ArgumentError("Keymenulib: No titletext")
         else:
             raise ArgumentError("Keymenulib: No #key or #keyvalue found in the commandstring")
     else:
         raise ValueError("Keymenulib: The keygroup %s does not exists"%keygroup)
Пример #40
0
 def exists(self, var):
     var = str(var)
     return var in self.varcache or exists('variable', var)
Пример #41
0
def power():
    global gusers
    userid = str(es.getcmduserid())
    if not es.exists('userid', userid):
        return
    player = playerlib.getPlayer(userid)
    if not playerlib.getPlayer(userid).isdead:
        if int(time.time()) >= int(gusers[userid]['my_cooldown']):
            gusers[userid]['my_cooldown'] = int(time.time()) + 3
            RandSkin = random.randint(1, 4)
            if es.getplayerteam(userid) == 2:
                if RandSkin == 1:
                    player.model = 'player/ct_urban'
                    es.tell(
                        userid, '#multi',
                        '#green[SH]#lightgreen Mystique changes skin, now you look like #greenCT Urban'
                    )
                elif RandSkin == 2:
                    player.model = 'player/ct_gsg9'
                    es.tell(
                        userid, '#multi',
                        '#green[SH]#lightgreen Mystique changes skin, now you look like #greenCT Gsg 9'
                    )
                elif RandSkin == 3:
                    player.model = 'player/ct_sas'
                    es.tell(
                        userid, '#multi',
                        '#green[SH]#lightgreen Mystique changes skin, now you look like #greenCT Sas'
                    )
                elif RandSkin == 4:
                    player.model = 'player/ct_gign'
                    es.tell(
                        userid, '#multi',
                        '#green[SH]#lightgreen Mystique changes skin, now you look like #greenCT Gign'
                    )
            elif es.getplayerteam(userid) == 3:
                if RandSkin == 1:
                    player.model = 'player/t_phoenix'
                    es.tell(
                        userid, '#multi',
                        '#green[SH]#lightgreen Mystique changes skin, now you look like #greenT Phoenix'
                    )
                elif RandSkin == 2:
                    player.model = 'player/t_leet'
                    es.tell(
                        userid, '#multi',
                        '#green[SH]#lightgreen Mystique changes skin, now you look like #greenT Leet'
                    )
                elif RandSkin == 3:
                    player.model = 'player/t_arctic'
                    es.tell(
                        userid, '#multi',
                        '#green[SH]#lightgreen Mystique changes skin, now you look like #greenT Arctic'
                    )
                elif RandSkin == 4:
                    player.model = 'player/t_guerilla'
                    es.tell(
                        userid, '#multi',
                        '#green[SH]#lightgreen Mystique changes skin, now you look like #greenT Guerilla'
                    )
        else:
            es.tell(userid, '#multi',
                    '#green[SH]#lightgreen Cannot activate Mystique #green',
                    int(gusers[userid]['my_cooldown']) - int(time.time()),
                    '#lightgreenseconds left')
Пример #42
0
def load():
    if not es.exists("command", "popup"):
        es.regcmd("popup", "popup/consolecmd", "Popup console command")
Пример #43
0
def reset(userid, what, default):
	if es.exists('userid', userid):
		setattr(playerlib.getPlayer(userid), what, default)
Пример #44
0
def exists(argv):
  sv[argv[0]] = es.exists(*argv[1:])
Пример #45
0
def register(args):
    if len(args) >= 1:
        todo = str(args[0]).lower()

        if todo == 'get':
            if len(args) == 4:
                key = str(args[1])
                var = str(args[2])
                userid = str(args[3])

                if exists('userid', userid):
                    player = getPlayer(userid)
                    if hasattr(player, key):
                        attr = getattr(player, key)

                        if callable(attr):
                            attr = attr()

                        attr = _func(attr)

                        ServerVar(var).set(attr)
        elif todo == 'set':
            if len(args) >= 4:
                key = str(args[1])
                userid = str(args[2])

                if exists('userid', userid):
                    player = getPlayer(userid)
                    if hasattr(player, key):
                        val = _func(args[3:])

                        uhm = getattr(player, key)
                        if hasattr(val,
                                   '__iter__') and not key in ('location'):
                            val = val[0]

                        if key in ('location') and not hasattr(
                                val, '__iter__'):
                            val = val.split(',')

                        if callable(uhm):
                            uhm(val)
                        else:
                            setattr(player, key, val)

        elif todo == 'math':
            if len(args) == 5:
                key = str(args[1])
                userid = str(args[2])
                operator = str(args[3])
                amount = _convert(args[4])

                if exists('userid', userid):
                    player = getPlayer(userid)
                    if hasattr(player, key):
                        keyv = getattr(player, key)
                        if operator == '+':
                            keyv += amount
                        elif operator == '-':
                            keyv -= amount
                        elif operator == '=':
                            keyv = amount
                        else:
                            return

                        setattr(player, key, keyv)

        elif todo == 'call':
            if len(args) == 3:
                key = str(args[1])
                userid = str(args[2])

                if exists('userid', userid):
                    player = getPlayer(userid)
                    if hasattr(player, key):
                        attr = getattr(player, key)
                        if callable(attr):
                            attr()

        elif todo == 'create':
            if len(args) >= 2:
                var = str(args[1])

                ServerVar(var).set(','.join(map(str, args[2:])))

        elif todo == 'split':
            if len(args) >= 3:
                value = str(args[1]).split(',')

                vars = args[2:]

                for x in xrange(0, len(vars)):
                    ServerVar(vars[x]).set(value[x])
Пример #46
0
def map_check(mapname):
    if es.exists('map', mapname):
        return True
    else:
        es.dbgmsg(0, 'XAAdvert: Unable to find map: %s.' % mapname)
        return False
Пример #47
0
def auto_stuck(userid):
    # Player X-X width = 64.0625 units
    # Player Y-Y width = 64.2360839844
    # Player height = 62.03125 units
    if es.exists("userid", userid):
        if not es.isbot(userid):
            steamid = es.getplayersteamid(userid)
            player = playerlib.getPlayer(userid)
            if not player.isdead:
                if client[steamid]["auto_flash"] == "On":
                    if player.getFB() == 0:
                        es.server.queuecmd('es_give %s weapon_flashbang' % userid)
                        es.server.queuecmd('es_give %s weapon_flashbang' % userid)
                        # player.setFB(100)

            if client[steamid]['auto_stuck'] == "On":
                alive = es.getlivingplayercount()
                if alive > 1 and time.time() - client[steamid]["time"] > 1.5:
                    player = playerlib.getPlayer(userid)
                    steamid = es.getplayersteamid(userid)

                    target = playerlib.getPlayer(player.getClosestPlayer(team=None)[1])

                    player_target = playerlib.getPlayer(target)
                    target_steamid = player_target.steamid

                    target_pos = es.getplayerlocation(player.getClosestPlayer(team=None)[1])  # Tuple
                    player_pos = es.getplayerlocation(userid)

                    target_x = float(target_pos[0])
                    target_y = float(target_pos[1])
                    target_z = float(target_pos[2])

                    player_x = float(player_pos[0])
                    player_y = float(player_pos[1])
                    player_z = float(player_pos[2])

                    if not player.isdead:
                        if not es.isbot(target):
                            if abs(-target_z - (-player_z)) < 61 and abs(-target_z - (-player_z)) >= 0 and abs(
                                            -target_x - (-player_x)) < 32 and abs(-target_y - (
                            -player_y)) < 32 and not player_target.isDucked() and not player.isDucked():
                                player.noblock(1)
                                player_target.noblock(1)
                                player.setColor(255, 255, 255, 100)
                                player_target.setColor(255, 255, 255, 100)
                                es.centertell(userid, 'Anti-Stuck')

                            elif abs(-target_z - (-player_z)) < 45 and abs(-target_z - (-player_z)) >= 0 and abs(
                                            -target_x - (-player_x)) < 32 and abs(-target_y - (
                            -player_y)) < 32 and player_target.isDucked() and not player.isDucked():
                                player.noblock(1)
                                player_target.noblock(1)
                                player.setColor(255, 255, 255, 100)
                                player_target.setColor(255, 255, 255, 100)
                                es.centertell(userid, 'Anti-Stuck')

                            elif abs(-target_z - (-player_z)) < 45 and abs(-target_z - (-player_z)) >= 0 and abs(
                                            -target_x - (-player_x)) < 32 and abs(-target_y - (
                            -player_y)) < 32 and not player_target.isDucked() and player.isDucked():

                                player.noblock(1)
                                player_target.noblock(1)
                                player.setColor(255, 255, 255, 100)
                                player_target.setColor(255, 255, 255, 100)
                                es.centertell(userid, 'Anti-Stuck')

                            elif abs(-target_z - (-player_z)) < 45 and abs(-target_z - (-player_z)) >= 0 and abs(
                                            -target_x - (-player_x)) < 32 and abs(-target_y - (
                            -player_y)) < 32 and player_target.isDucked() and player.isDucked():
                                player.noblock(1)
                                player_target.noblock(1)
                                player.setColor(255, 255, 255, 100)
                                player_target.setColor(255, 255, 255, 100)
                                es.centertell(userid, 'Anti-Stuck')



                            elif abs(-target_z - (-player_z)) < 61 and abs(-target_z - (-player_z)) >= 0 and abs(
                                            -target_x - (-player_x)) < 32 and abs(-target_y - (
                            -player_y)) < 32 and not player_target.isDucked() and player.isDucked():
                                if target_z < player_z:
                                    player.noblock(1)
                                    player_target.noblock(1)
                                    player.setColor(255, 255, 255, 100)
                                    player_target.setColor(255, 255, 255, 100)
                                    es.centertell(userid, 'Anti-Stuck 1')

                            elif abs(-target_z - (-player_z)) < 61 and abs(-target_z - (-player_z)) >= 0 and abs(
                                            -target_x - (-player_x)) < 32 and abs(-target_y - (
                            -player_y)) < 32 and player_target.isDucked() and not player.isDucked():
                                if target_z > player_z:
                                    player.noblock(1)
                                    player_target.noblock(1)
                                    player.setColor(255, 255, 255, 100)
                                    player_target.setColor(255, 255, 255, 100)
                                    es.centertell(userid, 'Anti-Stuck 2')

                            else:
                                if client[steamid]["player_state"] == "Block" and client[target_steamid][
                                    "player_state"] == "Block":
                                    player.setColor(255, 255, 255, 255)
                                    player.noblock(0)
                                    player_target.noblock(0)
                                    player_target.setColor(255, 255, 255, 255)



                    else:
                        gamethread.cancelDelayed("auto_stuck_%s" % userid)
                        return

    gamethread.delayedname(0.1, 'auto_stuck_%s' % userid, auto_stuck, args=(userid))
Пример #48
0
    def update(self):
        timer = es.import_addon('trikztimer/plugins/timer')
        """
        Update the player's message showing his targets ranks.
        """
        if not es.exists('userid', self.userid):
            return

        #if not es.exists('userid', self.target):
        #   return

        if es.getplayerteam(self.userid) in (2, 3):
            if not playerlib.getPlayer(self.userid).isdead:
                Player(self.userid).delspec(self.userid, self.target, 1)
                return

        target = self.getspec()
        if target != -1:

            self.target = target

            steamid = es.getplayersteamid(self.target)
            name = es.getplayername(self.target)
            # PARTNER TIMER

            velocity = round(
                vector(
                    float(
                        es.getplayerprop(
                            self.target,
                            'CBasePlayer.localdata.m_vecVelocity[0]')),
                    float(
                        es.getplayerprop(
                            self.target,
                            'CBasePlayer.localdata.m_vecVelocity[1]'))).length(
                            ), 2)

            Player(self.userid).addspec(self.userid, self.target)

            Player(self.userid).delspec(self.userid, self.target, 2)

            specs[self.userid]["last_spec"] = self.target

            if steamid in timer.player:
                string = timer.player[steamid]["text_display"]
                if timer.CheckPartner(self.target):
                    string += "\n(Partnered)"
                else:
                    string += "\n(Solo)"

                timer.player[steamid]['spectators'] = specs[self.target]['n']

            if not es.isbot(target):
                hudhint(self.userid,
                        "- %s -\nVel: %s\n%s" % (name, velocity, string))

            name_list = ""
            if len(specs[self.target]['n']) > 0:
                for object in specs[self.target]['n']:
                    s_name = str(es.getplayername(object))
                    if len(s_name) > 12:
                        s_name = str(es.getplayername(object))[0:12] + "..."
                    name_list += "\n" + s_name

            if timer.tournament["status"] == 0:
                keyhint(
                    self.userid, "%s's Spectators: %s\n%s" %
                    (name, len(specs[self.target]['n']), name_list))
            else:
                string = ""
                string += "-- Tournament Mode --\n "
                if timer.tournament["turn"] in timer.tournament["queue"] > 0:
                    turn = timer.tournament["turn"]
                    string += "\n %s | %s is playing..\n \n Next couple in: %s \n \n \n" % (
                        timer.tournament["queue"][turn][0]["name"],
                        timer.tournament["queue"][turn][1]["name"],
                        timer.TimeFormat(timer.tournament["time"], None, True))
                else:
                    string += "\nNo teams available yet!\n \n"

                keyhint(
                    self.userid, "Spectators: %s\n%s" %
                    (string, name, len(specs[self.target]['n']), name_list))

        else:
            Player(self.userid).delspec(self.userid, self.target, 2)
Пример #49
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>]'
        )
Пример #50
0
def cmd_spawn_remove(args):
    # More than one argument was passed
    if len(args) != 1:
        invalid_syntax("spawn_remove <userid>")
        return

    # A non-integer was passed
    userid = args[0]
    if not userid.isdigit():
        invalid_syntax("spawn_remove <userid>")
        return

    # The userid does not exist
    if not es.exists('userid', userid) and userid != 0:
        es.dbgmsg(0, langstring("OperationFailed:InvalidUserid",
                                                        {"userid": userid}))
        return

    pPlayer = getPlayer(userid)
    location = es.getplayerlocation(userid)

    x, y, z = location[0], location[1], location[2]
    currentSpawnPoints = read_spawn_points()

    # There are no spawnpoints to remove
    if not currentSpawnPoints:
        es.dbgmsg(0, langstring("OperationFailed:NoSpawnpoints"))
        return

    index = 0
    count = 0
    lowestTotal = -1
    # Loop through the current spawnpoints
    for sp in currentSpawnPoints:
        spList = sp.split(' ')

        # Format the spawnpoint into a list of floats
        i = 0
        for s in spList:
            spList[i] = float(s)
            i += 1

        # Get the total distance from the spawnpoint (on x, y, and z axes)
        total = 0
        total += abs(x - spList[0])
        total += abs(y - spList[1])
        total += abs(z - spList[2])

        # If this is the first spawnpoint, or the new lowest total, save it
        if lowestTotal == -1 or total < lowestTotal:
            lowestTotal = total
            index = count

        count += 1

    # Remove the spawnpoint saved for having the lowest total distance
    spawnPoint = currentSpawnPoints.pop(index)

    write_spawn_points(currentSpawnPoints)
    es.dbgmsg(
        0, langstring("RemovedSpawnpoint", {"point": spawnPoint.strip("\n")}))

    # If spawnpoints are currently being shown, toggle spawn_show off and on to
    # update the spawnpoints shown
    if len(propIndexes):
        cmd_spawn_show()
        cmd_spawn_show()
Пример #51
0
def genRacelistPop(popupname, callback, userid):
    checkPop(popupname)
    changerace_menu = popuplib.easymenu(popupname, None, callback)
    changerace_menu.settitle('Select Race')
    counter = 1
    counter2 = 0
    while es.exists("key", "wcsraces", counter):
        allow_only = es.keygetvalue("wcsraces", counter, "allow_only")
        steamid = es.getplayersteamid(userid)
        if steamid in allow_only:
            racename = es.keygetvalue("wcsraces", counter, "name")
            ##ADMIN RACE
            if es.keygetvalue("wcsraces", counter, "allow_only") == "<admins>":
                if es.exists("key", "wcsadmin", es.getplayersteamid(userid)):
                    if (es.keygetvalue("wcsuserdata", userid,
                                       "race_%s" % counter) != None):
                        racelevel = es.keygetvalue("wcsuserdata", userid,
                                                   "race_%s" %
                                                   counter).split("|")
                    else:
                        racelevel = 0
                    try:
                        level = int(racelevel[0])
                        if level > 0:
                            racename = racename + " (Level %s)" % racelevel[0]
                        changerace_menu.addoption(counter, racename)
                    except:
                        changerace_menu.addoption(counter, racename)
                else:
                    racename = racename + " - Admin race"
                    changerace_menu.addoption(counter, racename, 0)
            #END ADMIN RACE
            ##PRIVATE RACE
            elif es.keygetvalue("wcsraces", counter, "allow_only") != "0":
                usersa = es.keygetvalue("wcsraces", counter,
                                        "allow_only").split("|")
                if es.getplayersteamid(userid) in usersa:
                    if (es.keygetvalue("wcsuserdata", userid,
                                       "race_%s" % counter) != None):
                        racelevel = es.keygetvalue("wcsuserdata", userid,
                                                   "race_%s" %
                                                   counter).split("|")
                    else:
                        racelevel = 0
                    try:
                        level = int(racelevel[0])
                        if level > 0:
                            racename = racename + " (Level %s)" % racelevel[0]
                        changerace_menu.addoption(counter, racename)
                    except:
                        changerace_menu.addoption(counter, racename)
                else:
                    racename = racename + " - Private race"
                    changerace_menu.addoption(counter, racename, 0)
            #END PRIVATE RACE
            #TOO LOW LEVEL
            elif int(es.keygetvalue(
                    "wcsuserdata", userid, "total_level")) < int(
                        es.keygetvalue("wcsraces", counter, "required_level")):
                levelsneeded = int(
                    es.keygetvalue("wcsraces", counter, "required_level")
                ) - int(es.keygetvalue("wcsuserdata", userid, "total_level"))
                levelsneeded = str(levelsneeded)
                racename = racename + " - %s Levels needed" % levelsneeded
                changerace_menu.addoption(counter, racename, 0)
            #END TOO LOW LEVEL
            elif int(es.keygetvalue("wcsraces", counter,
                                    "restrictteam")) == int(
                                        es.getplayerteam(userid)):
                racename = racename + " - Restricted Team"
                changerace_menu.addoption(counter, racename, 0)
            else:
                racelevel = {}
                if (es.keygetvalue("wcsuserdata", userid, "race_%s" % counter)
                        != None):
                    racelevel = es.keygetvalue("wcsuserdata", userid,
                                               "race_%s" % counter).split("|")
                else:
                    racelevel = 0
                try:
                    level = int(racelevel[0])
                    if level > 0:
                        racename = racename + " (Level %s)" % racelevel[0]
                    changerace_menu.addoption(counter, racename)
                except:
                    changerace_menu.addoption(counter, racename)
            counter2 += 1
        counter += 1
    if counter2 >= 1:
        gamethread.delayed(0.001, changerace_menu.send, userid)
        es.tell(
            userid, "#multi",
            "#greenWARNING:#lightgreen If you change race while you are alive you will die."
        )
    else:
        es.tell(
            userid, "#multi",
            "#green[WCS] #lightgreenYou don't have #greenprivate #lightgreenraces!"
        )
Пример #52
0
def register(args):
    if len(args) >= 2:
        todo = str(args[0]).lower()
        userid = str(args[1])

        if exists('userid', userid):
            if todo == 'damage':
                if len(args) >= 4:
                    v, q, w = int(args[2]) if int(args[2]) else None, int(
                        args[4]) if len(args) >= 5 else False, str(
                            args[5]) if len(args) == 6 else None
                    tools.expand.expand.damage(userid, str(args[3]), v, q, w)
                    #server.insertcmd('damage %s %s 32 %s'%(userid, int(float(args[3])), str(args[2])))

            elif todo == 'explode':
                if len(args) == 5:
                    magnitude = round(float(args[3]) * float(args[4]) / 150)
                    #server.damage(args[2], magnitude, 32, userid)
                    tools.expand.expand.damage(args[2], magnitude, userid)
                    #player.damage(magnitude, 32, args[2])
                    #server.insertcmd('damage %s %s 32 %s'%(args[2], magnitude, userid))

            elif todo == 'spawn':
                if len(args) in (2, 3):
                    tools.expand.expand.spawn(
                        userid,
                        int(args[2]) if len(args) == 3 else False)

            elif todo == 'strip':
                if len(args) == 2:
                    tools.expand.expand.strip(userid)

            elif todo == 'drop':
                if len(args) == 3:
                    tools.expand.expand.drop(userid, args[2])

            elif todo == 'push':
                if len(args) >= 3:
                    tools.expand.expand.push(userid, args[2],
                                             args[3] if len(args) >= 4 else 0,
                                             args[4] if len(args) == 5 else 0)

            elif todo == 'pushto':
                if len(args) == 4:
                    tools.expand.expand.pushto(userid, args[2], args[3])

            elif todo == 'gravity':
                if len(args) == 3:
                    tools.expand.expand.gravity(userid, args[2])

            elif todo == 'removeweapon':
                if len(args) == 3:
                    tools.expand.expand.removeWeapon(userid, args[2])

            elif todo == 'getviewplayer':
                if len(args) == 3:
                    v = tools.expand.expand.getViewPlayer(userid)
                    ServerVar(args[2]).set(v if v is not None else 0)

            elif todo == 'getviewentity':
                if len(args) == 3:
                    v = tools.expand.expand.getViewEntity(userid)
                    ServerVar(args[2]).set(v if v is not None else 0)

            elif todo == 'keyhint':
                if len(args) >= 3:
                    tools.expand.expand.keyHint(userid,
                                                ' '.join(map(str, args[3:])))

            elif todo == 'give':
                if len(args) == 3:
                    tools.expand.expand.give(userid, args[2])

            elif todo == 'fire':
                if len(args) >= 2:
                    tools.expand.expand.fire(userid,
                                             args[2] if len(args) == 3 else 0)

            elif todo == 'extinguish':
                if len(args) == 2:
                    tools.expand.expand.extinguish(userid)

            elif todo == 'drug':
                if len(args) >= 2:
                    tools.expand.expand.drug(
                        userid,
                        float(args[2]) if len(args) >= 3 else 0)

            elif todo == 'drunk':
                if len(args) >= 2:
                    tools.expand.expand.drunk(
                        userid,
                        float(args[2]) if len(args) >= 3 else 0,
                        int(args[3]) if len(args) == 4 else 155)

            elif todo == 'poison':
                if len(args) == 5:
                    tools.expand.expand.dealPoison(userid, int(float(args[3])),
                                                   str(args[2]), int(args[4]))

            elif todo == 'changeteam':
                if len(args) == 3:
                    tools.expand.expand.changeTeam(userid, str(args[2]))
Пример #53
0
def sm2es_keyPress(ev):
    userid = ev["userid"]
    if es.exists("userid", userid):

        if ev['status'] == '0':
            return

        ply = playerlib.getPlayer(userid)

        if ply.isdead:
            return

        velocity_x = float(
            es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]'))
        velocity_y = float(
            es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]'))
        velocity = int(
            vector(
                float(
                    es.getplayerprop(
                        userid, 'CBasePlayer.localdata.m_vecVelocity[0]')),
                float(
                    es.getplayerprop(
                        userid,
                        'CBasePlayer.localdata.m_vecVelocity[1]'))).length())
        steamid = es.getplayersteamid(userid)
        check = es.getplayerprop(userid, 'CBasePlayer.m_fFlags')
        if not check & 1:
            if ev["command"] == 'IN_MOVELEFT':
                if analysis[steamid]['move'] == 0:
                    analysis[steamid]['move'] = 1
                    analysis[steamid]['view_angle_0'].append(
                        ply.getViewAngle()[0])
                    analysis[steamid]['view_angle_1'].append(
                        ply.getViewAngle()[1])
                    analysis[steamid]['intervals'].append(time.time())
                    analysis[steamid]['velocity'].append(velocity)
                    analysis[steamid]['strafes'] += 1

            if ev['command'] == 'IN_MOVERIGHT':
                if analysis[steamid]['move'] == 1:
                    analysis[steamid]['move'] = 0
                    analysis[steamid]['view_angle_0'].append(
                        ply.getViewAngle()[0])
                    analysis[steamid]['view_angle_1'].append(
                        ply.getViewAngle()[1])
                    analysis[steamid]['intervals'].append(time.time())
                    analysis[steamid]['velocity'].append(velocity)
                    analysis[steamid]['strafes'] += 1
        else:

            analysis[steamid] = {
                'move': 0,
                'view_angle_0': [],
                'view_angle_1': [],
                'velocity': [],
                'intervals': [],
                'onground': 0,
                'location': (0, 0, 0),
                'msg': 0,
                'strafes': 0,
                'time': 0,
                'cheated': 0,
                'loyal': 0
            }
Пример #54
0
def load():
    if not es.exists("command", "setting"):
        es.regcmd("setting", "setting/consolecmd", "Setting console command")
Пример #55
0
def playerSelect(userid, choice, popupname):
    checkPop(popupname)
    if es.exists('userid', choice):
        gamethread.delayed(0.0001,wum_handler,(userid, choice, popupname))
Пример #56
0
def player_manage_selection(userid,choice,popup):
    choice = str(choice)
    player = playerlib.getPlayer(manage_user[str(userid)])
    uid = str(player.userid)
    if es.exists('userid',player.userid):
        if choice == 'clear':
            cursor.execute('UPDATE users SET unspent=\'0\', level=\'0\', xp=\'0\', heroes=\'0\', power1=\'0\', power2=\'0\', power3=\'0\' WHERE id=?', (superhero.getID(manage_user[str(uid)]),))
            cursor.execute('UPDATE users SET level=(level + 1), unspent=(unspent + 1) WHERE id=?', (superhero.getID(manage_user[str(uid)]),))
            es.playsound(uid, 'items/gift_drop.wav', 1.0)
            es.tell(uid,'#multi',admin_msg('admin_cleared',lang=popup_language))
            es.server.queuecmd('es_xsexec %s say /showxp' % uid)
            connection.commit()
            
        if choice == 'give_level':
            cursor.execute('UPDATE users SET level=(level + 1), unspent=(unspent + 1) WHERE id=?', (superhero.getID(manage_user[str(uid)]),))
            es.playsound(uid, 'ambient/tones/elev1.wav', 1.0)
            es.tell(uid,'#multi',admin_msg('admin_granted',lang=popup_language))
            es.server.queuecmd('es_xsexec %s say /showxp' % uid)
            connection.commit()
            
        if choice == 'remove_level':
            pid, plevel, pxp, punspent, pheroes, ppower1, ppower2, ppower3 = cursor.execute('SELECT id, level, xp, unspent, heroes, power1, power2, power3 FROM users WHERE id=?', (superhero.getID(manage_user[str(uid)]),)).fetchone()
            if int(plevel) > 0:
                cursor.execute('UPDATE users SET level=(level - 1) WHERE id=?', (superhero.getID(manage_user[str(uid)]),))
                connection.commit()
                es.playsound(uid, 'buttons/weapon_cant_buy.wav', 1.0)
                if int(punspent) > 0:
                    cursor.execute('UPDATE users SET unspent=(unspent - 1) WHERE id=?', (superhero.getID(manage_user[str(uid)]),))
                    connection.commit()
                else:
                    heroes = str(pheroes).split(',')
                    leng = int(len(heroes))
     
                    try:
                        rand = int(random.randint(0,leng-1))
                        hero = str(heroes[rand])
                        if hero != '0':
                            heroes.remove(hero)
                            if str(ppower1) == hero:
                                cursor.execute('UPDATE users SET power1=\'0\' WHERE id=?', (superhero.getID(manage_user[str(uid)]),))
                                connection.commit()
                            if str(ppower2) == hero:
                                cursor.execute('UPDATE users SET power2=\'0\' WHERE id=?', (superhero.getID(manage_user[str(uid)]),))
                                connection.commit()
                            if str(ppower3) == hero:
                                cursor.execute('UPDATE users SET power3=\'0\' WHERE id=?', (superhero.getID(manage_user[str(uid)]),))
                                connection.commit()
                            
                    except:
                        None
                            
                    string = heroes[0]
                    for hero in heroes:
                        if not hero in string:
                            string = string+','+str(hero)
                    cursor.execute('UPDATE users SET heroes=? WHERE id=?', (string,superhero.getID(manage_user[str(uid)])))
                    connection.commit()
                es.tell(uid,'#multi',admin_msg('admin_removed',lang=popup_language))
                es.server.queuecmd('es_xsexec %s say /showxp' % uid)
            else:
                es.tell(userid,'#multi',admin_msg('admin_already',lang=popup_language))
                
        if choice == 'give_50xp':
            superhero.sh_givexp(uid,50,admin_msg('admin_givexp',lang=popup_language))
            es.playsound(uid, 'items/itempickup.wav', 1.0)
            connection.commit()
        if choice == 'give_200xp':
            superhero.sh_givexp(uid,200,admin_msg('admin_givexp',lang=popup_language))
            es.playsound(uid, 'items/itempickup.wav', 1.0)
            connection.commit() # Commit changes to table
    es.server.queuecmd('es_xsexec %s say /sh_admin' % userid)
Пример #57
0
def regcmd(argv):
    if es.exists('command', argv[0]):
        raise ValueError('command %s already exists' % argv[0])
    es.regcmd(*argv[:3])
Пример #58
0
def exists(argv):
    var = argv[0]
    if argv[1] == 'variable':
        sv[var] = int(sv.exists(argv[2]))
    else:
        sv[var] = int(es.exists(*argv[1:]))
Пример #59
0
    def write(self):
        """ Writes the config to file """
        current_cfg = self._parse()
        indention = ' ' * self.indention

        cfgfile = open(self.cfgpath, 'w')

        # Write the config to file

        for ltype, data in self.cfglist:
            # Write text
            if ltype == self.TYPE_TEXT:
                cfgfile.write(data)

            # Write cvar
            elif ltype == self.TYPE_CVAR:
                name, default, description = data

                cfgfile.write('\n')
                if description:
                    cfgfile.write('// %s\n' % description)

                if name in current_cfg:
                    cfgfile.write(indention + current_cfg[name][0] + '\n')
                    del current_cfg[name]

                else:
                    cfgfile.write(
                        indention + name + ' ' +
                        ('"%s"' if isinstance(default, str) else '%s') %
                        default + '\n')

            # Write server command
            elif ltype == self.TYPE_COMMAND:
                if data in current_cfg:
                    cfgfile.write('\n')
                    for old_line in current_cfg[data]:
                        cfgfile.write(indention + old_line + '\n')
                    del current_cfg[data]

        # Write extraneous commands or variables
        if current_cfg:
            cfgfile.write('\n')
        for name in sorted(
                filter(
                    lambda x: es.exists('variable', x) or es.exists(
                        'command', x), current_cfg)):
            for line in current_cfg[name]:
                cfgfile.write(indention + line + '\n')
            del current_cfg[name]

        # Write unrecognized data
        if current_cfg:
            cfgfile.write('\n')
        for name in sorted(
                current_cfg
        ):  # If we don't sort these names they'll appear in a new order every time the .cfg is created
            for line in current_cfg[name]:
                cfgfile.write('// ' + line + '\n')

        cfgfile.close()
Пример #60
0
def keymenu_cmd(args):
    if len(args):
        subcmd = args[0].lower()
        if len(args) > 1:
            kname = args[1]
        else:
            kname = ''
        if len(kname) and keymenulib.exists(kname):
            k = keymenulib.find(kname)
        else:
            k = None
        if subcmd == 'create':
            if len(args) > 6:
                index = 5
                titletext = ''
                if args[index] == '#key':
                    menudisplay = args[index]
                    index += 1
                elif args[index] == '#keyvalue':
                    menudisplay = args[index] + ' ' + args[index+1]
                    index += 2
                if args[index] == '#key':
                    menureturn = args[index]
                    index += 1
                elif args[index] == '#keyvalue':
                    menureturn = args[index] + ' ' + args[index+1]
                    index += 2
                for subindex in range(index, len(args)):
                    titletext += args[subindex] + ' '
                keymenulib.create(kname, args[2], args[3], args[4], menudisplay, menureturn, titletext.rstrip())
            else:
                es.dbgmsg(0, 'Syntax: keymenu create <name> <return var> <script/block> <keygroup> <menu display> <menu return> Menu Title Text')
        elif subcmd == 'delete':
            if kname and len(args) > 1:
                if k:
                    keymenulib.delete(kname)
                else:
                    es.dbgmsg(0, 'keymenu delete: No such keymenu: %s' % kname)
            else:
                es.dbgmsg(0, 'Syntax: keymenu delete <name>')
        elif subcmd == 'send':
            if kname and len(args) > 2:
                if k:
                    if '#' in args[2]:
                        args[2] = args[2].replace('#', ',#')[1:]
                    if len(args) > 3 and args[3].isdigit():
                        k.send(playerlib.getUseridList(args[2]), int(args[3]))
                    else:
                        k.send(playerlib.getUseridList(args[2]))
                else:
                    es.dbgmsg(0, 'keymenu send: No such keymenu: %s' % kname)
            else:
                es.dbgmsg(0, 'Syntax: keymenu send <name> <users> [page]')
        elif subcmd == 'unsend':
            if kname and len(args) > 2:
                if k:
                    if '#' in args[2]:
                        args[2] = args[2].replace('#', ',#')[1:]
                    if len(args) > 3 and args[3].isdigit():
                        k.unsend(playerlib.getUseridList(args[2]), int(args[3]))
                    else:
                        k.unsend(playerlib.getUseridList(args[2]))
                else:
                    es.dbgmsg(0, 'keymenu unsend: No such keymenu: %s' % kname)
            else:
                es.dbgmsg(0, 'Syntax: keymenu unsend <name> <users> [page]')
        elif subcmd == 'update':
            if kname and len(args) > 1:
                if k:
                    if len(args) > 2:
                        if es.exists('keygroup', args[2]):
                            k.update(args[2])
                        else:
                            es.dbgmsg(0, 'keymenu update: No such keygroup: %s' % args[2])
                    else:
                        k.update()
                else:
                    es.dbgmsg(0, 'keymenu update: No such keymenu: %s' % kname)
            else:
                es.dbgmsg(0, 'Syntax: keymenu update <name> [keygroup]')
        elif subcmd == 'exists':
            if len(args) > 2:
                es.ServerVar(args[1]).set(int(keymenulib.exists(args[2])))
            else:
                es.dbgmsg(0, 'Syntax: keymenu exists <var> <name>')
        elif subcmd == 'getpages':
            if len(args) > 2:
                if keymenulib.exists(args[2]):
                    es.ServerVar(args[1]).set(int(keymenulib.find(args[2]).getpages()))
                else:
                    es.dbgmsg(0, 'keymenu getpages: No such keymenu: %s' % args[2])
            else:
                es.dbgmsg(0, 'Syntax: keymenu getpages <var> <name>')
        elif subcmd == 'getmenuname':
            if len(args) > 2:
                if popuplib.exists(args[2]):
                    es.ServerVar(args[1]).set(str(keymenulib.getmenuname(args[2])))
                else:
                    es.dbgmsg(0, 'keymenu getmenuname: No such popup: %s' % args[2])
            else:
                es.dbgmsg(0, 'Syntax: keymenu getmenuname <var> <popup-name>')
        elif subcmd == 'changeblock':
            if len(args) > 2:
                if k:
                    k.changeblock(args[2])
                else:
                    es.dbgmsg(0, 'keymenu changeblock: No such keymenu: %s' % kname)
            else:
                es.dbgmsg(0, 'Syntax: keymenu changeblock <name> <script/block>')
        elif subcmd == 'backmenu':
            if len(args) > 2:
                if k:
                    k.backmenu(args[2])
                else:
                    es.dbgmsg(0, 'keymenu backmenu: No such keymenu: %s' % kname)
            else:
                es.dbgmsg(0, 'Syntax: keymenu backmenu <name> <keymenu/popup>')
        elif subcmd == 'setvar':
            if len(args) > 3:
                if k:
                    if args[2].isalnum():
                        setattr(k, args[2], args[3])
                    else:
                        es.dbgmsg(0, 'keymenu setvar: Invalid keymenu variable name')
                else:
                    es.dbgmsg(0, 'keymenu setvar: No such keymenu: %s' % kname)
            else:
                es.dbgmsg(0, 'Syntax: keymenu setvar <name> <variable> <value>')
        elif subcmd == 'getvar':
            if len(args) > 4:
                if k:
                    if args[3].isalnum() and hasattr(k, args[3]):
                        es.ServerVar(args[2]).set(getattr(k, args[3]))
                    else:
                        es.dbgmsg(0, 'keymenu getvar: Invalid keymenu variable name')
                else:
                    es.dbgmsg(0, 'keymenu getvar: No such keymenu: %s' % kname)
            else:
                es.dbgmsg(0, 'Syntax: keymenu getvar <name> <var> <variable>')
        elif subcmd == 'list':
            if len(args) > 1:
                listlevel = int(kname)
            else:
                listlevel = 0
            for kname in keymenulib.getmenulist():
                keymenulib.find(kname).information(listlevel)
            if not len(args) > 1:
                es.dbgmsg(0, ' ')
                es.dbgmsg(0, 'For more details, supply list level (0-1):')
                es.dbgmsg(0, 'Syntax: keymenu list [level]')
        elif subcmd == 'info':
            if k:
                k.information(listlevel, 1)
            else:
                es.dbgmsg(0, 'keymenu info: No such keymenu: %s' % kname)
            if not len(args) > 1:
                es.dbgmsg(0, ' ')
                es.dbgmsg(0, 'Syntax: keymenu info <name>')
        else:
            es.dbgmsg(0, 'Invalid keymenu subcommand, see http://www.eventscripts.com/pages/Keymenu/ for a list of subcommands')
    else:
        es.dbgmsg(0, 'Missing keymenu subcommand, see http://www.eventscripts.com/pages/Keymenu/ for a list of subcommands')