Beispiel #1
0
    def send_all_players_a_message(self, message, tokens):
        '''Sends all players on the server a message'''

        # Store a team members index
        index = self.index

        # Is there an index?
        if index is None:

            # If not, don't send any messages
            return

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

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

                # If so, don't send a message
                continue

            # Get the team's name
            teamname = langstring(self.teamname, userid=userid)

            # Update the tokens with the teamname
            tokens.update({'teamname': teamname})

            # Send the message to the player
            Player(userid).saytext2(index, message, tokens, True)
Beispiel #2
0
    def check_final_kill(self, userid, weapon):
        '''Checks to see if the kill should end the match'''

        # Is the team on the last level?
        if self.level != get_total_levels():

            # If not, return
            return

        # Is the team on the last multikill for the last level?
        if self.multikill + 1 < get_level_multikill(self.level):

            # If not, return
            return

        # Was the weapon used the last level's weapon?
        if get_level_weapon(self.level) != weapon:

            # If not, return
            return

        # Get the Player instance
        ggPlayer = Player(userid)

        # Is the attacker on the last level?
        if ggPlayer.level != get_total_levels():

            # If not, return
            return

        # End the match
        GG_Team_Win(winner=self.team, loser=5 - self.team).fire()
Beispiel #3
0
    def set_player_level(self, userid):
        '''Sets the player's level to the team's level'''

        # Get the Player instance
        ggPlayer = Player(userid)

        # Is the player prevented from leveling?
        if info.name in ggPlayer.preventlevel.levelup:

            # Remove the prevention
            ggPlayer.preventlevel.levelup.remove(info.name)

        # Set the player's level to the team's level
        ggPlayer.level = self.level

        # Add the addon to the player's levelup preventlevel
        ggPlayer.preventlevel.levelup.append(info.name)
Beispiel #4
0
    def set_all_player_levels(self):
        '''Sets all players on the team to the highest level'''

        # Loop through all players on the team
        for userid in self.team_players:

            # Get the Player instance
            ggPlayer = Player(userid)

            # Does this player need to level up?
            if ggPlayer.level != self.level:

                # Level the player up to the highest level
                Player(userid).level = self.level

                # Set the player's multikill to 0
                ggPlayer.multikill = 0
Beispiel #5
0
    def set_player_level(self, userid):
        '''Sets the player's level to the team's level'''

        # Get the Player instance
        ggPlayer = Player(userid)

        # Is the player prevented from leveling?
        if info.name in ggPlayer.preventlevel.levelup:

            # Remove the prevention
            ggPlayer.preventlevel.levelup.remove(info.name)

        # Set the player's level to the team's level
        ggPlayer.level = self.level

        # Add the addon to the player's levelup preventlevel
        ggPlayer.preventlevel.levelup.append(info.name)
Beispiel #6
0
    def send_winner_messages(self):
        '''Sends Winner Messages to all players'''

        # Store a team player's index
        index = self.index

        # Is there an index?
        if index is None:

            # If not, return
            return

        # Store the team's color
        color = self.color

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

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

                # Do not send messages to bots
                continue

            # Get the player's Player() instance
            ggPlayer = Player(userid)

            # Get the team's name
            teamname = langstring(self.teamname, userid=userid)

            # Send chat message for team winning the match
            ggPlayer.saytext2(
                index, 'TeamWork_Winner', {'teamname': teamname}, True)

            # We want to loop, so we send a message every second for 3 seconds
            for x in xrange(4):

                # Send centermsg about the winner
                delayed(x, ggPlayer.centermsg,
                    ('TeamWork_Winner_Center', {'teamname': teamname}))

            # Send toptext message about the winner
            ggPlayer.toptext(10, color,
                'TeamWork_Winner_Center', {'teamname': teamname})
Beispiel #7
0
def stop_multi_levelers():
    # For all players
    for userid in es.getUseridList():
        ggPlayer = Player(userid)

        # Make sure their multiLevels are reset
        ggPlayer.multiLevels = 0

        if userid in currentMultiLevel:
            # Cancel the gamethread
            gamethread.cancelDelayed("%i_multilevel" % userid)

            # Remove bonus effects
            remove_multi_level(userid)

        ggPlayer.multiLevelEntities = []

    # Clear the list of players currently multi-leveling
    currentMultiLevel.clear()
Beispiel #8
0
def gg_levelup(event_var):
    # Get event information
    userid = int(event_var['userid'])
    attacker = int(event_var['attacker'])

    # Was it a suicide?
    if userid == attacker:
        return

    # Did the player fall to their death?
    if not attacker:
        return

    # Teamkill?
    if event_var['es_userteam'] == event_var['es_attackerteam']:
        return

    # Increment multi-kills for attacker
    ggPlayer = Player(attacker)
    ggPlayer.multiLevels += 1

    # Is it greater than or equal to our threshold?
    if ggPlayer.multiLevels >= int(gg_multi_level):

        # If they currently have the bonus
        if attacker in currentMultiLevel:

            # Cancel the gamethread
            gamethread.cancelDelayed("%i_multilevel" % attacker)

            # Remove the bonus
            remove_multi_level(attacker)

        # Multi-Level them
        do_multi_level(attacker)

        # Reset their kills
        ggPlayer.multiLevels = 0

        # Remove multilevel in 10
        gamethread.delayedname(10, "%i_multilevel" % attacker,
                               remove_multi_level, attacker)
Beispiel #9
0
    def set_player_level(self, userid):
        '''Sets a player that just joined the team's level'''

        # Get the player's Player() instance
        ggPlayer = Player(userid)

        # Does the player get set to level 1?
        if not int(gg_teamwork_jointeam_level):

            # Set the player to level 1
            ggPlayer.level = 1

        # Does the player need set to the teams start level for this round?
        else:

            # Set the player to the team's level
            ggPlayer.level = self.level

        # Either way, reset the player's multikill value
        ggPlayer.multikill = 0
Beispiel #10
0
    def send_winner_messages(self):
        '''Sends Winner Messages to all players'''

        # Store a team player's index
        index = self.index

        # Store the team's color
        color = self.color

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

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

                # Do not send messages to bots
                continue

            # Get the player's Player() instance
            ggPlayer = Player(userid)

            # Get the team's name
            teamname = langstring(self.teamname, userid=userid)

            # Send chat message for team winning the match
            ggPlayer.saytext2(index, 'TeamPlay_Winner', {'teamname': teamname},
                              True)

            # We want to loop, so we send a message every second for 3 seconds
            for x in xrange(4):

                # Send centermsg about the winner
                delayed(x, ggPlayer.centermsg, ('TeamPlay_Winner_Center', {
                    'teamname': teamname
                }))

            # Send toptext message about the winner
            ggPlayer.toptext(10, color, 'TeamPlay_Winner_Center',
                             {'teamname': teamname})
Beispiel #11
0
def player_activate(event_var):
    ggPlayer = Player(event_var['userid'])

    # Add the player's multikill attribute
    ggPlayer.multiLevels = 0
    ggPlayer.multiLevelEntities = []
Beispiel #12
0
def remove_callbacks_for_addon(addon):
    Player.remove_callbacks_for_addon(addon)
Beispiel #13
0
def remove_attribute_callback(attribute):
    Player.remove_attribute_callback(attribute)
Beispiel #14
0
def add_attribute_callback(attribute, function, addon):
    Player.add_attribute_callback(attribute, function, addon)