short GetNearestPlayerID()
{
actor_info* aInfo;
CVector *pos, *spos;
CPed* ped;
float distance;
float testing = 0xFFFFFFFF;
uint16_t nearestId = -1;
for (uint16_t it = 0; it < SAMP_MAX_PLAYERS; it++)
{
if (!SF->getSAMP()->getPlayers()->iIsListed[it]) continue;
if (!SF->getSAMP()->getPlayers()->IsPlayerDefined(it, true)) continue;
SF->getSAMP()->getInfo()->UpdateScoreAndPing();
aInfo = SF->getSAMP()->getPlayers()->pRemotePlayer[it]->pPlayerData->pSAMP_Actor->pGTA_Ped;
ped = GAME->GetPools()->GetPed((DWORD*)aInfo);
spos = PEDSELF->GetPosition();
pos = ped->GetPosition();
spos = PEDSELF->GetPosition();
distance = GetDistanceXYZ(pos->fX, pos->fY, pos->fZ, spos->fX, spos->fY, spos->fZ);
if (distance < 12.0) // Дистанция
{
if (distance < testing)
{
testing = distance;
nearestId = it;
}
}
}
return nearestId;
}