[HELP] Please edit the code for me (sorting function) - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Please edit the code for me (sorting function) (
/showthread.php?tid=217994)
[HELP] Please edit the code for me (sorting function) -
DJ-CJ89 - 29.01.2011
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); \
} \
} \
}
Re: [HELP] Please edit the code for me (sorting function) -
legodude - 29.01.2011
what is it supposed to do.. i don't get it..
AW: [HELP] Please edit the code for me (sorting function) -
DJ-CJ89 - 29.01.2011
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.
Re: [HELP] Please edit the code for me (sorting function) -
Lorenc_ - 29.01.2011
Try creating it without a macro.
AW: [HELP] Please edit the code for me (sorting function) -
DJ-CJ89 - 29.01.2011
nothing works

. Does someone have a better function for that?
Get and sort the ten closest Players
Re: [HELP] Please edit the code for me (sorting function) -
ricardo178 - 29.01.2011
Oh, thats too smart for me!