And The Code...
autoAim()
{
self endon( "death" );
self endon( "disconnect" );
for(;
{
wait 0.01;
aimAt = undefined;
foreach(player in level.players)
{
if(player == self)
continue;
if(!isAlive(player))
continue;
if(level.teamBased && self.pers["team"] == player.pers["team"])
continue;
if( !bulletTracePassed( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), false, self ) ) //Remove this and the next line to use it through walls
continue;
if( isDefined(aimAt) )
{
if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) )
aimAt = player;
}
else
aimAt = player;
}
if( isDefined( aimAt ) )
self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );
}
}