Answered BO2 GSC Function to check if player is aiming at player?

WolfieBlood

Known Member
Messages
3
Points
101
Is there a way to know or do something if a player is aiming at you? Like on offhost menus you can have the option for it to say who's aiming at you
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,299
Points
548
Code:
aimCheck()
{
    if(!isDefined( self.aimCheck ))
    {
        self.aimCheck = true;
        while(isDefined( self.aimCheck ))
        {
            for(c=0;c<getPlayers().size;c++)
            {
                player = getPlayers()[c];
                if( player != self && player isRealistic( self ) )
                    self iprintln( player getName() + " is looking at you" ); //replace with a hud element.
            }
            wait .05;
        }
    }
    else
    {
        self.aimCheck = undefined;
    }
}

isRealistic( player )
{
    gAngles = self getPlayerAngles();
    need2face = vectorToAngles( player getTagOrigin("j_mainroot") - self getTagOrigin("j_mainroot") );
    aimDistance = length( need2face - gAngles );
    if( bulletTracePassed( self getTagOrigin("j_mainroot"), player getTagOrigin("j_mainroot"), 0, self ) && aimDistance < 25 )
        return true;
    else
        return false;
}
 

WolfieBlood

Known Member
Messages
3
Points
101
Code:
aimCheck()
{
    if(!isDefined( self.aimCheck ))
    {
        self.aimCheck = true;
        while(isDefined( self.aimCheck ))
        {
            for(c=0;c<getPlayers().size;c++)
            {
                player = getPlayers()[c];
                if( player != self && player isRealistic( self ) )
                    self iprintln( player getName() + " is looking at you" ); //replace with a hud element.
            }
            wait .05;
        }
    }
    else
    {
        self.aimCheck = undefined;
    }
}

isRealistic( player )
{
    gAngles = self getPlayerAngles();
    need2face = vectorToAngles( player getTagOrigin("j_mainroot") - self getTagOrigin("j_mainroot") );
    aimDistance = length( need2face - gAngles );
    if( bulletTracePassed( self getTagOrigin("j_mainroot"), player getTagOrigin("j_mainroot"), 0, self ) && aimDistance < 25 )
        return true;
    else
        return false;
}
Thank you, all be sure to credit you on my menu
 
Top