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')
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')
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')
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')
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')
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))])
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
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))])