First, some indentation would help, I guess. Then, there's no need to store all distances. You can keep track of the minimum distance encountered so far, like this:
int client::closestEnemy()
{
int index = -1;
float minDistance;
for(u32 i = 0; i<12; i++) {
if(p[i].exist() || p[i].alive() || p[i].team() != 3 || i != s.index) {
float distance = vec.distance(*pos(), *p[i].pos());
if (index == -1 || distance < minDistance) {
index = i;
minDistance = distance;
}
}
}
return index;
}