28.12.2009, 18:33
I use this loop to loop through players in race, so I edited the loop for you. ![afro](images/smilies/mrgreen.gif)
if you're going to make a repeating timer to loop, you must make ObjectPos a
global variable, otherwise it can be in the function, where you loop.
(Note: Its not tested)
![afro](images/smilies/mrgreen.gif)
if you're going to make a repeating timer to loop, you must make ObjectPos a
global variable, otherwise it can be in the function, where you loop.
pawn Код:
new ObjectPos[MAX_OBJECTS] = { MAX_OBJECTS, ... };
new Float:odis[MAX_OBJECTS];
new Float:sdis[10] = { 30000.00, ... };
for(new i; i < MAX_OBJECTS; i++)
{
odis[i] = GetObjectDistance(...);
for(new j; j < 10; j++)
{
if(odis[i] < sdis[j])
{
for(new o = ObjectPos[i]; o > j; o--)
{
sdis[o] = sdis[o-1];
ObjectPos[o] = ObjectPos[o-1];
}
ObjectPos[i] = j;
sdis[j] = odis[i];
break;
}
}
}