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

WolfieBlood

Veteran
Messages
3
Reaction score
0
Points
776
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,322
Reaction score
752
Points
973
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

Veteran
Messages
3
Reaction score
0
Points
776
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