[HELP] Please edit the code for me (sorting function)
#1

This function sorts the playerids from nearest to fahrest position from a specific playerid.

Код:
//sort
#define SortIDs(%1,%2); \
    for(new c, l, v; c < sizeof %2; c++) { \
        for(l = 1, v = 0; l < sizeof %1; l++) \
            if(%1[l] < %1[v]) v = l; \
        %2[c] = v, %1[v] = (Float:0x7F800000); \
    }
Please edit this function for me in that way, that it continues the loop, when %1 is -1


I tried this but it didnt work:

Код:
#define SortIDs(%1,%2);	\
for(new c, l, v; c < sizeof %2; c++) \
{ \
	for(l = 1, v = 0; l < sizeof %1; l++) \
	{	\
		if(%1[c] == -1) \
		{ \
			%2[c] = -1; \
			continue; \
		} \
		if(%1[l] < %1[v]) v = l; \
		{ \
			%2[c] = v, %1[v] = (Float:0x7F800000); \
		} \
    } \
}
Reply
#2

what is it supposed to do.. i don't get it..
Reply
#3

first I store the 10 nearest players and their distances to a specific player into an Array.

new Pdistance[10], Pclosest[10]; etc, etc.

Now I need the sort function to sort the nearest Player to Pclosest[0] ...... second nearest to pclosest[1].....etcetc.......the farthest to Pclosest[9].

so I use sortIDs(pdistance,pclosest);

The function works well but I need this edit because I found a little bug in it.
Reply
#4

Try creating it without a macro.
Reply
#5

nothing works . Does someone have a better function for that?

Get and sort the ten closest Players
Reply
#6

Oh, thats too smart for me!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)