27/02/2023 08:40
Dá uma olhada nesse código e adapte para você:
Código PHP:
stock ReturnNearestATM(playerid)
{
new
Float:x,
Float:y,
Float:z,
Float:distance = 999999.999,
id = -1;
for(new i = 1; i < MAX_ATMS; i++) if(AtmInfo[i][atmExists])
{
x = AtmInfo[i][atmPos][0];
y = AtmInfo[i][atmPos][1];
z = AtmInfo[i][atmPos][2];
if(GetPlayerDistanceFromPoint(playerid, x, y, z) < distance)
{
distance = GetPlayerDistanceFromPoint(playerid, x, y, z);
id = i;
}
}
return id;
}