Hello Guys,
I'll hope someone of the AMXMODX Heros can help me.
Following, i'm learning amxmodx and at the moment i'm trying to get 2 vars out of a txt file, (mymaps.txt)
Following is inside:
Code:
mario_air "\minplayers\5\maxplayers\32\"
mario_land "\minplayers\4\maxplayers\32\"
mario_world "\minplayers\8\maxplayers\32\"
mario_xmas "\minplayers\4\maxplayers\32\"
My Problem is now that i need the the two numbers:
"\minplayers\
5\maxplayers\
32\"
The Code-Part for it: (mapchooser like)
Code:
new fp=fopen(filename,"r");
while (!feof(fp))
{
buff[0]='^0';
fgets(fp, buff, charsof(buff));
parse(buff, szText, charsof(szText));
if (szText[0] != ';' &&
ValidMap(szText) &&
!equali(szText, g_lastMap) &&
!equali(szText, currentMap))
{
ArrayPushString(g_mapName, szText);
++g_mapNums;
}
}
fclose(fp);
The ValidMap() is at the moment the standard of mapchooser.amxx
Code:
stock bool:ValidMap(mapname[])
{
if ( is_map_valid(mapname) )
{
return true;
}
// If the is_map_valid check failed, check the end of the string
new len = strlen(mapname) - 4;
// The mapname was too short to possibly house the .bsp extension
if (len < 0)
{
return false;
}
// HERE SHOULD MY ADDING GOES.....
if (-------------------)
{
return false;
}
if ( equali(mapname[len], ".bsp") )
{
// If the ending was .bsp, then cut it off.
// the string is byref'ed, so this copies back to the loaded text.
mapname[len] = '^0';
// recheck
if ( is_map_valid(mapname) )
{
return true;
}
}
return false;
}
Above i comment the Part where the code should go.
mapname[len] contains the whole part of the line i hope, so how i can get these two numbers out of mapname[len]?
I realy hope someone can helps me out!
(Sorry for my broken english, ill do my best)
//// ADDED:
Aye..., may i should say what i want to "if" too...
The first Number (minplayers) should go with if(get_playersnum() >= minplayers && maxplayers >= get_playersnum())...
Like this!
Greetings