NajblizaBenzinskaPumpa(playerid) // closest gas station
{
new benzaid, Float:distance = 99999.0, Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new i = 0; i <MAX_FIRMI; i++)
{
if(FirmaInfo[i][Vrsta] == 1)
{
new Float:tempdist;
tempdist = GetDistanceBetween(x, y, z, FirmaInfo[i][EXTX], FirmaInfo[i][EXTY], FirmaInfo[i][EXTZ]); // I have 6 mismatches at this line
if(tempdist < distance)
{
distance = tempdist;
benzaid = i;
}
}
}
return benzaid;
}
GetDistanceBetween(x1, y1, z1, x2, y2, z2)
{
new Float:dist;
dist = floatsqroot(floatpower(floatsub(x2, x1), 2) + floatpower(floatsub( y2, y1), 2) + floatpower(floatsub( z2, z1), 2));
return dist; // mismatch
}
Float:GetDistanceBetween(x1, y1, z1, x2, y2, z2) { new Float:dist; dist = floatsqroot(floatpower(floatsub(x2, x1), 2) + floatpower(floatsub( y2, y1), 2) + floatpower(floatsub( z2, z1), 2)); return dist; } |
tempdist = GetDistanceBetween(x, y, z, FirmaInfo[i][EXTX], FirmaInfo[i][EXTY], FirmaInfo[i][EXTZ]);
Float:EXTX,
Float:EXTY,
Float:EXTZ,
forward Float:GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 );
public Float:GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 )
{
new Float:dist;
dist = floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) ) ) ;
return dist;
}