14.03.2011, 16:42
Ok so..
I've created a /work cmd that creates a checkpoint at the nearest shop..
this is at my cmd:
and that's the stock:
however it always creates the checkpoint at the first coordinate in my "WorkingStation" list...
what's wrong?
I've created a /work cmd that creates a checkpoint at the nearest shop..
this is at my cmd:
pawn Код:
for(new n=0; n<sizeof(WorkStations); n++)
{
number++;
x = WorkStations[n][0];
y = WorkStations[n][1];
z = WorkStations[n][2];
cdist = GetDistanceToPoint(playerid, x, y, z);
if(number == 0)
{
distance = cdist;
nearest = n;
}
else if(distance > cdist)
{
distance = cdist;
nearest = n;
}
}
pawn Код:
const Float:INF_FLOAT=Float:0x7F800000;
stock Float:GetDistanceBetweenPoints(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2)
{
return floatadd(floatadd(floatsqroot(floatpower(floatsub(x1,x2),2)),floatsqroot(floatpower(floatsub(y1,y2),2))),floatsqroot(floatpower(floatsub(z1,z2),2)));
}
stock Float:GetDistanceToPoint(playerid,Float:x1,Float:y1,Float:z1)
{
if (IsPlayerConnected(playerid))
{
new Float:x2,Float:y2,Float:z2;
GetPlayerPos(playerid,x2,y2,z2);
return GetDistanceBetweenPoints(x1,y1,z1,x2,y2,z2);
}
return INF_FLOAT;
}
what's wrong?