Did you add checking at the "END OF MAP" yourself? Because original version does it at the beginning of the map.
I added checking for min and max players in a lot simpler way (just need to add "#min max" in maps file and maps in following lines will only be used iif ( min <= players amount <= max )):
PHP Code:
new szText[32], szTmp[32]
new currentMap[32]
new min=0, max=get_maxplayers(), pnum=0
new buff[256];
for(new i=1; i<=max; i++)
if((is_user_connecting(i) || is_user_connected(i)) && !is_user_hltv(i) && !is_user_bot(i))
pnum++
get_mapname(currentMap, 31)
new fp=fopen(filename,"r");
ArrayClear(g_mapName);
while (!feof(fp))
{
buff[0]='^0';
szText[0]='^0';
szTmp[0]='^0';
fgets(fp, buff, charsof(buff));
parse(buff, szText, charsof(szText), szTmp, charsof(szTmp));
if(szText[0] == '#')
{
min = str_to_num(szText[1])
max = str_to_num(szTmp)
continue
}
if(min>pnum || max<pnum)
continue
if (szText[0] != ';' &&
ValidMap(szText) &&
!equali(szText, g_lastMap) &&
!equali(szText, currentMap))
{
ArrayPushString(g_mapName, szText);
++g_mapNums;
}
}
example maps file:
Code:
#1 15
dod_anzio
dod_avalanche
#3 4
dod_forest
dod_glider
dod_jagd
dod_kalt
#0 3
dod_vicenza
dod_zalec
__________________