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