int ClosestID = -1;
int how_ClosestID = m_pClient->m_Tuning[g_Config.m_ClDummy].m_HookLength;
int my_x = m_pClient->m_Snap.m_pLocalCharacter->m_X;
int my_y = m_pClient->m_Snap.m_pLocalCharacter->m_Y;
int LocalID = m_pClient->m_Snap.m_LocalClientID;
vec2 WallPos;
template<typename T>
inline T distance(const vector2_base<T> a, const vector2_base<T> &b)
{
return length(a-b);
}
for (int i = 0; i < MAX_CLIENTS; i++)
{
if (LocalID != i) // Skip our ClientID
{
vec2 MyPos = m_pClient->m_aClients[LocalID].m_Predicted.m_Pos + m_pClient->m_aClients[LocalID].m_Predicted.m_Vel;
CCharacterCore Player = m_pClient->m_aClients[i].m_Predicted;
vec2 EnemyPos = m_pClient->m_aClients[i].m_Predicted.m_Pos + m_pClient->m_aClients[i].m_Predicted.m_Vel;
int dist = distance(vec2(my_x, my_y), vec2(EnemyPos.x, EnemyPos.y));
if (how_ClosestID > dist)
{
ClosestID = i; // Saving the ClosestPlayer's ID
how_ClosestID = dist;
}
}
}
// THIS IS A 2D GAME BY THE WAY
What im trying to achieve at the moment is to grab the Farthest playersID