Tag mismatch
#1

Hi guys, I have some mismatches on codes I recently found on this website.

pawn Код:
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
}
Reply
#2

it should be
Quote:
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;
}

Reply
#3

Thank you BroZeus!

I am still getting mismatches at this line

pawn Код:
tempdist = GetDistanceBetween(x, y, z, FirmaInfo[i][EXTX], FirmaInfo[i][EXTY], FirmaInfo[i][EXTZ]);
Reply
#4

Make "EXTX," where you defined it as "Float:EXTX", make it for EXTY and EXTZ too
Reply
#5

Already have it that way in enum...

pawn Код:
Float:EXTX,
Float:EXTY,
Float:EXTZ,
Reply
#6

Fixed mismatches!

Solution:

pawn Код:
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)