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 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): # 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')
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')
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')
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 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')
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')
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 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')
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')