Example #1
0
def gg_team_win(event_var):
    '''Fired when a team wins the match'''

    # Reset team level and multikill values
    gg_teams.clear()

    # Send Winner Messages?
    if int(gg_teamplay_winner_messages):

        # Send Winner Messages
        gg_teams[int(event_var['winner'])].send_winner_messages()

    # Get a random player from the server
    userid = getuserid()

    # End the match
    ServerCommand('es_xgive %s game_end' % userid)
    ServerCommand('es_xfire %s game_end EndGame' % userid)

    # Loop through all players on the server
    for userid in getUseridList():

        # Is the player a bot?
        if isbot(userid):

            # If so, don't play the sound
            continue

        # Play the winner sound to the player
        Player(userid).playsound('winner')
Example #2
0
def round_start(ev):
    Number = random.randint(1, 5)
    Player = es.getuserid()
    if (Player):
        if (Number == 1):
            es.emitsound("player", Player, "music/HL2_song3.mp3", 0.45, 0)
        if (Number == 2):
            es.emitsound("player", Player, "music/HL2_song29.mp3", 0.45, 0)
        if (Number == 3):
            es.emitsound("player", Player, "music/HL2_song20_submix4.mp3",
                         0.45, 0)
        if (Number == 4):
            es.emitsound("player", Player, "music/HL2_song14.mp3", 0.45, 0)
        if (Number == 5):
            es.emitsound("player", Player, "music/HL2_song16.mp3", 0.45, 0)
    es.ServerVar("mp_roundtime").set(9)
    es.ServerVar("ammo_338mag_max").set(1000)
    es.ServerVar("ammo_357sig_max").set(1000)
    es.ServerVar("ammo_45acp_max").set(1000)
    es.ServerVar("ammo_50AE_max").set(1000)
    es.ServerVar("ammo_556mm_box_max").set(1000)
    es.ServerVar("ammo_556mm_max").set(1000)
    es.ServerVar("ammo_57mm_max").set(1000)
    es.ServerVar("ammo_762mm_max").set(1000)
    es.ServerVar("ammo_9mm_max").set(1000)
    es.ServerVar("ammo_buckshot_max").set(1000)
Example #3
0
def getPlayerList(players):
    """Returns a set of RestrictedPlayer or RestrictedTeam instances based on userid or team tag"""
    if isinstance(players, str):
        if players.startswith('@'):
            if players[1:] == 'all':
                players = (getTeam(2), getTeam(3))
            elif acceptable_teams.has_key(players[1:]):
                players = (getTeam(acceptable_teams[players[1:]]), )
            else:
                raise ValueError, 'Invalid team tag \"%s\"' % players

        elif players.startswith('#'):
            if players[1:] == 'all':
                players = es.getUseridList()
            elif acceptable_teams.has_key(players[1:]):
                team = acceptable_teams[players[1:]]
                players = filter(lambda x: es.getplayerteam(x) == team,
                                 es.getUseridList())
            else:
                raise ValueError, 'Invalid team tag \"%s\"' % players

            players = map(getPlayer, players)

        else:
            userid = es.getuserid(players)
            if not userid:
                raise ValueError, 'Invalid player \"%s\"' % players

            players = (getPlayer(userid), )

    elif isinstance(players, (int, float)):
        players = (getPlayer(players), )

    return players
Example #4
0
 def clientAddXp(self, userid, args=None):
     """
     This method is a client command callback when an admin runs the command
     rpgaddxp <steamid> <amount>. This will be generally called from the
     custom menu with the escape input box. Execute the addition of the experience
     
     @PARAM userid - the admin's id who executed the command
     @PARAM args - any additional arguments after the command
     """
     if args is None:
         args = userid
         userid = None
     if len(args) != 2:
         if len(args) == 6:
             args = ("".join(args[:5]), args[5])
         else:
             es.dbgmsg(0, "rpgaddxp <steamid> <amount>")
             return
     steamid, amount = args
     if not str(amount).isdigit():
         es.dbgmsg(0, "rpgaddxp <steamid> <amount>")
         return
     if not steamid.lower().startswith("steam"):
         userid = es.getuserid(steamid)
         if userid is None:
             return
         steamid = es.getplayersteamid(userid)
     amount = int(amount)
     popup.addXp(userid, amount, "sourcerpg_addxp_player%s" % steamid)
Example #5
0
 def upgradeSkill(self, userid, choice, popupid):
     """
     This method increments a skill at the admin's choice by one.
     
     @PARAM userid - the admin who decremented the skill
     @PARAM choice - the skill to decrement
     @PARAM popupid - the name of the popup used to get here
     """
     target = popupid.replace("sourcerpg_upgrade_player", "")
     if self.isOnline(target):
         sourcerpg.checkSkillForUpgrading(es.getuserid(target), choice,
                                          None, False, False)
     else:
         """ Player is offline, make sure that you don't go over the max level """
         level = sourcerpg.database.getSkillLevel(target, choice)
         if level is None:
             query = "SELECT UserID FROM Player WHERE steamid=?"
             sourcerpg.database.execute(query, target)
             dbuserid = sourcerpg.database.fetchone()
             query = "INSERT INTO Skill (name, UserID, level) VALUES (?, ?, 1)"
             sourcerpg.database.execute(query, choice, dbuserid)
         else:
             skill = sourcerpg.skills[choice]
             if level < int(skill.maxLevel):
                 level += 1
                 sourcerpg.database.updateSkillForPlayer(
                     target, choice, level)
     self.buildPlayerSkillsMenu("sourcerpg_upgrade_player%s" % target,
                                target, self.upgradeSkill,
                                "sourcerpg_player%s" % target,
                                True).send(userid)
Example #6
0
 def downgradeSkill(self, userid, choice, popupid):
     """
     This method decrements a skill at the admin's choice by one.
     
     @PARAM userid - the admin who decremented the skill
     @PARAM choice - the skill to decrement
     @PARAM popupid - the name of the popup used to get here
     """
     target = popupid.replace("sourcerpg_downgrade_player", "")
     if self.isOnline(target):
         sourcerpg.checkSkillForSelling(es.getuserid(target), choice, None,
                                        False, False)
     else:
         """ Player is offline, makes sure we don't go below 0 """
         level = sourcerpg.database.getSkillLevel(target, choice)
         if level is None:
             level = 0
         if level > 0:
             level -= 1
             if level == 0:
                 query = "SELECT UserID FROM Player WHERE steamid=?"
                 sourcerpg.database.execute(query, target)
                 dbuserid = sourcerpg.database.fetchone()
                 query = "DELETE FROM Skill WHERE name=? AND UserID=?"
                 sourcerpg.database.execute(query, choice, dbuserid)
             else:
                 sourcerpg.database.updateSkillForPlayer(
                     target, choice, level)
     #self.chosenPlayer(userid, target, 'sourcerpg_admin')
     self.buildPlayerSkillsMenu("sourcerpg_downgrade_player%s" % target,
                                target, self.downgradeSkill,
                                "sourcerpg_player%s" % target,
                                False).send(userid)
Example #7
0
 def downgradeSkill(self, userid, choice, popupid):
     """
     This method decrements a skill at the admin's choice by one.
     
     @PARAM userid - the admin who decremented the skill
     @PARAM choice - the skill to decrement
     @PARAM popupid - the name of the popup used to get here
     """
     target = popupid.replace("sourcerpg_downgrade_player", "")
     if self.isOnline(target):
         sourcerpg.checkSkillForSelling(es.getuserid(target), choice, None, False, False)
     else:
         """ Player is offline, makes sure we don't go below 0 """
         level = sourcerpg.database.getSkillLevel(target, choice)
         if level is None:
             level = 0
         if level > 0:
             level -= 1
             if level == 0:
                 query = "SELECT UserID FROM Player WHERE steamid=?"
                 sourcerpg.database.execute(query, target)
                 dbuserid = sourcerpg.database.fetchone()
                 query = "DELETE FROM Skill WHERE name=? AND UserID=?"
                 sourcerpg.database.execute(query, choice, dbuserid)
             else:
                 sourcerpg.database.updateSkillForPlayer(target, choice, level)
     #self.chosenPlayer(userid, target, 'sourcerpg_admin')
     self.buildPlayerSkillsMenu("sourcerpg_downgrade_player%s" % target, target, self.downgradeSkill, "sourcerpg_player%s" % target, False).send(userid)
def choosePlayer():
    '''
    Used by chooseKick() to determine a player to kick
    '''
    kicklist = playerlib.getPlayerList("#res")
    kickuid = playerlib.getPlayer(es.getuserid(
    ))  # get a random player to return if none of the others return anything.
    if int(xareserveslots.setting.getVariable(
            "reserve_slots_kick_method")) == 1:
        timelowest = None
        for id in kicklist:
            time = id.attributes["timeconnected"]
            if timelowest is None or time < timelowest:
                timelowest = time
                kickuid = id
        return kickuid
    else:
        ping = -1
        for id in kicklist:
            pping = id.attributes["ping"]
            if pping > ping:
                ping = pping
                kickuid = id
        return kickuid
    return kickuid
Example #9
0
def gg_team_win(event_var):
    '''Fired when a team wins the match'''

    # Reset team level and multikill values
    gg_teams.clear()

    # Send Winner Messages?
    if int(gg_teamplay_winner_messages):

        # Send Winner Messages
        gg_teams[int(event_var['winner'])].send_winner_messages()

    # Get a random player from the server
    userid = getuserid()

    # End the match
    ServerCommand('es_xgive %s game_end' % userid)
    ServerCommand('es_xfire %s game_end EndGame' % userid)

    # Loop through all players on the server
    for userid in getUseridList():

        # Is the player a bot?
        if isbot(userid):

            # If so, don't play the sound
            continue

        # Play the winner sound to the player
        Player(userid).playsound('winner')
Example #10
0
 def getDetails(steamid):
     """
     This method returns the details of a user. It will either use
     the SourceRPG PlayerObject if the player is online, otherwise it'll
     query results from the database directly
     
     @RETRUN dictionary - strings containing the values of the objects
     """
     if steamid.startswith("BOT"):
         steamid = steamid.split("_", 1)[1]
     values = {}
     if popup.isOnline(steamid):
         """ The player is online, query PlayerObject instance """
         userid = es.getuserid(steamid)
         return sourcerpg.players[userid]
     """ The player is offline, query database """
     """ Query the stats of the player """
     query = "SELECT name,level,xp,credits FROM Player WHERE steamid=?"
     sourcerpg.database.execute(query, steamid)
     values['name'], values['level'], values['xp'], values[
         'credits'] = sourcerpg.database.cursor.fetchone()
     """ Query the levels of the current loaded skills """
     for skill in sourcerpg.skills:
         level = sourcerpg.database.getSkillLevel(steamid, skill.name)
         if level is None:
             level = 0
         values[skill.name] = level
     """ Return a dictionary object which imitats a PlayerObect reference """
     return values
Example #11
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)
Example #12
0
def redirect_cmd():
    """
    redirect <userid/player name/"Steam ID"> ["IP"] [kick] [delay]
    Ensures a correct number of arguments were provided
    Ensures the specified player exists
    Retrieves the optional arguments while converting them to the desired type
    Calls send_prompt with the specified arguments
    """
    int_arg_count = es.getargc()
    int_cmd_userid = es.getcmduserid()

    if int_arg_count in (2, 3, 4, 5):
        str_player_arg = es.getargv(1)
        int_userid = es.getuserid(str_player_arg)

        if int_userid:
            list_args = [int_userid, str(var_ip), int(var_kick), float(var_delay)]
            dict_arg_types = {2:str, 3:int, 4:float}
            for int_x in range(2, int_arg_count):
                try:
                    list_args[int_x - 1] = dict_arg_types[int_x](es.getargv(int_x))
                except:
                    display_feedback(int_cmd_userid, 'invalid argument', {'arg':es.getargv(int_x), 'type':dict_arg_types[int_x].__name__})
                    return

            send_prompt(*list_args)

        else:
            display_feedback(int_cmd_userid, 'no player', {'player':str_player_arg})

    else:
        display_feedback(int_cmd_userid, 'syntax', {'syntax':'xaredirect <userid/player name/\"Steam ID\"> [\"IP\"] [kick] [delay]'})
Example #13
0
 def clientAddXp(self, userid, args=None):
     """
     This method is a client command callback when an admin runs the command
     rpgaddxp <steamid> <amount>. This will be generally called from the
     custom menu with the escape input box. Execute the addition of the experience
     
     @PARAM userid - the admin's id who executed the command
     @PARAM args - any additional arguments after the command
     """
     if args is None:
         args = userid
         userid = None
     if len(args) != 2:
         if len(args) == 6:
             args = ("".join(args[:5]), args[5])
         else:
             es.dbgmsg(0, "rpgaddxp <steamid> <amount>")
             return
     steamid, amount = args
     if not str(amount).isdigit():
         es.dbgmsg(0, "rpgaddxp <steamid> <amount>")
         return
     if not steamid.lower().startswith("steam"):
         userid = es.getuserid(steamid)
         if userid is None:
             return
         steamid = es.getplayersteamid(userid)
     amount = int(amount)
     popup.addXp(userid, amount, "sourcerpg_addxp_player%s" % steamid)
Example #14
0
    def getDetails(steamid ):
        """
        This method returns the details of a user. It will either use
        the SourceRPG PlayerObject if the player is online, otherwise it'll
        query results from the database directly
        
        @RETRUN dictionary - strings containing the values of the objects
        """
        if steamid.startswith("BOT"):
            steamid = steamid.split("_", 1)[1]
        values = {}
        if popup.isOnline(steamid):
            """ The player is online, query PlayerObject instance """
            userid = es.getuserid(steamid)
            return sourcerpg.players[userid] 
        """ The player is offline, query database """


        """ Query the stats of the player """
        query = "SELECT name,level,xp,credits FROM Player WHERE steamid=?"
        sourcerpg.database.execute(query, steamid)
        values['name'], values['level'], values['xp'], values['credits'] = sourcerpg.database.cursor.fetchone()
        
        """ Query the levels of the current loaded skills """
        for skill in sourcerpg.skills:
            level = sourcerpg.database.getSkillLevel(steamid, skill.name)
            if level is None:
                level = 0
            values[skill.name] = level 
            
        """ Return a dictionary object which imitats a PlayerObect reference """
        return values
Example #15
0
def _get_matching_players(users):
    '''Return a set() of players matching the given filter...'''
    
    # Get a set to store the matching players...
    return_value = set()
    
    # Is the player a single userid?
    if es.exists('userid', users):
        
        # Add that player...
        return_value.add(int(users))
        
    # Otherwise, is that a playerlib's filter?
    elif str(users).startswith('#'):
        
        # Loop through all matching players...
        for userid in playerlib.getUseridList(users):
            
            # Add the player...
            return_value.add(userid)
            
    # Otherwise...
    else:
        
        # Try to find a userid...
        userid = es.getuserid(users)
        
        # Any match found?
        if userid:
            
            # Add the player...
            return_value.add(userid)
            
    # Finaly, return the matching players...
    return return_value
Example #16
0
def getPlayerList(players):
   """Returns a set of RestrictedPlayer or RestrictedTeam instances based on userid or team tag"""
   if isinstance(players, str):
      if players.startswith('@'):
         if players[1:] == 'all':
            players = (getTeam(2), getTeam(3))
         elif acceptable_teams.has_key(players[1:]):
            players = (getTeam(acceptable_teams[players[1:]]),)
         else:
            raise ValueError, 'Invalid team tag \"%s\"' % players

      elif players.startswith('#'):
         if players[1:] == 'all':
            players = es.getUseridList()
         elif acceptable_teams.has_key(players[1:]):
            team    = acceptable_teams[players[1:]]
            players = filter(lambda x: es.getplayerteam(x) == team, es.getUseridList())
         else:
            raise ValueError, 'Invalid team tag \"%s\"' % players

         players = map(getPlayer, players)

      else:
         userid = es.getuserid(players)
         if not userid:
            raise ValueError, 'Invalid player \"%s\"' % players

         players = (getPlayer(userid),)

   elif isinstance(players, (int, float)):
      players = (getPlayer(players),)

   return players
Example #17
0
 def upgradeSkill(self, userid, choice, popupid):
     """
     This method increments a skill at the admin's choice by one.
     
     @PARAM userid - the admin who decremented the skill
     @PARAM choice - the skill to decrement
     @PARAM popupid - the name of the popup used to get here
     """
     target = popupid.replace("sourcerpg_upgrade_player", "")
     if self.isOnline(target):
         sourcerpg.checkSkillForUpgrading(es.getuserid(target), choice, None, False, False)
     else:
         """ Player is offline, make sure that you don't go over the max level """
         level = sourcerpg.database.getSkillLevel(target, choice)
         if level is None:
             query = "SELECT UserID FROM Player WHERE steamid=?"
             sourcerpg.database.execute(query, target)
             dbuserid = sourcerpg.database.fetchone()
             query = "INSERT INTO Skill (name, UserID, level) VALUES (?, ?, 1)"
             sourcerpg.database.execute(query, choice, dbuserid)
         else:
             skill = sourcerpg.skills[choice]
             if level < int(skill.maxLevel):
                 level += 1
                 sourcerpg.database.updateSkillForPlayer(target, choice, level)
     self.buildPlayerSkillsMenu("sourcerpg_upgrade_player%s" % target, target, self.upgradeSkill, "sourcerpg_player%s" % target, True).send(userid)
Example #18
0
def sayFilter(userid, text, teamonly):
    player = getPlayer(userid)
    if (teamonly or player.isdead):
        for id in admins:
            admin = getPlayer(es.getuserid(id))
            if(int(userid) == int(admin.userid)):
                continue

            if((teamonly and (admin.team != player.team)) or (player.isdead and not admin.isdead)):
                text = text.strip('"')
                if (player.isdead and not admin.isdead) or (player.isdead and (teamonly and admin.team != player.team)):
                    dead = "*SPEC* " if player.team == 1 or player.team == 0 else "*DEAD* "
                else:
                    dead = ""
                if teamonly and admin.team != player.team:
                    if player.team == 0 or player.team == 1:
                        team = "(Spectator) "
                    elif player.team == 2:
                        team = "(Terrorist) "
                    else:
                        team = "(Counter-Terrorist) "
                else:
                    team = ""
                newtext = "\x01%s\x03%s\x01 %s:  %s"%(dead, player.name, team, text)
                saytext2(admin.userid, player.index, newtext)
    return (userid, text, teamonly)
Example #19
0
def convert_userid_identifier_to_players(filter_):
    # TODO: Do not use es.getuserid
    userid = es.getuserid(filter_)

    try:
        index_from_userid(userid)
    except ValueError:
        players = set()
        append = True

        for x in filter_:
            if x == '#':
                append = True
            elif x == '!':
                append = False
            else:
                found_players = PlayerIter(_team_convert.get(x, x))

                if append:
                    players.update(found_players)
                else:
                    players = players.difference(found_players)

        yield from players
    else:
        yield from (Player.from_userid(userid), )
Example #20
0
    def _endDelay(self):
        """Marks the weapons as available for player pickup"""
        self.activedelay = False

        userid = es.getuserid()
        if userid:
            es.server.cmd('es_xfire %s %s addoutput "spawnflags 0"' % (userid, self.name))
Example #21
0
    def _endDelay(self):
        """Marks the weapons as available for player pickup"""
        self.activedelay = False

        userid = es.getuserid()
        if userid:
            es.server.cmd('es_xfire %s %s addoutput \"spawnflags 0\"' %
                          (userid, self.name))
Example #22
0
 def isOnline(steamid):
     """
     This method returns if a player provided by the steamid parameter is
     currently online.
     
     @PARAM steamid - the steamid of the player to test
     @RETURN boolean - whether or not the player is currently online
     """
     return bool( es.getuserid( steamid ))
Example #23
0
 def isOnline(steamid):
     """
     This method returns if a player provided by the steamid parameter is
     currently online.
     
     @PARAM steamid - the steamid of the player to test
     @RETURN boolean - whether or not the player is currently online
     """
     return bool(es.getuserid(steamid))
Example #24
0
def EndMap( APIAccessorModule = None ):
    global change_map
    change_map = None
    winner = es.ServerVar('eventscripts_nextmapoverride')
    userid = es.getuserid()
    if not userid:
        return
    es.server.queuecmd('nextlevel %s'%winner)
    es.server.queuecmd('es_give %s game_end'%userid)
    es.server.queuecmd('es_fire %s game_end EndGame'%userid)
Example #25
0
def EndMap(APIAccessorModule=None):
    global change_map
    change_map = None
    winner = es.ServerVar('eventscripts_nextmapoverride')
    userid = es.getuserid()
    if not userid:
        return
    es.server.queuecmd('nextlevel %s' % winner)
    es.server.queuecmd('es_give %s game_end' % userid)
    es.server.queuecmd('es_fire %s game_end EndGame' % userid)
Example #26
0
def round_start(event_var):
    '''Called at the start of every round'''

    # Set the round as active
    ActiveInfo.round = True

    # Retrieve a random userid
    userid = es.getuserid()

    # Disable Buyzones
    es.server.queuecmd('es_xfire %s func_buyzone Disable' % userid)
Example #27
0
def _addadmin_select(userid,choice,popupid):
    es.dbgmsg(1,'*****_addadmin_select')
    if choice[1]:
        id = es.getuserid(choice[0])
        steamid = es.getplayersteamid(id)
        basicadmins = str(es.ServerVar('BASIC_AUTH_ADMIN_LIST'))
        basicadmins = basicadmins.split(';')
        if steamid not in basicadmins:
            _update_badmins(steamid,choice[0],'0','0')
        else:
            es.tell(userid, '#multi', prefix + choice[0] + ' is already an admin.')
Example #28
0
def round_start(event_var):
    '''Called at the start of every round'''

    # Set the round as active
    ActiveInfo.round = True

    # Retrieve a random userid
    userid = es.getuserid()

    # Disable Buyzones
    es.server.queuecmd('es_xfire %s func_buyzone Disable' % userid)
Example #29
0
    def addXp(self, userid, choice, popupid):
        """
        This method adds a cetain amount of experience to a player. If the player
        is online when we shall execute the method to add the experience; otherwise
        we have to query the experience levels and credits and simulate the 
        main thesis behind incrementing the experience and testing for levels up
        only with values from the database rather than throught the PlayerObject
        instance.
        
        @PARAM userid - the admin who gave the experience
        @PARAM choice - the amount of experience to award
        @PARAM popupid - the id of the popup which was used to give the player experience
        """
        target = popupid.replace("sourcerpg_addxp_player", "")
        if isinstance(choice, str):
            if choice.isdigit():
                choice = int(choice)
        if isinstance(choice, int):
            tokens = {}
            tokens['amount'] = str(choice)
            if popup.isOnline(target):
                player = es.getuserid(target)
                sourcerpg.players[player].addXp(choice, 'being liked by the admin')
                tokens['name'] = sourcerpg.players[player]['name']
                if userid is not None:
                    self.chosenPlayer(userid, target, "sourcerpg_onlineplayers")
            else:
                query = "SELECT xp,level,name FROM Player WHERE steamid=?"
                sourcerpg.database.execute(query, target)
                xp, level, name = sourcerpg.database.fetchone()
                xp += choice
                amountOfLevels = 0
                nextXpAmount = level * int(sourcerpg.xpIncrement) + int(sourcerpg.startXp)
                while xp > nextXpAmount:
                    xp -= nextXpAmount
                    amountOfLevels += 1
                    nextXpAmount += int(sourcerpg.xpIncrement)
                if amountOfLevels:
                    query = "UPDATE Player SET xp=?, level=level+?, credits=credits+? WHERE steamid=?"
                    sourcerpg.database.execute(query, xp, amountOfLevels, amountOfLevels * int(sourcerpg.creditsReceived), target)
                else:
                    query = "UPDATE Player SET xp=? WHERE steamid=?"
                    sourcerpg.database.execute(query, xp, target)
                sourcerpg.database.execute(query)

                tokens['name'] = name
                if userid is not None:
                    self.chosenPlayer(userid, target, "sourcerpg_offlineplayers")
            if userid is not None:
                tell(userid, 'add xp', tokens)
        else:
            tell(userid, 'escape')
            es.escinputbox(30, userid, '=== %s Add Xp ===' % sourcerpg.prefix, 
                'Enter the amount' , 'rpgaddxp %s' % target)
Example #30
0
def setupDissolver():
    # Get a userid
    userid = es.getuserid()

    #Give the dissolver entity and set some keyvalues
    cmd = ('es_xgive %s env_entity_dissolver;' % userid +
           'es_xfire %s env_entity_dissolver ' % userid +
           'AddOutput "target cs_ragdoll";' +
           'es_xfire %s env_entity_dissolver AddOutput "magnitude 1"' % userid)

    # Run the command
    es.server.queuecmd(cmd)
Example #31
0
def setupDissolver():
    # Get a userid
    userid = es.getuserid()

    #Give the dissolver entity and set some keyvalues
    cmd = ('es_xgive %s env_entity_dissolver;' % userid +
          'es_xfire %s env_entity_dissolver ' % userid +
          'AddOutput "target cs_ragdoll";' +
          'es_xfire %s env_entity_dissolver AddOutput "magnitude 1"' % userid)

    # Run the command
    es.server.queuecmd(cmd)
Example #32
0
    def createDelay(self):
        """
      Designates all weapons of the desired type as "reserved for NPC"
      """
        self.removeDelay()

        userid = es.getuserid()
        if userid:
            es.server.cmd('es_xfire %s %s addoutput "spawnflags 2"' % (userid, self.name))

            self.activedelay = True
            gamethread.delayedname(repickup, "xarestrict_weapon_%s" % self.name, self._endDelay)
def _addadmin_select(userid, choice, popupid):
    es.dbgmsg(1, '*****_addadmin_select')
    if choice[1]:
        id = es.getuserid(choice[0])
        steamid = es.getplayersteamid(id)
        basicadmins = str(es.ServerVar('BASIC_AUTH_ADMIN_LIST'))
        basicadmins = basicadmins.split(';')
        if steamid not in basicadmins:
            _update_badmins(steamid, choice[0], '0', '0')
        else:
            es.tell(userid, '#multi',
                    prefix + choice[0] + ' is already an admin.')
Example #34
0
def getViewPlayer(userid):
    '''Get the player a player is looking at...'''
    
    # Get the index of the entity the player is looking at...
    index = getViewEntity(userid)
    
    # Is the index not valid?
    if not index or es.entitygetvalue(index, 'classname') != 'player':
        
        # Don't go further...
        return None
        
    # Return the player userid...
    return es.getuserid(es.gethandlefromindex(index))
Example #35
0
def getPlayerList(players):
    """Returns a set of RestrictedPlayer or RestrictedTeam instances based on userid or team tag"""
    if isinstance(players, str):
        if players.startswith('@'):
            if players[1:] == 'all':
                players = (getTeam(2), getTeam(3))
            elif acceptable_teams.has_key(players[1:]):
                players = (getTeam(acceptable_teams[players[1:]]), )
            else:
                #bugfix: echo to users console (useful message)
                usermsg.echo(
                    "#all",
                    'xarestrict error: invalid tag \"%s\" [command accepts @all, @ct, @t]'
                    % players)
                raise ValueError, 'Invalid team tag \"%s\"' % players

        elif players.startswith('#'):
            if players[1:] == 'all':
                players = es.getUseridList()
            elif acceptable_teams.has_key(players[1:]):
                team = acceptable_teams[players[1:]]
                players = filter(lambda x: es.getplayerteam(x) == team,
                                 es.getUseridList())
            else:
                #bugfix: echo to users console (useful message)
                usermsg.echo(
                    "#all",
                    'xarestrict error: invalid tag \"%s\" [command accepts #all, #ct, #t]'
                    % players)
                raise ValueError, 'Invalid team tag \"%s\"' % players

            players = map(getPlayer, players)

        else:
            userid = es.getuserid(players)
            if not userid:
                #bugfix: echo to users console (useful message)
                usermsg.echo(
                    "#all",
                    'xarestrict error: invalid player \"%s\" [command accepts partial username, userid or steamid]'
                    % players)
                raise ValueError, 'Invalid player \"%s\"' % players

            players = (getPlayer(userid), )

    elif isinstance(players, (int, float)):
        players = (getPlayer(players), )

    return players
Example #36
0
    def createDelay(self):
        """
      Designates all weapons of the desired type as "reserved for NPC"
      """
        self.removeDelay()

        userid = es.getuserid()
        if userid:
            es.server.cmd('es_xfire %s %s addoutput \"spawnflags 2\"' %
                          (userid, self.name))

            self.activedelay = True
            gamethread.delayedname(repickup,
                                   'xarestrict_weapon_%s' % self.name,
                                   self._endDelay)
Example #37
0
def load():
    loadSpawnFile(str(es.ServerVar("eventscripts_currentmap")))

    userid = es.getuserid()

    # If there are no players on the server, stop here
    if not userid:
        return

    pointsLoaded = True

    if not spawnPoints:
        return

    loadRandomPoints(userid)
Example #38
0
def VenomCycle(userid, venom, attacker):
    if not es.getuserid(userid) or not es.getuserid(attacker):
        return
    player = playerlib.getPlayer(userid)
    if player.isdead:
        return
    if venom == 0:
        return
    elif venom == 1:
        es.server.queuecmd('damage %s 1 1024 %s'%(userid,attacker))
        venom -= 1
        fade(userid, 0, 0.2, 0.2, 0, 255, 0, 50)
    elif venom == 2:
        es.server.queuecmd('damage %s 2 1024 %s'%(userid,attacker))
        venom -=  2
    elif venom == 3:
         es.server.queuecmd('damage %s 3 1024 %s'%(userid,attacker))
         venom -= 3
         fade(userid, 0, 0.2, 0.2, 0, 255, 0, 50)
    elif venom > 0:
        es.server.queuecmd('damage %s 4 1024 %s'%(userid,attacker))
        venom -= 4
        fade(userid, 0, 0.2, 0.2, 0, 255, 0, 50)
    gamethread.delayedname(1, VenomCycle, VenomCycle, (userid, venom, attacker))
Example #39
0
def load():
    loadSpawnFile(str(es.ServerVar("eventscripts_currentmap")))

    userid = es.getuserid()

    # If there are no players on the server, stop here
    if not userid:
        return

    pointsLoaded = True

    if not spawnPoints:
        return

    loadRandomPoints(userid)
Example #40
0
def disable_objectives():
    '''Disables Objectives on the map'''

    # Get a userid
    userid = es.getuserid()

    # Is there a userid on the server?
    if not userid:

        # If not, es_xfire cannot be ran, so simply return
        return

    # Get map info
    map_objectives = int(gg_map_obj)

    # Set up the command to format
    cmd = ''

    # Do Bombing Objectives need removed?
    if map_objectives in (1, 2):

        # Are there any func_bomb_target indexes
        if len(es.getEntityIndexes('func_bomb_target')):

            # Disable all func_bomb_target entities
            cmd += 'es_xfire %d func_bomb_target Disable;' % userid

            # Kill all weapon_c4 entities
            cmd += 'es_xfire %d weapon_c4 Kill;' % userid

    # Do Hostage Objectives need removed?
    if map_objectives in (1, 3):

        # Are there any func_hostage_rescue indexes?
        if len(es.getEntityIndexes('func_hostage_rescue')):

            # Disable all func_hostage_rescue entities
            cmd += 'es_xfire %d func_hostage_rescue Disable;' % userid

            # Kill all hostage_entity entities
            cmd += 'es_xfire %d hostage_entity Kill;' % userid

    # Is there a command string?
    if cmd:

        # Execute the command string to disable objectives
        es.server.queuecmd(cmd)
Example #41
0
def disable_objectives():
    '''Disables Objectives on the map'''

    # Get a userid
    userid = es.getuserid()

    # Is there a userid on the server?
    if not userid:

        # If not, es_xfire cannot be ran, so simply return
        return

    # Get map info
    map_objectives = int(gg_map_obj)

    # Set up the command to format
    cmd = ''

    # Do Bombing Objectives need removed?
    if map_objectives in (1, 2):

        # Are there any func_bomb_target indexes
        if len(es.getEntityIndexes('func_bomb_target')):

            # Disable all func_bomb_target entities
            cmd += 'es_xfire %d func_bomb_target Disable;' % userid

            # Kill all weapon_c4 entities
            cmd += 'es_xfire %d weapon_c4 Kill;' % userid

    # Do Hostage Objectives need removed?
    if map_objectives in (1, 3):

        # Are there any func_hostage_rescue indexes?
        if len(es.getEntityIndexes('func_hostage_rescue')):

            # Disable all func_hostage_rescue entities
            cmd += 'es_xfire %d func_hostage_rescue Disable;' % userid

            # Kill all hostage_entity entities
            cmd += 'es_xfire %d hostage_entity Kill;' % userid

    # Is there a command string?
    if cmd:

        # Execute the command string to disable objectives
        es.server.queuecmd(cmd)
Example #42
0
 def buildPlayerSkillsMenu(popupName, target, function, returnPopup, upgrade=True):
     """
     This function builds the skills for a player and allows us to
     choose an option from the menu calling back as the function
     
     @PARAM name - the name of the popup
     @PARAM target - the steamid of the players skills you'd like to show
     @PARAM function - the function to execute as a callback
     @PARAM returnPopup - the popup which will be used to go back to
     @RETRURN Popup_popup instance
     """
     popupInstance = popuplib.easymenu(popupName, "_popup_choice", function)
     popupInstance.settitle("=== %s Admin ===" % sourcerpg.prefix)
     """ If the target is online we can use the PlayerObject instance """
     if popup.isOnline(target):
         userid = es.getuserid(target)
         for skill in sourcerpg.skills:
             level = sourcerpg.players[userid][skill.name]
             if upgrade:
                 if level >= int(skill.maxLevel):
                     popupInstance.addoption(None, skill.name + " (MAXED)", False )
                 else:
                     popupInstance.addoption(skill.name, skill.name + "(" + str(level) + " => " + str(level + 1) + ")" )
             else:
                 if level <= 0:
                     popupInstance.addoption(None, skill.name + " (MINIMUM)", False)
                 else:
                     popupInstance.addoption(skill.name, skill.name + "(" + str(level) + " => " + str(level - 1) + ")" )
     else:
         """ Otherwise we have to get the skill level directly from the database """
         for skill in sourcerpg.skills:
             level = sourcerpg.database.getSkillLevel(target, skill.name)
             if level is None:
                 level = 0
             if upgrade:
                 if level >= int(skill.maxLevel):
                     popupInstance.addoption(None, skill.name + " (MAXED)", False )
                 else:
                     popupInstance.addoption(skill.name, skill.name + "(" + str(level) + " => " + str(level + 1) + ")" )
             else:
                 if level <= 0:
                     popupInstance.addoption(None, skill.name + " (MINIMUM)", False)
                 else:
                     popupInstance.addoption(skill.name, skill.name + "(" + str(level) + " => " + str(level - 1) + ")" )
     popupInstance.submenu(10, returnPopup)
     return popupInstance
Example #43
0
def _admin_say_tell(adminid, message, teamonly):
    position = 0 
    tokens = {}
    username = ''
    messagetokens = message.split()
    if not messagetokens:
        return
    if messagetokens[0].startswith('"') and message.count('"') >= 2:
        for part in messagetokens:
            position += 1
            username += ' '+part.strip('"')
            if part.endswith('"'):
                break
        try:
            message = ' '.join(messagetokens[position:])
        except:
            message = ''
    elif messagetokens[0].startswith("'") and message.count("'") >= 2:
        for part in messagetokens:
            position += 1
            username += ' '+part.strip("'")
            if part.endswith("'"):
                break
        try:
            message = ' '.join(messagetokens[position:])
        except:
            message = ''
    else:
        username = messagetokens[0]
        message = ' '.join(messagetokens[1:])
    username = username.lstrip()
    userid = es.getuserid(username)
    if userid: 
        tokens['adminname'] = es.getplayername(adminid) 
        tokens['username']  = es.getplayername(userid) 
        tokens['message']   = message
        if not teamonly: 
            es.tell(userid , '#multi', xalanguage('admin to player', tokens, playerlib.getPlayer(userid).get("lang"))) 
            es.tell(adminid, '#multi', xalanguage('admin to player', tokens, playerlib.getPlayer(adminid).get("lang"))) 
        else: 
            es.centertell(userid , xalanguage('admin center to player', tokens, playerlib.getPlayer(userid).get("lang"))) 
            es.centertell(adminid, xalanguage('admin center to player', tokens, playerlib.getPlayer(adminid).get("lang"))) 
    else: 
        tokens['username'] = username
        es.tell(adminid, '#multi', xalanguage('no player found', tokens, playerlib.getPlayer(adminid).get("lang"))) 
    return (0,'',0)
Example #44
0
 def sendPlayerVoteMenu(self,userid):
     if not es.getuserid(userid): return
     player = playerlib.getPlayer(userid)
     message, tokens = self.checkSendVote(player.uniqueid(True))
     if message:
         es.tell(userid,'#multi',lmv['lang'](message,tokens,player.lang))
     elif popuplib.isqueued('Vote on GamePlay_%s'%userid,userid) or popuplib.isqueued('Vote on Map_%s'%userid,userid): return
     else:
         if lmv_randomize_votes:
             options = list(self.options)
             random.shuffle(options)
             self.options = set(options)
         popupname = 'Vote on GamePlay' if self.vote_status == 1 else 'Vote on Map'
         uservotemenu = popuplib.easymenu('%s_%s'%(popupname,userid),'choice',self.getPlayerVote)
         uservotemenu.settitle(lmv['lang'](popupname,lang=player.lang))
         for option in self.options:
             uservotemenu.addoption(option,lmv['lang'](option,lang=player.lang) if self.vote_status == 1 else option)
         uservotemenu.send(userid)
Example #45
0
def unload():
    # Remove gungame from sv_tags
    tags = set(str(sv_tags).split(','))
    tags.discard('gungame')
    sv_tags.set(','.join(tags))

    # Remove the public variables
    eventscripts_gg.removeFlag('notify')
    eventscripts_gg.removeFlag('replicated')
    eventscripts_gg5.removeFlag('notify')
    eventscripts_gg5.removeFlag('replicated')

    # Unregister server_cvar for core.weapons
    WeaponOrderManager().unregister()

    # Unregister events
    unload_events()

    # Unload Menus
    MenuManager().unload_menus()

    # Unload all sub-addons
    AddonManager().unload_all_addons()

    # Unload translations
    unload_translation('gungame', 'gungame')

    # Remove all player instances
    _PlayerContainer().clear()

    # Close the database
    Database().close()

    # Unload configs (removes flags from CVARs)
    unload_configs()

    # Enable Buyzones
    es.server.queuecmd('es_xfire %s func_buyzone Enable' % es.getuserid())

    # Fire gg_unload event
    GG_Unload().fire()

    # Unregister !thanks command
    unregisterSayCommand('!thanks')
Example #46
0
def unload():
    # Remove gungame from sv_tags
    tags = set(str(sv_tags).split(','))
    tags.discard('gungame')
    sv_tags.set(','.join(tags))

    # Remove the public variables
    eventscripts_gg.removeFlag('notify')
    eventscripts_gg.removeFlag('replicated')
    eventscripts_gg5.removeFlag('notify')
    eventscripts_gg5.removeFlag('replicated')

    # Unregister server_cvar for core.weapons
    WeaponOrderManager().unregister()

    # Unregister events
    unload_events()

    # Unload Menus
    MenuManager().unload_menus()

    # Unload all sub-addons
    AddonManager().unload_all_addons()

    # Unload translations
    unload_translation('gungame', 'gungame')

    # Remove all player instances
    _PlayerContainer().clear()

    # Close the database
    Database().close()

    # Unload configs (removes flags from CVARs)
    unload_configs()

    # Enable Buyzones
    es.server.queuecmd('es_xfire %s func_buyzone Enable' % es.getuserid())

    # Fire gg_unload event
    GG_Unload().fire()

    # Unregister !thanks command
    unregisterSayCommand('!thanks')
Example #47
0
def getPlayerList(players):
    """Returns a set of RestrictedPlayer or RestrictedTeam instances based on userid or team tag"""
    if isinstance(players, str):
        if players.startswith("@"):
            if players[1:] == "all":
                players = (getTeam(2), getTeam(3))
            elif acceptable_teams.has_key(players[1:]):
                players = (getTeam(acceptable_teams[players[1:]]),)
            else:
                # bugfix: echo to users console (useful message)
                usermsg.echo("#all", 'xarestrict error: invalid tag "%s" [command accepts @all, @ct, @t]' % players)
                raise ValueError, 'Invalid team tag "%s"' % players

        elif players.startswith("#"):
            if players[1:] == "all":
                players = es.getUseridList()
            elif acceptable_teams.has_key(players[1:]):
                team = acceptable_teams[players[1:]]
                players = filter(lambda x: es.getplayerteam(x) == team, es.getUseridList())
            else:
                # bugfix: echo to users console (useful message)
                usermsg.echo("#all", 'xarestrict error: invalid tag "%s" [command accepts #all, #ct, #t]' % players)
                raise ValueError, 'Invalid team tag "%s"' % players

            players = map(getPlayer, players)

        else:
            userid = es.getuserid(players)
            if not userid:
                # bugfix: echo to users console (useful message)
                usermsg.echo(
                    "#all",
                    'xarestrict error: invalid player "%s" [command accepts partial username, userid or steamid]'
                    % players,
                )
                raise ValueError, 'Invalid player "%s"' % players

            players = (getPlayer(userid),)

    elif isinstance(players, (int, float)):
        players = (getPlayer(players),)

    return players
Example #48
0
 def addLevels(self, userid, choice, popupid):
     """
     This method adds a cetain amount of levels to a player by a given
     steamid. If the player is currently online then add the levels by
     the sourcerpg player object; otherwise query the database and update
     it via that.
     
     @PARAM userid - the admin who gave the levels
     @PARAM choice - the amount of levels to give
     @PARAM popupid - the id of the popup which was used to give the player levels
     """
     target = popupid.replace("sourcerpg_addlevel_player", "")
     tokens = {}
     tokens['amount'] = str(choice)
     if isinstance(choice, str):
         if choice.isdigit():
             choice = int(choice)
     if isinstance(choice, int):
         if popup.isOnline(target):
             player = es.getuserid(target)
             sourcerpg.players[player].addLevel(choice)
             tokens['name'] = sourcerpg.players[player]['name']
             if userid is not None:
                 self.chosenPlayer(userid, target,
                                   "sourcerpg_onlineplayers")
         else:
             query = "UPDATE Player SET level=level+?, credits=credits+? WHERE steamid=?"
             sourcerpg.database.execute(
                 query, choice, (choice * sourcerpg.creditsReceived),
                 target)
             query = "SELECT name FROM Player WHERE steamid=?"
             sourcerpg.database.execute(query, target)
             name = sourcerpg.database.fetchone()
             tokens['name'] = name
             if userid is not None:
                 self.chosenPlayer(userid, target,
                                   "sourcerpg_offlineplayers")
         if userid is not None:
             tell(userid, 'add levels', tokens)
     else:
         tell(userid, 'escape')
         es.escinputbox(30, userid, '=== %s Add Xp ===' % sourcerpg.prefix,
                        'Enter the amount', 'rpgaddlevels %s' % target)
Example #49
0
def equip_player():
    userid = es.getuserid()
    cmd = ('es_xremove game_player_equip;' +
           'es_xgive %s game_player_equip;' % userid +
           'es_xfire %s game_player_equip ' % userid +
           'AddOutput "weapon_knife 1";')

    # Retrieve the armor type
    armor_type = int(gg_player_armor)

    # Give the player full armor
    if armor_type == 2:
        cmd += ('es_xfire %s ' % userid +
                'game_player_equip AddOutput "item_assaultsuit 1";')

    # Give the player kevlar only
    elif armor_type == 1:
        cmd += ('es_xfire %s ' % userid +
                'game_player_equip AddOutput "item_kevlar 1";')

    es.server.queuecmd(cmd)
Example #50
0
def preHook(args):
    userid = es.getuserid(str(args[4]))
    steamid = es.getplayersteamid(userid)
    name = es.getplayername(userid)
    # Name args[4]
    message = args[3]
    method = chat.getHook()
    if hasattr(method, '__call__'):
        if args[3] in [
                "Cstrike_Chat_Spec", "Cstrike_Chat_CT", "Cstrike_Chat_T"
        ]:
            message = chat.call_hook(userid, steamid, name, args[5], True)
        else:
            message = chat.call_hook(userid, steamid, name, args[5], False)

    args[3] = '\x01' + format(message)
    args[4] = ''
    args[5] = ''
    args[6] = ''
    args[7] = ''
    return (HookAction.Modified, 0)
Example #51
0
def equip_player():
    userid = es.getuserid()
    cmd = ('es_xremove game_player_equip;' +
          'es_xgive %s game_player_equip;' % userid +
          'es_xfire %s game_player_equip ' % userid +
          'AddOutput "weapon_knife 1";')

    # Retrieve the armor type
    armor_type = int(gg_player_armor)

    # Give the player full armor
    if armor_type == 2:
        cmd += ('es_xfire %s ' % userid +
            'game_player_equip AddOutput "item_assaultsuit 1";')

    # Give the player kevlar only
    elif armor_type == 1:
        cmd += ('es_xfire %s ' % userid +
            'game_player_equip AddOutput "item_kevlar 1";')

    es.server.queuecmd(cmd)
Example #52
0
    def remove(self, item):
        '''Removes a list of userids from the respawn list
            and spawns the players if necessary'''

        # Create a list to store names of players being respawned
        players = list()

        # Loop through all userids in the current list
        for userid in item:

            # Does the current userid exist on the server?
            if not exists('userid', userid):

                # If not, do not respawn them
                continue

            # Is the player still on a team?
            if getplayerteam(userid) < 2:

                # If not, do not respawn them
                continue

            # Respawn the player
            Player(userid).respawn()

            # Add the player's name to the list of names
            players.append(getplayername(userid))

        # Are any players being respawned?
        if players:

            # Get the first player's index
            index = Player(getuserid(players[0])).index

            # Send a message about all the players being respawned
            saytext2('#human', index, 'RespawningPlayer',
                {'player': '\x01, \x03'.join(players)}, True)

        # Remove the list from the respawn list
        super(_RespawnPlayers, self).remove(item)
Example #53
0
    def remove(self, item):
        '''Removes a list of userids from the respawn list
            and spawns the players if necessary'''

        # Create a list to store names of players being respawned
        players = list()

        # Loop through all userids in the current list
        for userid in item:

            # Does the current userid exist on the server?
            if not exists('userid', userid):

                # If not, do not respawn them
                continue

            # Is the player still on a team?
            if getplayerteam(userid) < 2:

                # If not, do not respawn them
                continue

            # Respawn the player
            Player(userid).respawn()

            # Add the player's name to the list of names
            players.append(getplayername(userid))

        # Are any players being respawned?
        if players:

            # Get the first player's index
            index = Player(getuserid(players[0])).index

            # Send a message about all the players being respawned
            saytext2('#human', index, 'RespawningPlayer',
                     {'player': '\x01, \x03'.join(players)}, True)

        # Remove the list from the respawn list
        super(_RespawnPlayers, self).remove(item)
Example #54
0
 def addLevels(self, userid, choice, popupid):
     """
     This method adds a cetain amount of levels to a player by a given
     steamid. If the player is currently online then add the levels by
     the sourcerpg player object; otherwise query the database and update
     it via that.
     
     @PARAM userid - the admin who gave the levels
     @PARAM choice - the amount of levels to give
     @PARAM popupid - the id of the popup which was used to give the player levels
     """
     target = popupid.replace("sourcerpg_addlevel_player", "")
     tokens = {}
     tokens['amount'] = str(choice)
     if isinstance(choice, str):
         if choice.isdigit():
             choice = int(choice)
     if isinstance(choice, int):
         if popup.isOnline(target):
             player = es.getuserid(target)
             sourcerpg.players[player].addLevel(choice)
             tokens['name'] = sourcerpg.players[player]['name']
             if userid is not None:
                 self.chosenPlayer(userid, target, "sourcerpg_onlineplayers")
         else:
             query = "UPDATE Player SET level=level+?, credits=credits+? WHERE steamid=?"
             sourcerpg.database.execute(query, choice, (choice * sourcerpg.creditsReceived), target)
             query = "SELECT name FROM Player WHERE steamid=?"
             sourcerpg.database.execute(query, target)
             name = sourcerpg.database.fetchone()
             tokens['name'] = name
             if userid is not None:
                 self.chosenPlayer(userid, target, "sourcerpg_offlineplayers")
         if userid is not None:
             tell(userid, 'add levels', tokens)
     else:
         tell(userid, 'escape')
         es.escinputbox(30, userid, '=== %s Add Xp ===' % sourcerpg.prefix,
             'Enter the amount' , 'rpgaddlevels %s' % target)
Example #55
0
def setentname_cmd(args):
    if gamename in ['cstrike', 'dod', 'hl2mp']:
        userid = es.getuserid()
        if userid:
            if len(args) > 1:
                entity = args[0]
                entityname = args[1]
                if entity.isdigit() and entityname:
                    player = playerlib.getPlayer(userid)
                    playerlocation = vecmath.vector(player.getLocation())
                    playermovetype = es.getplayerprop(int(player), 'CBaseEntity.movetype')
                    if gamename == 'cstrike':
                        playerviewangles = vecmath.vector((float(es.getplayerprop(int(player), 'CCSPlayer.m_angEyeAngles[0]')), float(es.getplayerprop(int(player), 'CCSPlayer.m_angEyeAngles[1]')), 0.0))
                        playerviewoffset = vecmath.vector((float(es.getplayerprop(int(player), 'CBasePlayer.localdata.m_vecViewOffset[0]')), float(es.getplayerprop(int(player), 'CBasePlayer.localdata.m_vecViewOffset[1]')), float(es.getplayerprop(int(player), 'CBasePlayer.localdata.m_vecViewOffset[2]'))))
                    elif gamename == 'dod':
                        playerviewangles = vecmath.vector((float(es.getplayerprop(int(player), 'CDODPlayer.m_angEyeAngles[0]')), float(es.getplayerprop(int(player), 'CDODPlayer.m_angEyeAngles[1]')), 0.0))
                        playerviewoffset = vecmath.vector((float(es.getplayerprop(int(player), 'CBasePlayer.localdata.m_vecViewOffset[0]')), float(es.getplayerprop(int(player), 'CBasePlayer.localdata.m_vecViewOffset[1]')), float(es.getplayerprop(int(player), 'CBasePlayer.localdata.m_vecViewOffset[2]'))))
                    elif gamename == 'hl2mp':
                        playerviewangles = vecmath.vector((float(es.getplayerprop(int(player), 'CHL2MP_Player.m_angEyeAngles[0]')), float(es.getplayerprop(int(player), 'CHL2MP_Player.m_angEyeAngles[1]')), 0.0))
                        playerviewoffset = vecmath.vector((float(es.getplayerprop(int(player), 'CHL2MP_Player.baseclass.baseclass.baseclass.baseclass.m_vecViewOffset[0]')), float(es.getplayerprop(int(player), 'CHL2MP_Player.baseclass.baseclass.baseclass.baseclass.m_vecViewOffset[1]')), float(es.getplayerprop(int(player), 'CHL2MP_Player.baseclass.baseclass.baseclass.baseclass.m_vecViewOffset[2]'))))
                    playerviewvector = (vecmath.vector(vecmath.angles((1.0,1.0,1.0), playerviewangles))) * 0.5
                    entitylocation = vecmath.vector(es.getindexprop(entity, 'CBaseEntity.m_vecOrigin'))
                    entityviewvector = (playerlocation - (playerviewoffset + playerviewvector)) + entitylocation
                    player.freeze(1)
                    player.setLocation(list(entityviewvector))
                    player.viewCoord(list(entitylocation))
                    es.entsetname(int(player), entityname)
                    es.server.cmd('es_xsetang %s %s %s' % (int(player), playerviewangles[0], playerviewangles[1]))
                    es.setplayerprop(int(player), 'CBaseEntity.movetype', playermovetype)
                    player.setLocation(list(playerlocation))
                else:
                    es.dbgmsg(0, 'setentname: Invalid target user "%s" to setentname.' % target)
            else:
                es.dbgmsg(0, 'setentname: Not enough arguments to setentname. Syntax: setentname <entity-index#> <desired-name>')
        else:
            es.dbgmsg(0, 'setentname: No userid available. Sorry, no targetname set!')
    else:
        es.dbgmsg(0, 'setentname: Game "%s" is not supported. Sorry, no targetname set!' % gamename)
Example #56
0
def _adminlist_select(userid,choice,popupid):
    es.dbgmsg(1,'*****_adminlist_select')
    global admindetail
    es.set('_pdetails', 0)
    admindetail.modlineAll(3, choice[1][0])
    admindetail.modlineAll(4, choice[0])
    id = int(es.getuserid(choice[0]))
    if id:
        admindetail.modlineAll(5, 'Userid: %d' %id)
    else:
        admindetail.modlineAll(5, 'Userid: Not active')
    if not int(choice[1][2]):
        admindetail.modlineAll(6, lang['status good'])
    else:
        admindetail.modlineAll(6, lang['status suspended'])
    if int(choice[1][1]): 
        admindetail.modlineAll(7, lang['master'])
    else:
        admindetail.modlineAll(7, lang['normal'])
    admindetail.menuvalue('_pdetails',1,choice[0])
    admindetail.menuvalue('_pdetails',2,choice[0])
    admindetail.menuvalue('_pdetails',3,choice[0])
    admindetail.send(userid)
Example #57
0
def blind_con_com():
    '''
    Allows admins to blind via a console command
    '''
    if es.getargc() > 1:
        id = es.getuserid(es.getargv(1))
        admin = playerlib.getPlayer(es.getcmduserid())
        if id > 0:
            target = playerlib.getPlayer(id)
            if ghosting.setting.getVariable('blind_ghosters') == "0":
                # can only use this if auto blinding is OFF
                if checkplayer(int(target)):
                    es.msg("#green %s blinded %s till the end of the round for ghosting" % (admin.attributes["name"], target.attributes["name"]))
                    ghosting.logging.log("Admin (%s) blinded player %s for ghosting " % (admin.attributes["name"], target.attributes["name"]))
                    blindplayer(str(target))
                else:
                    es.tell(int(admin), "#green %s was not IP ghosting" % (target.attributes["name"]))
            else:
                es.tell(int(admin), "#green XA will blind %s automatically if they are IP ghosting" % (target.attributes["name"]))
        else:
            es.tell(int(admin), "#green Player %s could not be found" % (str(es.getargv(1))))
    else:
        es.dbgmsg(0, "Syntax: xa_blind_ghoster <steamid|userid> - blinds ghosting players till the end of the round")
Example #58
0
def choosePlayer():         
    '''
    Used by chooseKick() to determine a player to kick
    '''
    kicklist = playerlib.getPlayerList("#res")
    kickuid  = playerlib.getPlayer(es.getuserid()) # get a random player to return if none of the others return anything.
    if int(xareserveslots.setting.getVariable("reserve_slots_kick_method")) == 1:
        timelowest = None
        for id in kicklist:
            time = id.attributes["timeconnected"]   
            if timelowest is None or time < timelowest:
                timelowest = time
                kickuid = id
        return kickuid
    else:
        ping = -1
        for id in kicklist:
            pping = id.attributes["ping"]
            if pping > ping:
                ping = pping
                kickuid = id
        return kickuid
    return kickuid