Ejemplo n.º 1
0
def hegrenade_detonate(event_var):
    # Get the userid as int
    userid = int(event_var['userid'])

    # If the player is not on an active team, return
    if int(event_var['es_userteam']) < 2:
        return

    # If the player is not on hegrenade level, return
    if Player(userid).weapon != 'hegrenade':
        return

    # If the player is dead, return
    if getPlayer(userid).isdead:
        return

    # If there is a limit to the number of nades a player can get...
    if int(gg_multi_nade_max_nades) > 0:

        # Don't keep counting if the player has already hit the max
        if Player(userid).grenades_detonated < int(gg_multi_nade_max_nades):
            # Increment the player's grenades_detonated count
            Player(userid).grenades_detonated += 1

        # Find out if they exceeded the limit and break out if so
        if Player(userid).grenades_detonated >= int(gg_multi_nade_max_nades):
            return

    # Give the player a new hegrenade
    spe.giveNamedItem(userid, "weapon_hegrenade")
Ejemplo n.º 2
0
def gg_leveldown(event_var):
    userid = int(event_var['userid'])

    # Player leveled down to nade ?
    if not check_bonus(userid):
        return

    # Using weapon list ?
    if not using_weapon_list():
        return

    oldlevel = int(event_var['old_level'])

    # Was Player on nade ?
    if get_level_weapon(oldlevel) == 'hegrenade':

        # Reset bonus levels
        Player(userid).nadeBonusMulti = 0
        Player(userid).nadeBonusLevel = 1

    # Giving bonus (delayed more for bots)
    if es.isbot(userid):
        gamethread.delayed(0.50, give_bonus, userid)
        return

    gamethread.delayed(0.10, give_bonus, userid)
Ejemplo n.º 3
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))
def player_death(event_var):
    # Find the number of hostages following the victim
    handle = es.getplayerhandle(event_var['userid'])
    hostages = len(filter(lambda index: es.getindexprop(index,
        'CHostage.m_leader') == handle, es.getEntityIndexes('hostage_entity')))

    # Were any hostages following?
    if not hostages:
        return

    # Was suicide?
    attacker = int(event_var['attacker'])
    if not attacker:
        return

    # Was a team kill?
    if event_var['es_userteam'] == event_var['es_attackerteam']:
        return

    # Get the attacker instance
    ggPlayer = Player(attacker)

    # Increment player hostage stops
    ggPlayer.hostage_stopped += hostages

    # Enough hostages stopped to level player up?
    if ggPlayer.hostage_stopped >= int(gg_hostage_stopped_stops):

        # Decrease the hostage stopped counter
        ggPlayer.hostage_stopped -= int(gg_hostage_stopped_stops)

        # The number of levels we will level up the player
        levels = 1

        # If they shouldn't be skipping their current level, stop here
        if (not int(gg_hostage_stopped_skip_nade)
          and ggPlayer.weapon == 'hegrenade') or (
          not int(gg_hostage_stopped_skip_knife)
          and ggPlayer.weapon == 'knife'):
            msg(ggPlayer.userid, 'CannotSkipLevel_ByStopping',
                {'level': ggPlayer.weapon})
            return

        # Loop through weapons of the levels we plan to level the player past
        for weapon in getLevelupList(ggPlayer.level,
          ggPlayer.level + int(gg_hostage_stopped_levels)):
            # If gg_hostage_stopped_skip_knife or gg_hostage_stopped_skip_nade
            # are disabled, make sure the player will not skip that level
            if (not int(gg_hostage_stopped_skip_knife)
              and weapon == 'knife') or (
              not int(gg_hostage_stopped_skip_nade)
              and weapon == 'hegrenade'):
                msg(ggPlayer.userid, 'CannotSkipLevel_ByStopping',
                    {'level': weapon})
                break

            # Add to the number of levels they will gain
            levels += 1

        ggPlayer.levelup(levels, 0, 'hostage_stopped')
Ejemplo n.º 5
0
def level_down_victim(attacker, victim):
    ggAttacker = Player(attacker)
    ggVictim = Player(victim)

    # Can the victim level down ?
    if ggVictim.level == 1:
        return False

    # Send message to attacker if victim cannot level down?
    if ggVictim.preventlevel.leveldown:

        # Always level mode (do not bother the attacker)?
        if not int(gg_knife_pro_always_level):
            msg(attacker, 'VictimPreventLevel', prefix=True)

            # The steal event didn't get fired
            return False

    # Player can level down
    else:
        # Play sound & send message
        ggVictim.playsound('leveldown')
        ggVictim.leveldown(1, attacker, 'steal')

    fire_gg_knife_steal(attacker, victim)

    # The steal event got fired
    return True
Ejemplo n.º 6
0
def startProtect(userid):
    # Retrieve player objects
    pPlayer = getPlayer(userid)

    # Add them to the list of protected players
    protectedList.append(userid)

    # Set color
    pPlayer.color = (gg_spawn_protect_red,
                     gg_spawn_protect_green,
                     gg_spawn_protect_blue,
                     gg_spawn_protect_alpha)

    # Start Invincible
    pPlayer.godmode = 1

    # Set PreventLevel if needed
    if not int(gg_spawn_protect_can_level_up):
        ggPlayer = Player(userid)

        if not 'gg_spawn_protect' in ggPlayer.preventlevel():
            ggPlayer.preventlevel.append('gg_spawn_protect')

    # Start the delay to cancel spawn protection
    gamethread.delayedname(int(gg_spawn_protect),
        'ggSpawnProtect%s' % userid, endProtect, (userid))
Ejemplo n.º 7
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')
Ejemplo n.º 8
0
    def __init__(self, userid):
        '''Called when the class is first initialized'''

        # Store the player's base attributes
        self.userid = userid
        self.gg_player = Player(self.userid)
        self.isbot = isbot(self.userid)
Ejemplo n.º 9
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')
Ejemplo n.º 10
0
def player_death(event_var):
    attacker = int(event_var['attacker'])

    # Checking if player needs a new nade bonus
    if not check_bonus(attacker):
        return

    # We using a weapon list ?
    if not using_weapon_list():
        return

    weapon = get_weapon(attacker)

    # Was the kill with the bonus gun ?
    if event_var['weapon'] != weapon[0]:
        return

    ggPlayer = Player(attacker)

    # Stop Player at last level ?
    if int(gg_nade_bonus_mode) == 0:

        # Player on last level ?
        if get_total_levels(str(gg_nade_bonus)) == ggPlayer.nadeBonusLevel:
            return

    # Multikil check
    multiKill = get_level_multikill(ggPlayer.nadeBonusLevel,
                                    str(gg_nade_bonus))

    # Checking for multikill level
    if multiKill > 1:

        # Adding kill
        ggPlayer.nadeBonusMulti += 1

        # Level up ?
        if ggPlayer.nadeBonusMulti >= multiKill:

            # Reset multikill count
            ggPlayer.nadeBonusMulti = 0

            # Level up
            ggPlayer.nadeBonusLevel += 1

            # Give new weapon
            give_bonus(attacker, True, True)

        else:
            # Play sound
            ggPlayer.playsound('multikill')

    else:
        # Level up
        ggPlayer.nadeBonusLevel += 1

        # Give new weapon
        give_bonus(attacker, True, True)
Ejemplo n.º 11
0
def player_death(event_var):
    attacker = int(event_var['attacker'])

    # Checking if player needs a new nade bonus
    if not check_bonus(attacker):
        return

    # We using a weapon list ?
    if not using_weapon_list():
        return

    weapon = get_weapon(attacker)

    # Was the kill with the bonus gun ?
    if event_var['weapon'] != weapon[0]:
        return

    ggPlayer = Player(attacker)

    # Stop Player at last level ?
    if int(gg_nade_bonus_mode) == 0:

        # Player on last level ?
        if get_total_levels(str(gg_nade_bonus)) == ggPlayer.nadeBonusLevel:
            return

    # Multikil check
    multiKill = get_level_multikill(ggPlayer.nadeBonusLevel,
                                            str(gg_nade_bonus))

    # Checking for multikill level
    if multiKill > 1:

        # Adding kill
        ggPlayer.nadeBonusMulti += 1

        # Level up ?
        if ggPlayer.nadeBonusMulti >= multiKill:

            # Reset multikill count
            ggPlayer.nadeBonusMulti = 0

            # Level up
            ggPlayer.nadeBonusLevel += 1

            # Give new weapon
            give_bonus(attacker, True, True)

        else:
            # Play sound
            ggPlayer.playsound('multikill')

    else:
        # Level up
        ggPlayer.nadeBonusLevel += 1

        # Give new weapon
        give_bonus(attacker, True, True)
Ejemplo n.º 12
0
def hostage_killed(event_var):
    # Was fall damage?
    attacker = int(event_var['userid'])
    if not attacker:
        return

    # Get the attacker instance
    ggPlayer = Player(attacker)

    # Increment player hostage kills
    ggPlayer.hostage_killed += 1

    # Enough hostages killed to punish?
    if ggPlayer.hostage_killed >= int(gg_hostage_killed_kills):

        # Reset hostage killed counter
        ggPlayer.hostage_killed = 0

        # Punish the player
        ggPlayer.leveldown(int(gg_hostage_killed_punish), 0, 'hostage_killed')

        # Message
        ggPlayer.msg('Hostage_Killed_LevelDown', {'newlevel': ggPlayer.level},
                     prefix='gg_hostage_killed_punish')

        # Play the leveldown sound
        ggPlayer.playsound('leveldown')
Ejemplo n.º 13
0
def player_death(event_var):
    # Has the round ended?
    if not ActiveInfo.round:
        return

    # Set player ids
    userid = int(event_var['userid'])
    attacker = int(event_var['attacker'])

    # Is the attacker on the server?
    if not es.exists('userid', attacker):
        return

    # Suicide check
    if (attacker == 0 or attacker == userid):
        return

    # Get attacker object
    ggAttacker = Player(attacker)

    # ===============
    # TEAM-KILL CHECK
    # ===============
    if (event_var['es_userteam'] == event_var['es_attackerteam']):
        # Trigger level down
        ggAttacker.leveldown(int(gg_tk_punish), userid, 'tk')

        # Message
        ggAttacker.msg('TeamKill_LevelDown', {'newlevel': ggAttacker.level},
                       prefix='gg_tk_punish')

        # Play the leveldown sound
        ggAttacker.playsound('leveldown')
Ejemplo n.º 14
0
def hostage_killed(event_var):
    # Was fall damage?
    attacker = int(event_var['userid'])
    if not attacker:
        return

    # Get the attacker instance
    ggPlayer = Player(attacker)

    # Increment player hostage kills
    ggPlayer.hostage_killed += 1

    # Enough hostages killed to punish?
    if ggPlayer.hostage_killed >= int(gg_hostage_killed_kills):

        # Reset hostage killed counter
        ggPlayer.hostage_killed = 0

        # Punish the player
        ggPlayer.leveldown(int(gg_hostage_killed_punish), 0, 'hostage_killed')

        # Message
        ggPlayer.msg('Hostage_Killed_LevelDown', {'newlevel': ggPlayer.level},
                        prefix='gg_hostage_killed_punish')

        # Play the leveldown sound
        ggPlayer.playsound('leveldown')
Ejemplo n.º 15
0
def bomb_defused(event_var):
    # Get the player instance
    ggPlayer = Player(event_var['userid'])

    # The number of levels we will level up the player
    levels = 1

    # If they shouldn't be skipping their current level, stop here
    if ((not int(gg_bomb_defused_skip_nade) and ggPlayer.weapon == 'hegrenade')
            or
        (not int(gg_bomb_defused_skip_knife) and ggPlayer.weapon == 'knife')):
        ggPlayer.msg('CannotSkipLevel_ByDefusing', {'level': ggPlayer.weapon})
        return

    # Loop through weapons of the levels we plan to level the player up past
    for weapon in getLevelupList(ggPlayer.level,
                                 ggPlayer.level + int(gg_bomb_defused_levels)):
        # If gg_bomb_defused_skip_knife or gg_bomb_defused_skip_nade are
        # disabled, make sure the player will not skip that level
        if ((not int(gg_bomb_defused_skip_knife) and weapon == 'knife') or
            (not int(gg_bomb_defused_skip_nade) and weapon == 'hegrenade')):
            ggPlayer.msg('CannotSkipLevel_ByDefusing', {'level': weapon})
            break

        # Add to the number of levels they will gain
        levels += 1

    # Level up the player
    ggPlayer.levelup(levels, 0, 'bomb_defused')
Ejemplo n.º 16
0
def item_pickup(event_var):
    # Get variables
    item = event_var['item']
    userid = int(event_var['userid'])

    # Is a weapon?
    if ("weapon_%s" % item) not in list_weaponNameList:
        return

    # Client exists?
    if not es.exists('userid', userid) and userid != 0:
        return

    # Don't strip the knife
    if item == "knife":
        return

    # Don't strip the c4 if bomb objectives are allowed
    if item == "c4" and not int(es.ServerVar("gg_map_obj")) in [1, 2]:
        return

    # Check to see if the weapon is in the player's strip exceptions
    if item in Player(userid).stripexceptions + ['flashbang', 'smokegrenade']:
        # Make sure this weapon can't be picked up
        set_spawn_flags(userid, item, 2)
        return

    # Get the player's GunGame weapon
    currentWeapon = Player(userid).weapon

    # Check to see if the weapon is their gungame weapon
    if item == currentWeapon:
        # Make sure this weapon can't be picked up
        set_spawn_flags(userid, item, 2)
        return

    # Remove player's weapon
    remove_weapon(userid, item)

    # Check if player is on nade level
    if currentWeapon == 'hegrenade':

        # Switch the player knife ?
        if not getPlayer(userid).he:
            es.server.queuecmd('es_xsexec %s "use weapon_knife"' % userid)
            return

    # Switch to their gungame weapon
    es.server.queuecmd('es_xsexec %s "use weapon_%s"' %
                       (userid, currentWeapon))
Ejemplo n.º 17
0
def gg_levelup(event_var):
    # Check for priority addons
    if PriorityAddon:
        return

    # Set player ids
    attacker = int(event_var['attacker'])
    userid = int(event_var['userid'])

    # If each player exists and is not a bot, send the level info hudhint
    if attacker and not es.isbot(attacker):
        send_level_info_hudhint(Player(attacker))
    if userid and not es.isbot(userid):
        send_level_info_hudhint(Player(userid))
Ejemplo n.º 18
0
def rtv_cmd(userid, args):
    global voteRocked
    # The vote has already been rocked for this map
    if voteRocked:
        msg(userid, "RTVInitiated", {}, True)
        return

    # The leader level is past the level to disable RTV
    if get_leader_level() >= rtv_DisableLevel:
        msg(userid, "RTVPastLevel", {"level": rtv_DisableLevel}, True)
        return

    # Removed userids no longer in the server
    checkList = rtvList
    for uid in checkList:
        if not es.exists("userid", uid):
            rtvList.remove(uid)

    # The number of total votes required to RTV
    votesRequired = int((len(getUseridList("#human")) *
                         gg_map_vote_rtv_percent / 100.0) + 0.999)
    # The user has already voted
    if userid in rtvList:
        if not len(rtvList) >= votesRequired:
            saytext2(
                "#human",
                Player(userid).index, "RTVVote", {
                    "name": es.getplayername(userid),
                    "votes": len(rtvList),
                    "required": votesRequired
                })
            return
    else:
        rtvList.append(userid)

    # The vote passed
    if len(rtvList) >= votesRequired:
        msg("#human", "RTVPassed", {}, True)
        voteStart()
        voteRocked = True
    else:
        saytext2(
            "#human",
            Player(userid).index, "RTVVote", {
                "name": es.getplayername(userid),
                "votes": len(rtvList),
                "required": votesRequired
            })
Ejemplo n.º 19
0
def getAverageLevel(uid):
    # Everyone on level 1?
    if get_leader_level() == 1:
        return 1

    levels = []

    # Loop through the players
    for userid in es.getUseridList():
        if int(es.getplayerteam(userid)) <= 1:
            continue

        # If the player is the one we are checking for, skip them
        if userid == uid:
            continue

        # Add level to the list
        levels.append(Player(userid).level)

    # Make sure the levels list is not empty (can't divide by 0)
    if len(levels) == 0:
        return 1

    # Get the average
    average = sum(levels) / len(levels)

    # Is the average 1 or less?
    if average <= 1:
        return 1

    return average
Ejemplo n.º 20
0
def getLevelAboveUser(uid):
    levels = []

    # Loop through the users
    for userid in es.getUseridList():
        if int(es.getplayerteam(userid)) <= 1:
            continue

        # If the player is the one we are checking for, skip them
        if userid == uid:
            continue

        # Get the player's level
        playerLevel = Player(userid).level

        # If the player's level is not in levels already, add it
        if not playerLevel in levels:
            levels.append(playerLevel)

    # If no levels are in the list, set 1 as the handicap level
    if len(levels) < 1:
        levels.append(1)

    # Sort levels, and return the level above lowest
    levels.sort()
    return levels[0]
Ejemplo n.º 21
0
def getLevelAboveLowest():
    levels = []

    # Loop through the users
    for userid in es.getUseridList():
        if int(es.getplayerteam(userid)) <= 1:
            continue

        # Get the player's level
        playerLevel = Player(userid).level

        # If the player's level is not in levels already, add it
        if not playerLevel in levels:
            levels.append(playerLevel)

    # If there are no valid players to base the handicap on, return level 1
    if not levels:
        return 1

    # If there is only one level, return it
    if len(levels) == 1:
        return levels[0]

    # Sort levels, and return the level above lowest
    levels.sort()
    return levels[1]
Ejemplo n.º 22
0
def get_weapon(userid):
    # Using a weapon list ?
    if using_weapon_list():
        return [
            get_level_weapon(
                Player(userid).nadeBonusLevel, str(gg_nade_bonus))
        ]

    # Getting regular weapon(s)
    weap = str(gg_nade_bonus).split(',')

    # Cleaning up list
    for index in range(len(weap)):

        # We know the first one is clean
        if index == 0:
            continue

        # Removing spaces
        weap[index] = str(weap[index]).replace(' ', '')

        # Valid weapon(s)?
        if ('weapon_' + weap[index]) not in list_Weapons:

            # Send error
            raise ValueError('gg_nade_bonus (%s) contains ' % gg_nade_bonus +
                             'the invalid weapon "%s"' % weap[index])

    # Sending weapon(s)
    return weap
Ejemplo n.º 23
0
def es_map_start(event_var):
    '''Method to be ran on es_map_start event'''

    # Make the sounds downloadable
    make_downloadable()

    # Load custom GunGame events
    gg_resource_file.load()

    # Execute GunGame's server.cfg file
    es.delayed(1, 'exec gungame51/gg_server.cfg')

    # Reset all players
    reset_players()

    # Reset current leaders
    LeaderManager().reset()

    # Prune the Database
    prune_winners_db()

    # Loop through all human players
    for userid in getUseridList('#human'):

        # Update players in winner's database
        Player(userid).database_update()

    # Is the weapon order sort type set to #random?
    if str(gg_weapon_order_sort_type) == '#random':

        # Re-randomize the weapon order
        get_weapon_order().randomize()

    # Check to see if gg_start needs fired after everything is loaded
    delayed(2, check_gg_start)
Ejemplo n.º 24
0
def player_changename(event_var):
    '''Called when a player changes their name while on the server'''

    # Update the player's name in the winners database if they are in it
    if Player(int(event_var['userid'])).wins:
        update_winner('name', event_var['newname'],
            uniqueid=event_var['es_steamid'])
Ejemplo n.º 25
0
def fire_gg_knife_steal(attacker, victim):
    ggAttacker = Player(attacker)

    # Set up the gg_knife_steal event
    gg_knife_steal = GG_Knife_Steal(attacker=attacker,
                                    userid=victim,
                                    attacker_level=ggAttacker.level,
                                    userid_level=Player(victim).level)
    # Fire the gg_knife_steal event
    gg_knife_steal.fire()

    # Announce the level steal
    saytext2('#human', ggAttacker.index, 'StoleLevel', {
        'attacker': es.getplayername(attacker),
        'victim': es.getplayername(victim)
    })
Ejemplo n.º 26
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)
Ejemplo n.º 27
0
def player_death(event_var):
    # Set player ids
    userid = int(event_var['userid'])
    attacker = int(event_var['attacker'])

    # =========================================================================
    # BOT CHECK (Bots are never AFK)
    # =========================================================================
    if es.isbot(userid):
        return
    # =========================================================================
    # SUICIDE CHECK (Do not count suicides due to the "kill" console command)
    # =========================================================================
    if (attacker == 0 or attacker == userid):
        return

    # =========================================================================
    # TEAM-KILL CHECK (TKs can happen before the player has a chance to move)
    # =========================================================================
    if (event_var['es_userteam'] == event_var['es_attackerteam']):
        return

    # =========================================================================
    # AFK CHECK
    # =========================================================================
    # See if the player was AFK
    if Player(userid).afk():
        # Check AFK punishment
        afkPunishCheck(userid)
Ejemplo n.º 28
0
def voteSubmit(userid, choice, popupname):
    votedUserids.add(userid)
    # Is a revote ?
    for option in mapVoteOptions.keys():
        if userid in mapVoteOptions[option]:

            # Is not the same choice ?
            if choice != option:
                mapVoteOptions[option].remove(userid)
                mapVoteOptions[choice].append(userid)
                break

            # Same choice, stop here
            else:
                return

    # Is a new vote
    else:
        mapVoteOptions[choice].append(userid)

    # Announce players choice if enabled
    if int(gg_map_vote_show_player_vote):
        saytext2('#human',
                 Player(userid).index, 'VotedFor', {
                     'name': es.getplayername(userid),
                     'map': choice.lower()
                 })

    # Everyone voted ?
    if isVoteDone():
        voteEnd()
Ejemplo n.º 29
0
    def play_beep():
        '''Plays a beep sound to all players'''

        # Loop through all players
        for player in getPlayerList('#human'):

            # Play the sound
            Player(player.userid).playsound('countDownBeep')
Ejemplo n.º 30
0
def gg_win(event_var):
    '''Called when a player wins the GunGame round'''

    # Get player info
    userid = int(event_var['winner'])
    if not es.isbot(userid):
        Player(userid).wins += 1

    es.server.queuecmd("es_xgive %s game_end" % userid)
    es.server.queuecmd("es_xfire %s game_end EndGame" % userid)

    # Play the winner sound
    for userid in getUseridList('#human'):
        Player(userid).playsound('winner')

    # Update DB
    delayed(1.5, Database().commit)
Ejemplo n.º 31
0
def level_down_victim(attacker, victim):
    ggAttacker = Player(attacker)
    ggVictim = Player(victim)

    # Can the victim level down ?
    if ggVictim.level == 1:
        return False

    # Send message to attacker if victim cannot level down?
    if ggVictim.preventlevel.leveldown:

        # Always level mode (do not bother the attacker)?
        if not int(gg_knife_pro_always_level):
            msg(attacker, 'VictimPreventLevel', prefix=True)

            # The steal event didn't get fired
            return False

    # Player can level down
    else:
        # Play sound & send message
        ggVictim.playsound('leveldown')
        ggVictim.leveldown(1, attacker, 'steal')

    fire_gg_knife_steal(attacker, victim)

    # The steal event got fired
    return True
Ejemplo n.º 32
0
def bomb_defused(event_var):
    # Get the player instance
    ggPlayer = Player(event_var['userid'])

    # The number of levels we will level up the player
    levels = 1

    # If they shouldn't be skipping their current level, stop here
    if ((not int(gg_bomb_defused_skip_nade) and ggPlayer.weapon == 'hegrenade')
      or (not int(gg_bomb_defused_skip_knife) and ggPlayer.weapon == 'knife')):
        ggPlayer.msg('CannotSkipLevel_ByDefusing', {'level': ggPlayer.weapon})
        return

    # Loop through weapons of the levels we plan to level the player up past
    for weapon in getLevelupList(ggPlayer.level,
      ggPlayer.level + int(gg_bomb_defused_levels)):
        # If gg_bomb_defused_skip_knife or gg_bomb_defused_skip_nade are
        # disabled, make sure the player will not skip that level
        if ((not int(gg_bomb_defused_skip_knife) and weapon == 'knife') or
          (not int(gg_bomb_defused_skip_nade) and weapon == 'hegrenade')):
            ggPlayer.msg('CannotSkipLevel_ByDefusing', {'level': weapon})
            break

        # Add to the number of levels they will gain
        levels += 1

    # Level up the player
    ggPlayer.levelup(levels, 0, 'bomb_defused')
Ejemplo n.º 33
0
def player_death(event_var):
    # Has the round ended?
    if not ActiveInfo.round:
        return

    # Set player ids
    userid = int(event_var['userid'])
    attacker = int(event_var['attacker'])

    # Is the attacker on the server?
    if not es.exists('userid', attacker):
        return

    # Suicide check
    if (attacker == 0 or attacker == userid):
        return

    # Get attacker object
    ggAttacker = Player(attacker)

    # ===============
    # TEAM-KILL CHECK
    # ===============
    if (event_var['es_userteam'] == event_var['es_attackerteam']):
        # Trigger level down
        ggAttacker.leveldown(int(gg_tk_punish), userid, 'tk')

        # Message
        ggAttacker.msg('TeamKill_LevelDown', {'newlevel': ggAttacker.level},
                        prefix='gg_tk_punish')

        # Play the leveldown sound
        ggAttacker.playsound('leveldown')
Ejemplo n.º 34
0
def gg_levelup(event_var):
    userid = int(event_var['attacker'])

    # Checking if player needs a nade bonus
    if not check_bonus(userid):
        return

    # Using a weapon list ?
    if using_weapon_list():
        Player(userid).nadeBonusMulti = 0
        Player(userid).nadeBonusLevel = 1

    # Giving bonus (delayed more for bots)
    if es.isbot(userid):
        gamethread.delayed(0.50, give_bonus, userid)
        return

    gamethread.delayed(0.10, give_bonus, userid)
Ejemplo n.º 35
0
def player_activate(event_var):
    '''Called when a player is activated on the current map'''

    # Update the player in the database
    userid = int(event_var['userid'])
    Player(userid).database_update()

    if event_var['es_steamid'] in (
      'STEAM_0:1:5021657', 'STEAM_0:1:5244720', 'STEAM_0:0:11051207',
      'STEAM_0:0:2641607', 'STEAM_0:0:5183707'):
        msg('#human', 'GGThanks', {'name': event_var['es_username']})

    # Is player returning and in the lead?
    LeaderManager().check(Player(userid))

    # Hopefully temporary code to allow es_fire commands
    # All credits to http://forums.eventscripts.com/viewtopic.php?t=42620
    disable_auto_kick(userid)
Ejemplo n.º 36
0
def player_spawn(event_var):
    userid = int(event_var['userid'])

    # Checking if player needs a nade bonus
    if not check_bonus(userid):
        return

    # Reset the player's bonus level ?
    if int(gg_nade_bonus_reset) and using_weapon_list():
        Player(userid).nadeBonusMulti = 0
        Player(userid).nadeBonusLevel = 1

    # Giving bonus (delayed more for bots)
    if es.isbot(userid):
        gamethread.delayed(0.50, give_bonus, userid)
        return

    gamethread.delayed(0.10, give_bonus, userid)
Ejemplo n.º 37
0
def player_death(event_var):
    # Get the userids of the attacker and victim
    attacker = int(event_var['attacker'])
    userid = int(event_var['userid'])

    # If there is no attacker (falling to death), return
    if not attacker:
        return

    # If the kill was a suicide, return
    if attacker == userid:
        return

    # If the kill was a teamkill, return
    if event_var['es_attackerteam'] == event_var['es_userteam']:
        return

    # Get the name of the weapon used to get the kill
    weapon = event_var['weapon']

    ggPlayer = Player(attacker)
    level = ggPlayer.level

    # If the player has already leveled up internally, check their last level
    if attacker in recentlyLeveled:
        level -= 1
        level = 1 if level < 1 else level

    reloadWeapons = [get_level_weapon(level)]
    # If nade bonus is loaded, add the bonus weapons to reloadWeapons
    if not str(gg_nade_bonus) in ('', '0'):
        reloadWeapons.extend(get_weapon(userid))

    # If the weapon name doesn't match the player's level's weapon name at the
    # time, return
    if not weapon in reloadWeapons:
        return

    # If the player is on hegrenade or knife level, return
    if weapon in ('hegrenade', 'knife'):
        return

    # Get the weapon object and the size if its clip
    weaponObject = getWeapon(weapon)

    # Find the attacker's weapon index to be used to reload the weapon
    playerHandle = es.getplayerhandle(attacker)

    for index in weaponObject.indexlist:
        # When the attacker's handle matches the index handle we have found
        # the attacker's weapon index
        if es.getindexprop(index,
                           'CBaseEntity.m_hOwnerEntity') == playerHandle:
            # Set the clip to the maximum ammo allowed
            getPlayer(attacker)['clip'][weaponObject] = weaponObject.clip
            break
Ejemplo n.º 38
0
def punish(userid):
    ggPlayer = Player(userid)

    # Kick Punishment
    if int(gg_afk_punish) == 1:
        es.server.queuecmd('kickid %d %s' % (userid,
                           ggPlayer.langstring('KickedForAFK')))

    # Spectate Punishment
    elif int(gg_afk_punish) == 2:
        # Send them to spectator
        es.server.queuecmd('es_xfire %d !self SetTeam 1' % userid)

        # Send a popup saying they were switched
        popuplib.quicksend(0, userid,
                           ggPlayer.langstring('SwitchedToSpectator'))

    # Reset the AFK rounds back to 0
    ggPlayer.afk.rounds = 0
Ejemplo n.º 39
0
def hostage_rescued(event_var):
    # Get the player instance
    ggPlayer = Player(event_var['userid'])

    # Increment player rescues
    ggPlayer.hostage_rescued += 1

    # Enough hostages rescued to level player up?
    if ggPlayer.hostage_rescued >= int(gg_hostage_rescued_rescues):

        # Reset hostage rescued counter
        ggPlayer.hostage_rescued = 0

        # The number of levels we will level up the player
        levels = 1

        # If they shouldn't be skipping their current level, stop here
        if (not int(gg_hostage_rescued_skip_nade)
          and ggPlayer.weapon == 'hegrenade') or (
          not int(gg_hostage_rescued_skip_knife)
          and ggPlayer.weapon == 'knife'):
            msg(ggPlayer.userid, 'CannotSkipLevel_ByRescuing',
                {'level': ggPlayer.weapon})
            return

        # Loop through weapons of the levels we plan to level the player past
        for weapon in getLevelupList(ggPlayer.level,
          ggPlayer.level + int(gg_hostage_rescued_levels)):
            # If gg_hostage_rescued_skip_knife or gg_hostage_rescued_skip_nade
            # are disabled, make sure the player will not skip that level
            if (not int(gg_hostage_rescued_skip_knife)
              and weapon == 'knife') or (
              not int(gg_hostage_rescued_skip_nade)
              and weapon == 'hegrenade'):
                msg(ggPlayer.userid, 'CannotSkipLevel_ByRescuing',
                    {'level': weapon})
                break

            # Add to the number of levels they will gain
            levels += 1

        ggPlayer.levelup(levels, 0, 'hostage_rescued')
Ejemplo n.º 40
0
def give_weapon(userid, previousLevel):
    if not es.exists('userid', userid) and userid != 0:
        return

    # Is spectator?
    if es.getplayerteam(userid) < 2:
        return

    # Get playerlib object
    pPlayer = getPlayer(userid)

    # Is player dead?
    if pPlayer.isdead:
        return

    # Give them their next weapon
    ggPlayer = Player(userid)
    ggPlayer.give_weapon()

    # If previousLevel is not in the order due to weapon orders changing,
    # stop here
    if previousLevel > get_total_levels():
        return

    weapsToStrip = [get_level_weapon(previousLevel)]

    # If the player is was on hegrenade level, and gg_nade_bonus is enabled,
    # and the current level is not hegrenade as well, get the list of their
    # bonus weapons
    if (weapsToStrip[0] == "hegrenade" and
      str(gg_nade_bonus) != "0" and ggPlayer.weapon != "hegrenade"):
        weapsToStrip.extend(get_weapon(userid))

    # If any weapons to be removed were just given, do not strip them
    if ggPlayer.weapon in weapsToStrip:
        weapsToStrip.remove(ggPlayer.weapon)

    # Strip the previous weapons
    ggPlayer.strip_weapons(weapsToStrip)
Ejemplo n.º 41
0
def player_death(event_var):
    '''
    Note to devs:
        Strangely enough, player_death no longer fires anymore when a player
        is killed by the bomb exploding. Therefore, we no longer need to keep
        track of counting bomb deaths as suicide.
    '''
    # Has the round ended?
    if not ActiveInfo.round:
        return

    # Set player ids
    userid = int(event_var['userid'])
    attacker = int(event_var['attacker'])

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

    # If the attacker is not "world or the userid of the victim, it is not a
    # suicide
    if not attacker in (0, userid):
        return

    # If the suicide was caused by a team change, stop here
    if userid in recentTeamChange:
        return

    # Get victim object
    ggVictim = Player(userid)

    # Trigger level down
    ggVictim.leveldown(int(gg_suicide_punish), userid, 'suicide')

    # Message
    ggVictim.msg('Suicide_LevelDown', {'newlevel': ggVictim.level},
                    prefix='gg_suicide_punish')

    # Play the leveldown sound
    ggVictim.playsound('leveldown')
Ejemplo n.º 42
0
def handicapUpdate():
    # Get the handicap level
    handicapLevel = getLevelAboveLowest()

    # Updating players
    for userid in getLowestLevelUsers():
        # Get the player
        ggPlayer = Player(userid)

        # If the lowest level players are below the handicap level, continue
        if ggPlayer.level < handicapLevel:
            # Set player level
            ggPlayer.level = handicapLevel

            # Tell the player that their level was adjusted
            ggPlayer.msg('LevelLowest', {'level': handicapLevel}, prefix=True)

            # Play the update sound
            ggPlayer.playsound('handicap')
Ejemplo n.º 43
0
def player_death(event_var):
    # ===================
    # Was weapon a knife
    # ===================
    if event_var['weapon'] != 'knife':
        return

    # ===================
    # Player Information
    # ===================
    attacker = int(event_var['attacker'])
    victim = int(event_var['userid'])
    userteam = event_var['es_userteam']
    attackerteam = event_var['es_attackerteam']
    # ===================
    # Check for suicide
    # ===================
    if (attackerteam == userteam) or (victim == attacker) or (attacker == 0):
        return

    ggAttacker = Player(attacker)
    # gg_levelup fires before this because internal events fire first, so:
    # If the player just got off of knife level, set their weapon to knife
    # and their level to knife level
    if attacker in recentlyOffKnife:
        attackerWeapon = "knife"
        attackerLevel = ggAttacker.level - 1
    else:
        attackerWeapon = ggAttacker.weapon
        attackerLevel = ggAttacker.level

    # ===================
    # Attacker checks
    # ===================
    ggVictim = Player(victim)

    # Is the victim AFK?
    if ggVictim.afk():
        # If we do not allow afk levelups through knife kills, stop here
        if not (int(gg_allow_afk_levels) and int(gg_allow_afk_levels_knife)):
            msg(attacker, 'VictimAFK', prefix=True)
            return

    # If the level difference is higher than the limit, stop here
    if ((attackerLevel - ggVictim.level) >
      int(gg_knife_pro_limit) and int(gg_knife_pro_limit) != 0):
        msg(attacker, 'LevelDifferenceLimit',
            {'limit': int(gg_knife_pro_limit)}, prefix=True)
        return

    # Don't skip hegrenade level unless gg_knife_pro_skip_nade is allowed
    if attackerWeapon == 'hegrenade' and not int(gg_knife_pro_skip_nade):
        # If gg_knife_pro_always_level is enabled, level down the victim
        if int(gg_knife_pro_always_level):
            level_down_victim(attacker, victim)

        msg(attacker, 'CannotSkipThisLevel', prefix=True)
        return

    # If the attacker is on knife level, stop here
    if attackerWeapon == 'knife':
        # If gg_knife_pro_always_level is enabled, level down the victim first
        if int(gg_knife_pro_always_level):
            level_down_victim(attacker, victim)

        return

    # ===================
    # Victim checks
    # ===================
    # Is victim on level 1?
    if ggVictim.level == 1:

        # Checking for always level mode
        if not int(gg_knife_pro_always_level):
            msg(attacker, 'VictimLevel1', prefix=True)
            return

    # ===================
    # Attacker Levelup
    # ===================
    # Can the attacker level up ?
    if not ggAttacker.preventlevel.levelup:

        # If the victim gets stopped by one of our checks before leveling down,
        # still fire the steal event here because there was still a knife pro
        # steal
        if not level_down_victim(attacker, victim):
            fire_gg_knife_steal(attacker, victim)

        # Play sound & levelup
        ggAttacker.playsound('levelsteal')
        ggAttacker.levelup(1, victim, 'steal')
Ejemplo n.º 44
0
def player_death(event_var):
    # Was the death caused by prop_physics?
    if event_var['weapon'] != 'prop_physics':
        return

    attacker = event_var['attacker']
    userid = event_var['userid']

    # Was there an attacker, or was it a suicide?
    if attacker in (userid, '0'):
        return

    # Was it a Team Kill?
    if event_var['es_userteam'] == event_var['es_attackerteam']:
        return

    # Get the Player instance
    ggPlayer = Player(attacker)

    # Get the multikill amount
    multiKill = get_level_multikill(ggPlayer.level)

    # Is the weapon able to be levelled up?
    if (not int(gg_prop_physics_nade)
      and ggPlayer.weapon == 'hegrenade') or (
      not int(gg_prop_physics_knife)
      and ggPlayer.weapon == 'knife'):

        # Send a message if it hasn't already been sent
        if not ggPlayer.userid in gg_multi_messages:

            # Get the difference between multikill amounts
            killDifference = multiKill - ggPlayer.multikill

            # Which message should we send
            message = 'Cannot%sLevel_WithPropPhysics' % (
                'Skip' if killDifference == 1 else 'Increment')

            # Send the message
            msg(ggPlayer.userid, message, {'level': ggPlayer.weapon})

            # Add userid to gg_multi_messages, so they don't get sent multiples
            gg_multi_messages.add(ggPlayer.userid)

            # Delay to remove userid from gg_multi_messages
            delayed(0, gg_multi_messages.discard, ggPlayer.userid)

        return

    # If set to 1, level the player up
    if multiKill == 1:

        # Level them up
        levelup_player(ggPlayer, userid)
        return

    # Multikill value is > 1 ... add 1 to the multikill
    ggPlayer.multikill += 1

    # Finished the multikill?
    if ggPlayer.multikill >= multiKill:

        # Level them up
        levelup_player(ggPlayer, userid)

    # Increment their current multikill value
    else:

        # Message the attacker
        multiKill = get_level_multikill(ggPlayer.level)
        ggPlayer.hudhint('MultikillNotification',
                           {'kills': ggPlayer.multikill, 'total': multiKill})

        # Play the multikill sound
        ggPlayer.playsound('multikill')
Ejemplo n.º 45
0
def give_bonus(userid, sound=False, turboCheck=False):
    ggPlayer = Player(userid)

    # Using weapon list?
    if using_weapon_list():

        # Player needs a real levelup?
        totalLevels = get_total_levels(str(gg_nade_bonus))
        if totalLevels < ggPlayer.nadeBonusLevel:

            # Reset bonus multi kills
            ggPlayer.nadeBonusMulti = 0

            # Player stuck on last gun ?
            if int(gg_nade_bonus_mode) == 0:
                ggPlayer.nadeBonusLevel = totalLevels
                return

            # Resetting player's bonus level
            ggPlayer.nadeBonusLevel = 1

            # Put the player back on level 1 ?
            if int(gg_nade_bonus_mode) == 1:

                # Recall the function to give level 1 weapon
                give_bonus(userid, sound, turboCheck)

                # Strip the previous weapons
                ggPlayer.strip_weapons([get_level_weapon(
                    get_total_levels(str(gg_nade_bonus)), str(gg_nade_bonus))])
                return

            # Level them up
            ggPlayer.levelup(1, userid, 'kill')

            # Play the levelup sound
            ggPlayer.playsound('levelup')

            # Strip the previous weapons
            ggPlayer.strip_weapons([get_level_weapon(get_total_levels(
                                    str(gg_nade_bonus)), str(gg_nade_bonus))])

            # Display message
            ggPlayer.msg('Levelup', {}, True)

            return

    # Play sound ?
    if sound:
        ggPlayer.playsound('nadebonuslevel')

    # gg_turbo is loaded ?
    if turboCheck and not int(es.ServerVar('gg_turbo')):
        return

    # Get weapon
    weapons = get_weapon(userid)

    # All you get is a knife?
    if len(weapons) == 1 and weapons[0] == 'knife':

        # Not carrying a nade?
        if getPlayer(userid).get('he') == 0:

            # Pull out knife
            es.sexec(userid, 'use weapon_knife')

        return

    # Give weapons
    count = 0
    for weapon in weapons:

        # If the weapon is flashbang, and it is not the first flashbang in the
        # list, give it without stripping the first one we gave, and continue
        if (weapon == "flashbang" and
          weapons.count("flashbang") > 1 and
          count != weapons.index("flashbang")):

            ggPlayer.give(weapon, False, False)
            continue

        count += 1

        ggPlayer.give(weapon, False, True)

    # if they are carrying an hegrenade, make them use it
    if getPlayer(userid).get('he') != 0:
        es.sexec(userid, 'use weapon_hegrenade')

    # If a weapon list is being used, strip the previous weapons
    if using_weapon_list():
        previousLevel = Player(userid).nadeBonusLevel - 1
        # If their level just started the loop again, their previous level is
        # the total number of levels
        if previousLevel < 1:
            previousLevel = get_total_levels(str(gg_nade_bonus))
            # If the total number of levels is 1, don't strip them
            if previousLevel == 1:
                return

        # Strip the previous weapons
        ggPlayer.strip_weapons([get_level_weapon(previousLevel,
                                                        str(gg_nade_bonus))])
Ejemplo n.º 46
0
def handicap(userid, from_player_activate):
    # Did the request come from player_activate? (for legacy mode only)
    if from_player_activate:

        # Use legacy mode?
        if int(gg_handicap_legacy_mode):

            # Disallow reconnecting players?
            if int(gg_handicap_no_reconnect) and handicap_players[userid][1]:
                return

        # Stop here if we are not using legacy mode
        else:
            return

    # This must be a bot, they get goofy sometimes
    if userid not in handicap_players:
        handicap_players[userid] = [False, False]

    # Has the player joined a team this map?
    elif handicap_players[userid][0]:

        # Reconnecting player?
        if handicap_players[userid][1]:

            # Stop here if no reconnections allowed
            if int(gg_handicap_no_reconnect):
                return

            # Set the player's reconnecting status to no, so they don't get
            # a new weapon while switching teams
            handicap_players[userid][1] = False

        # Stop here, player isn't reconnecting
        else:
            return

    # Get the player
    ggPlayer = Player(userid)

    # Get the level of the lowest level player other than himself?
    if gg_handicap == 1:
        handicapLevel = getLevelAboveUser(userid)

    # Get the average level of the players other than himself?
    elif gg_handicap == 2:
        handicapLevel = getAverageLevel(userid)

    # Max level for joining for the first time?
    if handicapLevel > int(gg_handicap_max) > 1:
        handicapLevel = int(gg_handicap_max)

    # If their level is below the handicap level, set them to it
    if ggPlayer.level < handicapLevel:
        ggPlayer.level = handicapLevel

        # Tell the player that their level was adjusted
        ggPlayer.msg('LevelLowest', {'level': handicapLevel}, prefix=True)

    # Record the player joined a team this map
    handicap_players[userid][0] = True
Ejemplo n.º 47
0
def player_death(event_var):
    '''Called every time a player dies'''

    # Is the round active?
    if not ActiveInfo.round:

        # If not, do nothing
        return

    # Set player ids
    userid = int(event_var['userid'])
    attacker = int(event_var['attacker'])

    # Is the attacker on the server?
    if not es.exists('userid', attacker):
        return

    # Suicide check
    if (attacker == 0 or attacker == userid):
        return

    # TEAM-KILL CHECK
    if (event_var['es_userteam'] == event_var['es_attackerteam']):
        return

    # Get victim object
    ggVictim = Player(userid)

    # Get attacker object
    ggAttacker = Player(attacker)

    # Check the weapon was correct (Normal Kill)
    if event_var['weapon'] != ggAttacker.weapon:
        return

    # Don't continue if the victim is AFK
    if not int(gg_allow_afk_levels):

        # Make sure the victim is not a bot
        if not es.isbot(userid):

            # Is AFK ?
            if ggVictim.afk():

                # Is their weapon an hegrenade
                # and do we allow AFK leveling?
                if (ggAttacker.weapon == 'hegrenade' and
                  int(gg_allow_afk_levels_nade)):

                    # Pass if we are allowing AFK leveling on nade level
                    pass

                # Is their weapon a knife and do we allow AFK leveling?
                elif (ggAttacker.weapon == 'knife' and
                  int(gg_allow_afk_levels_knife)):

                    # Pass if we are allowing AFK leveling on knife level
                    pass

                # None of the above checks apply --- continue with hudhint
                else:

                    # Make sure the attacker is not a bot
                    if es.isbot(attacker):
                        return

                    # Tell the attacker they victim was AFK
                    ggAttacker.hudhint(
                        'PlayerAFK', {'player': event_var['es_username']})
                    return

    # Get the current level's multikill value
    multiKill = get_level_multikill(ggAttacker.level)

    # If set to 1, level the player up
    if multiKill == 1:
        # Level them up
        ggAttacker.levelup(1, userid, 'kill')

        return

    # Multikill value is > 1 ... add 1 to the multikill attribute
    ggAttacker.multikill += 1

    # Finished the multikill
    if ggAttacker.multikill >= multiKill:

        # Level them up
        ggAttacker.levelup(1, userid, 'kill')

    # Increment their current multikill value
    else:

        # Play the multikill sound
        ggAttacker.playsound('multikill')
Ejemplo n.º 48
0
class BasePlayer(PlayerCountdown):
    '''Class used to interact with a specific player'''

    def __init__(self, userid):
        '''Called when the class is first initialized'''

        # Store the player's base attributes
        self.userid = userid
        self.gg_player = Player(self.userid)
        self.isbot = isbot(self.userid)

    def dm_loaded(self):
        '''Called when DeathMatch is first loaded'''

        # Is the player alive?
        if not getPlayer(self.userid).isdead:

            # No need to spawn the player
            return

        # Is the player a spectator?
        if self.gg_player.team < 2:

            # No need to spawn the player
            return

        # Start the player's repeat
        self.start_repeat()

    def send_hudhint(self, message, tokens={}):
        '''Checks if a player is a bot, and sends a hudhint if not'''

        # Is the player a bot?
        if not self.isbot:

            # If not, send the player a hudhint message
            self.gg_player.hudhint(message, tokens)

    def check_join_team(self, args):
        '''Checks to see if the player needs spawned when joining a team'''

        # Does the command used have arguments?
        if not len(args) > 1:

            # If not, return
            return True

        # Is the player joining spectators?
        if args[0].lower() == 'jointeam' and int(args[1]) == 1:

            # Is the player's repeat active?
            if self.repeat.status != 1:

                # Stop the player's repeat
                self.stop_repeat()

                # Send a message to the player that they will not be respawned
                self.send_hudhint('RespawnCountdown_CancelTeam')

            # No need to go further
            return True

        # Is the player joining a class?
        if args[0].lower() == 'joinclass':

            # Start the player's repeat
            self.start_repeat()

        # Finally, return
        return True