Shortest Distance
#2

Put them all in an array instead of single variables, then you can use this function to get the index of the shortest distance (just writing it, cant guarantee for it to be bug-free )

pawn Code:
stock GetSmallestIndex(v[], len = sizeof(v))
{
    new min_index, min_value = -1;
    for(new i = 0; i < len; i ++)
    {
        if(v[i] < min_value || minvalue == -1)
        {
            min_index = i;
            min_value = v[i];
        }
    }
    return min_index;
}

// Use it like this then:
new values[8];
values[0] = GetPlayerDistance...

switch(GetSmallestIndex(values))
{
    case 0: MissionFortC(playerid); break;
    case 1: //...
}
Reply


Messages In This Thread
Shortest Distance - by Rokzlive - 21.03.2011, 19:54
Re: Shortest Distance - by Mauzen - 21.03.2011, 21:32
Re: Shortest Distance - by Rokzlive - 23.03.2011, 02:08

Forum Jump:


Users browsing this thread: 1 Guest(s)