28.09.2016, 21:33
So I am scripting the Trucker job and erm, I wanted to detect if the coordinates for the delivery is close to San Fierro or Los Santos.
For instance, The coordinates are set to Commerence, It will automatically detect that it's in Los Santos and if it is set to Downtown San Fierro, It will automatically detect that it's in San Fierro. If the coordinates are located in a county-side, It will get the closest city in distance.
I have an idea though, I will get the coordinates for LS/SF and then use this function to do it.
Though I am clueless on how am I gonna do it.
For instance, The coordinates are set to Commerence, It will automatically detect that it's in Los Santos and if it is set to Downtown San Fierro, It will automatically detect that it's in San Fierro. If the coordinates are located in a county-side, It will get the closest city in distance.
I have an idea though, I will get the coordinates for LS/SF and then use this function to do it.
PHP код:
// From SCRP
stock GetClosestHospital(playerid)
{
new
Float:fDistance[2] = {99999.0, 0.0},
iIndex = -1
;
for (new i = 0; i < sizeof(arrHospitalSpawns); i ++)
{
fDistance[1] = GetPlayerDistanceFromPoint(playerid, arrHospitalSpawns[i][0], arrHospitalSpawns[i][1], arrHospitalSpawns[i][2]);
if (fDistance[1] < fDistance[0])
{
fDistance[0] = fDistance[1];
iIndex = i;
}
}
return iIndex;
}