def _play_quakesound(soundname, userid, attackerid):
    if soundname in quake_sounds_kv:
        if 'mode' in quake_sounds_kv[soundname]:
            mode = int(quake_sounds_kv[soundname]['mode'])
        else:
            mode = '1'
        if 'visual_mode' in quake_sounds_kv[soundname]:
            visual_mode = int(quake_sounds_kv[soundname]['visual_mode'])
        else:
            visual_mode = '1'
        if mode == 0:
            useridlist_sound = []
        elif mode == 1:
            useridlist_sound = playerlib.getUseridList('#human')
        elif mode == 2:
            useridlist_sound = [userid, attackerid]
        elif mode == 3:
            useridlist_sound = [attackerid]
        elif mode == 4:
            useridlist_sound = [userid]
        else:
            useridlist_sound = playerlib.getUseridList('#human')
        if visual_mode == 0:
            useridlist_text = []
        elif visual_mode == 1:
            useridlist_text = playerlib.getUseridList('#human')
        elif visual_mode == 2:
            useridlist_text = [userid, attackerid]
        elif visual_mode == 3:
            useridlist_text = [attackerid]
        elif visual_mode == 4:
            useridlist_text = [userid]
        else:
            useridlist_text = playerlib.getUseridList('#human')
        if (userid > 0) and (attackerid > 0):
            langdata = {"username":es.getplayername(userid), "attackername":es.getplayername(attackerid)}
        elif userid > 0:
            langdata = {"username":es.getplayername(userid)}
        elif attackerid > 0:
            langdata = {"attackername":es.getplayername(attackerid)}
        else:
            langdata = {}
        for userid in useridlist_sound:
            if not es.isbot(userid):
                soundfile = None
                style = str(quake_sounds_setting.get(userid))
                if style != 'off':
                    if style in quake_sounds_kv[soundname]['sound']:
                        soundfile = str(quake_sounds_kv[soundname]['sound'][style])
                    elif 'standard' in quake_sounds_kv[soundname]['sound']:
                        soundfile = str(quake_sounds_kv[soundname]['sound']['standard'])
                    if soundfile:
                        es.playsound(userid, soundfile, 1.0)
        for userid in useridlist_text:
            if not es.isbot(userid):
                style = str(quake_sounds_setting.get(userid))
                if style != 'off':
                    player = playerlib.getPlayer(userid)
                    soundtext = quake_sounds_language(soundname, langdata, player.get("lang"))
                    usermsg.centermsg(userid, str(soundtext))
Exemple #2
0
def vip_killed(ev):
    if not es.isbot(ev['attacker']):
        dbg( 'vip killed')
        players.increment(ev['attacker'],'vip_killed')
    if not es.isbot(ev['userid']):
        dbg( 'vip died')
        players.increment(sid(ev),'vip_died')
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))
Exemple #4
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))
Exemple #5
0
def player_death(event_var):
  if not es.isbot(event_var['userid']):
    if teachAdmins == 1:
      # This tells admins every time they die how to ban a player
      # This is to help them learn the command
      if isMember(event_var['es_steamid']):
        es.tell(event_var['userid'], '#multi', '#greenType the following in say to ban: #default!banmenu')
def multikill_call_back(name, value, ggPlayer):
    # Does the player have a multikill value?
    if not hasattr(ggPlayer, 'multikill'):
        return

    # Is the player a bot?
    if es.isbot(ggPlayer.userid):
        return

    # Did the player just level up?
    if value == 0:
        return

    # Get multikills needed
    multikill = get_level_multikill(ggPlayer.level)

    # Is the player going to level up?
    if value >= multikill:
        return

    # Message the player
    ggPlayer.hudhint('MultikillNotification', {
        'kills': value,
        'total': multikill
    })
Exemple #7
0
def gg_team_win(event_var):
    '''Fired when a team wins the match'''

    # Reset team level and multikill values
    gg_teams.clear()

    # Send Winner Messages?
    if int(gg_teamplay_winner_messages):

        # Send Winner Messages
        gg_teams[int(event_var['winner'])].send_winner_messages()

    # Get a random player from the server
    userid = getuserid()

    # End the match
    ServerCommand('es_xgive %s game_end' % userid)
    ServerCommand('es_xfire %s game_end EndGame' % userid)

    # Loop through all players on the server
    for userid in getUseridList():

        # Is the player a bot?
        if isbot(userid):

            # If so, don't play the sound
            continue

        # Play the winner sound to the player
        Player(userid).playsound('winner')
Exemple #8
0
def player_jump(ev):
    if not es.isbot(ev['userid']):
        dbg( 'player jumped')
        steamid = sid(ev)
        players.increment(steamid,'jump')
        vStartpos = vecmath.vector(es.getplayerlocation(ev['userid']))
        players.update(steamid,'jump_startpos',str(vStartpos))
Exemple #9
0
def drunk(users, lifetime=0, iFov=155):
    '''Drunk a player for the given time...'''
    
    # Loop through all matching players...
    for userid in _get_matching_players(users):
        
        # Is the player a bot?
        if es.isbot(userid):
            
            # Don't go further...
            continue
            
        # Set the fov to the given value...
        es.setplayerprop(userid, 'CBasePlayer.m_iDefaultFOV', iFov)
        es.setplayerprop(userid, 'CBasePlayer.m_iFOV', iFov)
        
        # Is there any time given?
        if not lifetime:
            
            # Don't go further...
            continue
            
        # Undrunk the player after the given time...
        gamethread.delayedname(
            lifetime, '_wcs_delay', _reset_player_fov, userid)
Exemple #10
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)
Exemple #11
0
def gg_team_win(event_var):
    '''Fired when a team wins the match'''

    # Reset team level and multikill values
    gg_teams.clear()

    # Send Winner Messages?
    if int(gg_teamplay_winner_messages):

        # Send Winner Messages
        gg_teams[int(event_var['winner'])].send_winner_messages()

    # Get a random player from the server
    userid = getuserid()

    # End the match
    ServerCommand('es_xgive %s game_end' % userid)
    ServerCommand('es_xfire %s game_end EndGame' % userid)

    # Loop through all players on the server
    for userid in getUseridList():

        # Is the player a bot?
        if isbot(userid):

            # If so, don't play the sound
            continue

        # Play the winner sound to the player
        Player(userid).playsound('winner')
Exemple #12
0
    def send_all_players_a_message(self, message, tokens):
        '''Sends all players on the server a message'''

        # Store a team members index
        index = self.index

        # Is there an index?
        if index is None:

            # If not, don't send any messages
            return

        # Loop through all players on the server
        for userid in getUseridList():

            # Is the player a bot?
            if isbot(userid):

                # If so, don't send a message
                continue

            # Get the team's name
            teamname = langstring(self.teamname, userid=userid)

            # Update the tokens with the teamname
            tokens.update({'teamname': teamname})

            # Send the message to the player
            Player(userid).saytext2(index, message, tokens, True)
Exemple #13
0
def round_end(ev):
    est.speed("#b!d", 9)
    for userid in es.getUseridList():
        if es.isbot(userid):
            continue
        es.stopsound(userid, sv('music'))
        es.playsound(userid, "zeisenproject/the-killers/sounds/sndRewind.wav", 1.0)
Exemple #14
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)
Exemple #15
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)
Exemple #16
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)
Exemple #17
0
def player_spawn(ev):
    dbg('player_spawn')
    if not es.isbot(ev['userid']):
        steamid = es.getplayersteamid(ev['userid'])
        if not steamid:
            dbg('NO STEAM ID!!!')
            return
        if steamid == 'STEAM_ID_PENDING':
            dbg('STEAM_ID_PENDING')
            gamethread.delayedname(1, 'xs_delayed_%s' % ev['userid'], pendingCheck, kw={userid:ev['userid']})
            pending.append(ev['userid']) 
            return
        if not ev['userid'] in newconnected:
            return
        if not steamid in players:
            players.newplayer(steamid)
        if not steamid in toplist:
            toplist.newplayer(steamid)
        players.increment(steamid,'sessions')
        players.update(steamid,'sessionstart',time.time())
        players.update(steamid,'lastseen',time.time())
        players.update(steamid,'teamchange_time',time.time())
        newname = es.getplayername(ev['userid'])
        players.name(steamid,newname)
        newconnected.remove(ev['userid'])
        if ev['userid'] in pending:
            pending.remove(ev['userid'])
        dbg('player spawned: %s' % steamid)
Exemple #18
0
    def send_all_players_a_message(self, message, tokens):
        '''Sends all players on the server a message'''

        # Store a team members index
        index = self.index

        # Is there an index?
        if index is None:

            # If not, don't send any messages
            return

        # Loop through all players on the server
        for userid in getUseridList():

            # Is the player a bot?
            if isbot(userid):

                # If so, don't send a message
                continue

            # Get the team's name
            teamname = langstring(self.teamname, userid=userid)

            # Update the tokens with the teamname
            tokens.update({'teamname': teamname})

            # Send the message to the player
            Player(userid).saytext2(index, message, tokens, True)
Exemple #19
0
def player_hurt(ev):
    victim = ev['es_steamid']
    attacker = ev['es_attackersteamid']
    weapon = ev['weapon']
    damage = int(ev['damage'])
    if weapon in weapons:
        weapons.add(weapon,'damage',float(damage))
    if not es.isbot(ev['userid']):
        dbg( 'player hurt')
        players.increment(victim,'hurt')
        players.add(victim,'hurt_damage',damage)
    if not es.isbot(ev['attacker']) and bool(int(ev['attacker'])):
        dbg( 'player hurted')
        players.increment(attacker,'attacked')
        players.add(attacker,'attacked_damage',damage)
        if 'damage_%s' % weapon in players.columns:
            players.add(attacker,'damage_%s' % weapon,damage)
Exemple #20
0
def round_end(ev):
    est.speed("#b!d", 9)
    for userid in es.getUseridList():
        if es.isbot(userid):
            continue
        es.stopsound(userid, sv('music'))
        es.playsound(userid, "zeisenproject/the-killers/sounds/sndRewind.wav",
                     1.0)
Exemple #21
0
def player_death(ev):
    dbg(' ')
    victimIsBot = bool(es.isbot(ev['userid']))
    victimSteamid = ev['es_steamid']
    victimTeam = ev['es_userteam']
    attackerIsBot = bool(es.isbot(ev['attacker']))
    attackerSteamid = ev['es_attackersteamid']
    attackerTeam = ev['es_attackerteam']
    wasTeamKill = True if attackerTeam == victimTeam else False
    isHeadshot = True if ev['headshot'] == '1' else False
    weapon = ev['weapon']
    dbg('player_death')
    dbg('victim: %s (%s)' % (victimSteamid,victimIsBot))
    dbg('attacker: %s (%s)' % (attackerSteamid,attackerIsBot))
    dbg('teamkill: %s (%s,%s)' % (wasTeamKill,victimTeam,attackerTeam))
    dbg('headshot: %s (%s)' % (isHeadshot,ev['headshot']))
    dbg('weapon: %s' % weapon)
    if weapon in weapons:
        weapons.increment(weapon,'kills')
    if wasTeamKill:
        dbg( 'teamkill')
        if not victimIsBot:
            players.increment(victimSteamid,'teamkilled')
        if not attackerIsBot:
            players.increment(attackerSteamid,'teamkills')
    else:
        dbg( 'kill')
        if not victimIsBot:
            players.increment(victimSteamid,'deaths')
        if not attackerIsBot:
            players.increment(attackerSteamid,'kills')
    if not victimIsBot:
        dbg( 'weapon stats (death)')
        if 'death_%s' % weapon in players.columns:
            players.increment(victimSteamid,'death_%s' % weapon)
        else:
            dbg('Custom weapon, not in database...')
    if not attackerIsBot:
        dbg( 'weapon stats (kill)')
        if 'kill_%s' % weapon in players.columns:
            players.increment(attackerSteamid,'kill_%s' % weapon)
        else:
            dbg('Custom weapon, not in database...')
        if isHeadshot:
            players.increment(attackerSteamid,'headshots')
Exemple #22
0
 def playerSpawn(self, ev):
     if int(ev["es_userteam"]) > 1:
         userid = int(ev["userid"])
         if es.isbot(userid):
             self.bots[userid] = Zombie(userid)
             self.bots[userid].prepare()
         else:
             self.humans[userid] = Human(userid)
             self.humans[userid].prepare()
def weapon_purchase(ev):
    if not es.isbot(ev['userid']):
        extendedstats.dbg( 'weapon purchase')
        steamid = extendedstats.sid(ev)
        weapon = ev['weapon']
        if 'bought_%s' in extendedstats.players.columns:
            extendedstats.players.increment(steamid,'bought_%s' % weapon)
            extendedstats.weapons.increment(weapon,'bought')
        else:
            extendedstats.dbg('custom weapon, not in database...')
Exemple #24
0
def refresh_hudhint():
    score = int(sv('score'))
    combo = int(sv('combo'))
    combo_msg = " "
    if combo > 0:
        combo_msg = "(%sx Combo)" % (combo)
    hudhint_string = "* %s PTS\n%s\n \n " % (score, combo_msg)
    for userid in es.getUseridList():
        if es.isbot(userid):
            continue
        usermsg.hudhint(userid, hudhint_string)
Exemple #25
0
def refresh_hudhint():
    score = int(sv('score'))
    combo = int(sv('combo'))
    combo_msg = " "
    if combo > 0:
        combo_msg = "(%sx Combo)" %(combo)
    hudhint_string = "* %s PTS\n%s\n \n " %(score, combo_msg)
    for userid in es.getUseridList():
        if es.isbot(userid):
            continue
        usermsg.hudhint(userid, hudhint_string)
def set_clan_tag():
    for userid in es.getUseridList():
        spe_player = SPEPlayer(userid)
        steamid = es.getplayersteamid(userid)
        player = playerlib.getPlayer(userid)
        if not player.isdead:
            if not es.isbot(userid):
                spe_player.clantag = "[%s]" % chat.getClantag(userid)
            else:
                spe_player.clantag = "N Replay | "

    gamethread.delayedname(10, "tag", set_clan_tag)
def Request_Prep_NewPlayer(Userid):
	global Zombies,Survivors,Spec,Grace,Kicked_Bots
	if Userid not in Zombies and Userid not in Survivors and Userid not in Spec:
		if not Grace:
			if not es.isbot(Userid):
				Spec.append(Userid)
			else:
				es.server.queuecmd("tf_bot_kick %s"%es.getplayername(Userid))
				Kicked_Bots += 1
		else:
			Zombify_Cheap(Userid)
	Request_TeamUpdate()
def sm2es_keyPress(ev):
    userid = ev["userid"]
    if es.exists("userid", userid):

        if ev['status'] == '0':
            return
        if es.isbot(userid):
            return

        ply = playerlib.getPlayer(userid)

        if ply.isdead:
            return

        velocity_x = float(
            es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]'))
        velocity_y = float(
            es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]'))
        velocity = int(
            vector(
                float(
                    es.getplayerprop(
                        userid, 'CBasePlayer.localdata.m_vecVelocity[0]')),
                float(
                    es.getplayerprop(
                        userid,
                        'CBasePlayer.localdata.m_vecVelocity[1]'))).length())
        steamid = es.getplayersteamid(userid)
        if analysis[steamid]['onground'] == 0:
            if ev["command"] == 'IN_MOVELEFT':
                if analysis[steamid]['move'] == 0:
                    analysis[steamid]['move'] = 1
                    analysis[steamid]['view_angle_0'].append(
                        ply.getViewAngle()[0])
                    analysis[steamid]['view_angle_1'].append(
                        ply.getViewAngle()[1])
                    analysis[steamid]['intervals'].append(time.time())
                    analysis[steamid]['velocity'].append(velocity)
                    analysis[steamid]['strafes'] += 1

            if ev['command'] == 'IN_MOVERIGHT':
                if analysis[steamid]['move'] == 1:
                    analysis[steamid]['move'] = 0
                    analysis[steamid]['view_angle_0'].append(
                        ply.getViewAngle()[0])
                    analysis[steamid]['view_angle_1'].append(
                        ply.getViewAngle()[1])
                    analysis[steamid]['intervals'].append(time.time())
                    analysis[steamid]['velocity'].append(velocity)
                    analysis[steamid]['strafes'] += 1
Exemple #29
0
    def _set_wins(self, value):
        """Sets the number wins."""
        # Bots can't win
        if _es.isbot(self.userid):
            return

        # Has won before
        if self.wins:
            _update_winner('wins', value, uniqueid=self.steamid)
        # New entry
        else:
            name = _es.getplayername(self.userid)
            if not name:
                name = "unnamed"
            _insert_winner(name, self.steamid, value)
Exemple #30
0
    def _set_wins(self, value):
        """Sets the number wins."""
        # Bots can't win
        if _es.isbot(self.userid):
            return

        # Has won before
        if self.wins:
            _update_winner('wins', value, uniqueid=self.steamid)
        # New entry
        else:
            name = _es.getplayername(self.userid)
            if not name:
                name = "unnamed"
            _insert_winner(name, self.steamid, value)
Exemple #31
0
def tp_menu(userid):
    steamid = es.getplayersteamid(userid)
    info = popuplib.easymenu(str(steamid) + 'tpto', None, tp_menu_select)
    info.settitle("Teleport menu\nStops your timer\n\nSelect a player..")
    info.c_beginsep = " "
    info.c_pagesep = " "
    for userid_2 in es.getUseridList():
		if not es.isbot(userid_2):
			if userid == userid_2:
				name = es.getplayername(userid_2)

				info.addoption(str(userid_2), "%s" % name, False)
			else:
				name = es.getplayername(userid_2)
				info.addoption(str(userid_2), "%s" % name)

    info.send(userid)
def checkplayer(uid):
    '''
    Checks if a player is ghosting and blinds them if so (does not test bots)
    '''
    if not es.isbot(uid):
        if str(uid).isdigit():
            uid = int(uid)
        else:
            return False
        plist = es.createplayerlist()
        if uid not in plist:
            return False
        uip = plist[uid]["address"]
        for userid in plist:
            if not userid == int(uid) and plist[userid]["address"] == uip:
                return True
    return False
Exemple #33
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)
def checkplayer(uid):
    '''
    Checks if a player is ghosting and blinds them if so (does not test bots)
    '''
    if not es.isbot(uid):
        if str(uid).isdigit():
            uid = int(uid)
        else:
            return False
        plist = es.createplayerlist()
        if uid not in plist:
            return False
        uip   = plist[uid]["address"]   
        for userid in plist:
            if not userid == int(uid) and plist[userid]["address"]== uip: 
                return True
    return False
Exemple #35
0
def player_spawn(event_var):
    '''Called any time a player spawns'''

    userid = int(event_var['userid'])

    # Is a spectator?
    if int(event_var['es_userteam']) < 2:
        return

    # Is player dead?
    if getPlayer(userid).isdead:
        return

    ggPlayer = Player(userid)

    # Do we need to give the player a defuser?
    if int(gg_player_defuser):

        # Is the player a CT?
        if int(event_var['es_userteam']) == 3:

            # Are we removing bomb objectives from map?
            if not int(gg_map_obj) in (1, 2):

                # Does the map have a bombsite?
                if len(es.getEntityIndexes('func_bomb_target')):

                    # Does the player already have a defuser?
                    if not getPlayer(userid).defuser:

                        # Give the player a defuser:
                        getPlayer(userid).defuser = 1

    # Strip bots (sometimes they keep previous weapons)
    if es.isbot(userid):
        delayed(0.25, give_weapon_check, (userid))
        delayed(0.35, ggPlayer.strip)

    # Player is human
    else:
        # Reset AFK
        delayed(0.60, ggPlayer.afk.reset)

        # Give the player their weapon
        delayed(0.05, give_weapon_check, (userid))
Exemple #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)
Exemple #37
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)
Exemple #38
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)
Exemple #39
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)
def player_jump(ev):
    userid = ev["userid"]
    steamid = es.getplayersteamid(userid)
    if not es.isbot(userid):
        analysis[steamid]["view_angle_0"] = []
        analysis[steamid]["view_angle_1"] = []
        analysis[steamid]["velocity"] = []
        velocity = int(
            vector(
                float(
                    es.getplayerprop(
                        userid, 'CBasePlayer.localdata.m_vecVelocity[0]')),
                float(
                    es.getplayerprop(
                        userid,
                        'CBasePlayer.localdata.m_vecVelocity[1]'))).length())

        analysis[steamid]["velocity"].append(velocity)
def Request_Spectate(Userid):
	global Kicked_Bots,Spec,Zombies,Survivors
	if es.exists('userid',Userid):
		if es.isbot(Userid):
			name = es.getplayername(Userid)
			es.server.queuecmd("tf_bot_kick %s"%name)
			Kicked_Bots += 1 
			Msg("%s Moved to [Bot Spectator]."%name)
		else:
			if Userid in Zombies:
				Zombies.remove(Userid)
			if Userid in Survivors:
				Survivors.remove(Userid)
			if Userid not in Spec:
				Spec.append(Userid)
			es.changeteam(Userid,1)
	else:
		Request_ClearData(Userid)
Exemple #42
0
    def send_winner_messages(self):
        '''Sends Winner Messages to all players'''

        # Store a team player's index
        index = self.index

        # Is there an index?
        if index is None:

            # If not, return
            return

        # Store the team's color
        color = self.color

        # Loop through all players on the server
        for userid in getUseridList():

            # Is the current player a bot?
            if isbot(userid):

                # Do not send messages to bots
                continue

            # Get the player's Player() instance
            ggPlayer = Player(userid)

            # Get the team's name
            teamname = langstring(self.teamname, userid=userid)

            # Send chat message for team winning the match
            ggPlayer.saytext2(
                index, 'TeamWork_Winner', {'teamname': teamname}, True)

            # We want to loop, so we send a message every second for 3 seconds
            for x in xrange(4):

                # Send centermsg about the winner
                delayed(x, ggPlayer.centermsg,
                    ('TeamWork_Winner_Center', {'teamname': teamname}))

            # Send toptext message about the winner
            ggPlayer.toptext(10, color,
                'TeamWork_Winner_Center', {'teamname': teamname})
def Request_TeamUpdate():
	#Lets move the players to their respecive teams.
	#1 = Spectator, 2 = Infected, 3 = Survivors 
	global Zombies,Survivors,Spec,Grace
		
	for Userid in Zombies:
		if es.exists('userid',Userid):
			if es.getplayerteam(Userid) != 2:
				es.changeteam(Userid,2)
		else:
			Zombies.remove(Userid)

	for Userid in Survivors:
		if es.exists('userid',Userid):
			if es.getplayerteam(Userid) != 3:
				es.changeteam(Userid,3)
		else:
			Survivors.remove(Userid)

	for Userid in Spec:
		if es.exists('userid',Userid):
			if es.getplayerteam(Userid) != 1:
				es.changeteam(Userid,1)
		else:
			Spec.remove(Userid)


	if es.getplayercount() > 1 and not Grace:
		if int(es.getplayercount(2)) == 0:
			es.server.queuecmd("sv_cheats 1")
			es.server.queuecmd("mp_forcewin 3")
			gamethread.delayed(.2,es.server.queuecmd,("sv_cheats 0"))

		if int(es.getplayercount(3)) == 0:
			es.server.queuecmd("sv_cheats 1")
			es.server.queuecmd("mp_forcewin 2")
			gamethread.delayed(.2,es.server.queuecmd,("sv_cheats 0"))
	elif es.getplayercount() == 1:
		if not es.isbot(es.getUseridList()[0]):
			es.server.queuecmd("tf_bot_add")
			es.server.queuecmd("tf_bot_add")
			Msg("Well this looks boring, lets throw some bots in.")
Exemple #44
0
def _select_target(userid, choice, popupid):
    if userid not in admins:
        return
    if choice == "player":
        giveplayermenu = popuplib.construct("giveplayermenu", "players", "#alive")
        giveplayermenu.settitle(xalanguage["choose player"])
        giveplayermenu.menuselectfb = _select_player
        giveplayermenu.send(userid)
    else:
        if choice == "team3":
            playerlist = filter(lambda x: es.getplayerteam(x) == 3, es.getUseridList())
        elif choice == "team2":
            playerlist = filter(lambda x: es.getplayerteam(x) == 2, es.getUseridList())
        elif choice == "bots":
            playerlist = filter(lambda x: es.isbot(x), es.getUseridList())
        elif choice == "all":
            playerlist = es.getUseridList()
        playerlist = filter(lambda x: not es.getplayerprop(x, 'CBasePlayer.pl.deadflag'), playerlist)
        for player in playerlist:
            giveObject(userid, player)
Exemple #45
0
def player_spawn(event_var):
    # Check for priority addons
    if PriorityAddon:
        return

    # Is a spectator?
    if int(event_var['es_userteam']) < 2:
        return

    # Set the player id
    userid = int(event_var['userid'])

    # Is player dead?
    if es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'):
        return

    # Is the player a bot?
    if not es.isbot(userid):

        # Send the player their level info
        send_level_info_hudhint(Player(userid))
Exemple #46
0
def player_disconnect(ev):
    if ev['userid'] in newconnected:
        newconnected.remove(ev['userid'])
        if ev['userid'] in pending:
            pending.remove(ev['userid'])
        return
    if not es.isbot(ev['userid']):
        dbg( 'player disconnected: %s' % ev['userid'])
        dbg( 'finnishing player session')
        steamid = ev['networkid']
        if not steamid in players:
            return
        players.update(steamid,'lastseen',time.time())
        players.add(steamid,'time',time.time() - players.query(steamid,'sessionstart'))
        cteam = players.query(steamid,'current_team')
        if not str(cteam) == '0':
            players.add(steamid,'team_' + str(cteam) + '_time',time.time() - players.query(steamid,'teamchange_time'))
        players.update(steamid,'teamchange_time',time.time())
        players.update(steamid,'current_team',0)
        for method in methods.keys():
            toplist.update(steamid,method,methods[method](players,steamid))
Exemple #47
0
def player_spawn(event_var):
    # Check for priority addons
    if PriorityAddon:
        return

    # Is a spectator?
    if int(event_var['es_userteam']) < 2:
        return

    # Set the player id
    userid = int(event_var['userid'])

    # Is player dead?
    if es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'):
        return

    # Is the player a bot?
    if not es.isbot(userid):

        # Send the player their level info
        send_level_info_hudhint(Player(userid))
Exemple #48
0
    def send_winner_messages(self):
        '''Sends Winner Messages to all players'''

        # Store a team player's index
        index = self.index

        # Store the team's color
        color = self.color

        # Loop through all players on the server
        for userid in getUseridList():

            # Is the current player a bot?
            if isbot(userid):

                # Do not send messages to bots
                continue

            # Get the player's Player() instance
            ggPlayer = Player(userid)

            # Get the team's name
            teamname = langstring(self.teamname, userid=userid)

            # Send chat message for team winning the match
            ggPlayer.saytext2(index, 'TeamPlay_Winner', {'teamname': teamname},
                              True)

            # We want to loop, so we send a message every second for 3 seconds
            for x in xrange(4):

                # Send centermsg about the winner
                delayed(x, ggPlayer.centermsg, ('TeamPlay_Winner_Center', {
                    'teamname': teamname
                }))

            # Send toptext message about the winner
            ggPlayer.toptext(10, color, 'TeamPlay_Winner_Center',
                             {'teamname': teamname})
def Serverloop():
    for userid in es.getUseridList():
        if not es.isbot(userid):
            steamid = es.getplayersteamid(userid)
            player = playerlib.getPlayer(userid)
            if not player.isdead:
                if not player.onGround():
                    analysis[steamid]['onground'] = 0
                    analysis[steamid]['msg'] = 1
                    if time.time() - analysis[steamid]['time'] > 1.8:
                        Average(userid)

                else:
                    analysis[steamid]['onground'] = 1
                    if analysis[steamid]['msg'] == 1:
                        Average(userid)
                    analysis[steamid]['msg'] = 0
                    analysis[steamid]['location'] = es.getplayerlocation(
                        userid)
                    analysis[steamid]['time'] = time.time()

    gamethread.delayedname(0.01, "server_loop", Serverloop)
Exemple #50
0
    def give_warmup_weapon(self, userid):
        '''Gives the player the warmup weapon'''

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

            # If not, no need to give them a weapon
            return

        # Is the player on a team?
        if es.getplayerteam(userid) < 2:

            # If not, no need to give them a weapon
            return

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

            # If not, no need to give them a weapon
            return

        # Get the player's Player instance
        ggPlayer = Player(userid)

        # Set the delay time
        delay = 0.05

        # Is the player a bot?
        if es.isbot(userid):

            # Increase bot delay to make sure they get the proper weapon
            delay += 0.2

        # Strip the player's weapons (split second delay)
        delayed(delay, ggPlayer.strip, (True, [warmup_weapon]))

        # Give the player the Warmup Weapon
        delayed(delay, ggPlayer.give, (self.weapon, True, True))
Exemple #51
0
def keyHint(users, message):
    '''Send a KeyHintText message to the given player...'''
    
    # Create the UserMessage...
    es.usermsg('create', 'keyhint', 'KeyHintText')
    
    # Write the message to it...
    es.usermsg('write', 'byte', 'keyhint', 1)
    es.usermsg('write', 'string', 'keyhint', message)
    
    # Loop through all matching players...
    for userid in _get_matching_players(users):
        
        # Is the player a bot?
        if es.isbot(userid):
            
            # Don't go further...
            continue
            
        # Send the message...
        es.usermsg('send', 'keyhint', userid)
        
    # Finaly, delete the message from memory...
    es.usermsg('delete', 'keyhint')
Exemple #52
0
def drug(users, lifetime=0):
    '''Drug a player for the given time...'''
    
    # Loop through all matching players...
    for userid in _get_matching_players(users):
        
        # Is the player a bot?
        if es.isbot(userid):
            
            # Don't go further...
            continue
            
        # Drug the player...
        es.cexec(userid, 'r_screenoverlay effects/tp_eyefx/tp_eyefx')
        
        # Is there any time given?
        if not lifetime:
            
            # Don't go further...
            continue
            
        # Undrug the player after the given time...
        gamethread.delayedname(
            lifetime, '_wcs_delay', es.cexec, (userid, 'r_screenoverlay off'))
    def update(self):
        timer = es.import_addon('trikztimer/plugins/timer')
        """
        Update the player's message showing his targets ranks.
        """
        if not es.exists('userid', self.userid):
            return

        #if not es.exists('userid', self.target):
        #   return

        if es.getplayerteam(self.userid) in (2, 3):
            if not playerlib.getPlayer(self.userid).isdead:
                Player(self.userid).delspec(self.userid, self.target, 1)
                return

        target = self.getspec()
        if target != -1:

            self.target = target

            steamid = es.getplayersteamid(self.target)
            name = es.getplayername(self.target)
            # PARTNER TIMER

            velocity = round(
                vector(
                    float(
                        es.getplayerprop(
                            self.target,
                            'CBasePlayer.localdata.m_vecVelocity[0]')),
                    float(
                        es.getplayerprop(
                            self.target,
                            'CBasePlayer.localdata.m_vecVelocity[1]'))).length(
                            ), 2)

            Player(self.userid).addspec(self.userid, self.target)

            Player(self.userid).delspec(self.userid, self.target, 2)

            specs[self.userid]["last_spec"] = self.target

            if steamid in timer.player:
                string = timer.player[steamid]["text_display"]
                if timer.CheckPartner(self.target):
                    string += "\n(Partnered)"
                else:
                    string += "\n(Solo)"

                timer.player[steamid]['spectators'] = specs[self.target]['n']

            if not es.isbot(target):
                hudhint(self.userid,
                        "- %s -\nVel: %s\n%s" % (name, velocity, string))

            name_list = ""
            if len(specs[self.target]['n']) > 0:
                for object in specs[self.target]['n']:
                    s_name = str(es.getplayername(object))
                    if len(s_name) > 12:
                        s_name = str(es.getplayername(object))[0:12] + "..."
                    name_list += "\n" + s_name

            if timer.tournament["status"] == 0:
                keyhint(
                    self.userid, "%s's Spectators: %s\n%s" %
                    (name, len(specs[self.target]['n']), name_list))
            else:
                string = ""
                string += "-- Tournament Mode --\n "
                if timer.tournament["turn"] in timer.tournament["queue"] > 0:
                    turn = timer.tournament["turn"]
                    string += "\n %s | %s is playing..\n \n Next couple in: %s \n \n \n" % (
                        timer.tournament["queue"][turn][0]["name"],
                        timer.tournament["queue"][turn][1]["name"],
                        timer.TimeFormat(timer.tournament["time"], None, True))
                else:
                    string += "\nNo teams available yet!\n \n"

                keyhint(
                    self.userid, "Spectators: %s\n%s" %
                    (string, name, len(specs[self.target]['n']), name_list))

        else:
            Player(self.userid).delspec(self.userid, self.target, 2)
Exemple #54
0
def pending():
	for userid in es.getUseridList():
		if not es.isbot(userid):
			status = popuplib.active(userid)
			if status['count'] >= 3:
				popuplib.close(status['name'], userid)
Exemple #55
0
def func_isbot(args):
    temp = '0'
    temp = str(es.isbot(args[0]))
    return temp