int BestTarget = -1; // Save the entity index here, after you choose the best one. if (BestTarget == -1) FindTarget(); // Find the best entity based on distance, fov, whatever and save the index of it into BestTarget if (BestTarget != -1) AimAtTarget(); // If we have found a target, aim at it! if (!IsEntityValid(BestTarget)) // Do your checks here - is alive, not dormant, is enemy, etc. if the entity is not valid anymore, BestTarget = -1; // set BestTarget to -1 so the aimbot searches for a new target
