problem solved by sawce by adding #pragma dynamic 32768
i have used this script before, and it works fine. but now there is a stack error.
if i change the array_size to 3000 it will be executed.
Code:
SortCustom2D(sort,countn,"stats_custom_compare");/*countn=~4000*//*wont work*/
SortCustom2D(sort,3000,"stats_custom_compare");/*works*/
is there any way to fix it?
part of the script:
Code:
#include <amxmodx>
#include <amxmisc>
public bbrank_topx()
{
static sortn[5000][2]
new lines[256], countn, hashidlvls[32], xppntlvls[32]
new configsdirs[256], playerslvls[256]
get_configsdir(configsdirs,255)
format(playerslvls,255,"players.lvl")
new playerslvlfp=fopen(playerslvls,"r")
if(playerslvlfp)
{
while(fgets(playerslvlfp,lines,255))
{
parse(lines,hashidlvls,31,xppntlvls,31)
if(!equal(xppntlvls,""))
{
sortn[countn][0] = str_to_num(hashidlvls)
sortn[countn][1] = str_to_num(xppntlvls)
countn++
}
}
fseek(playerslvlfp,0,0)
}
SortCustom2D(sortn,countn,"stats_custom_compare");
/*[...]*/
return PLUGIN_CONTINUE
}
// our custom sorting function (check second dimension for score)
public stats_custom_compare(elem1[],elem2[])
{
if(elem1[1] > elem2[1]) return -1;
else if(elem1[1] < elem2[1]) return 1;
return 0;
}
players.lvl (~4000lines)
Code:
1177353836
18244 0.000000
45408503 0.000000
85855008 9669010.000000
184481526 111581.671875
131327360 59691.257812
190911329 31731.560547
162650882 2714077.000000
[...]
__________________