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