Does your script have a enum or variable/float to store where the house doors X, Y, Z is? If not make one then you could use some a function to compare the distances between each of the houses and return the closest house.
http://forum.sa-mp.com/showthread.ph...light=Distance
pawn Код:
public GetClosestHouse(playerid, Float:Distance = 1000.0)
{
Distance = floatabs(Distance);
if(!Distance Distance = 1000.0;
new
Float:X[2],
Float:Y[2],
Float:Z[2],
Float:NearestPos = Distance,
NearestHouse;
GetPlayerPos(playerid, X[0], Y[0], Z[0]);
foreach(house, i)
{
X[1] = Houses[i][hExteriorX]
Y[1] = Houses[i][hExteriorY]
if(NearestPos > PointToPoint2D(X[0], Y[0], X[1], Y[1])) NearestPos = PointToPoint(X[0], Y[0], X[1], Y[1])), NearestHouse = i;
}
return i;
}
return -255;
}
Based on
https://sampforum.blast.hk/showthread.php?tid=125880