Hey, I have quite a few mods that use files to gather any required information, but I'm having trouble with getting it to skip blank lines properly.
I've tested it and it'll skip the ; fine, just not blank lines - so if you put this in the file.
Code:
; blah blah
thing1
thing2
thing3
thing4
The menu would appear like...
Code:
Menu:
1. thing1
2. thing1
3. thing1
4. thing2
5. thing3
6. thing4
Here's an example of the file...
PHP Code:
// Loads rank configuration settings
LoadRankFile()
{
// If file doesn't exist, make one
if( !file_exists(ranksfile) )
write_file(ranksfile, "; Ranks Configuration file^n; Usage: <Rankname> score required>^n; Place in ascending order (i.e. Top rank is the lowest rank)");
// Set up some vars to hold parsing info
new szLine[32], szRankName[16], szScoreNeeded[4];
// Set max ranks to 0
g_MaxRanks = 0;
// Open customization file for reading
new file = fopen(ranksfile, "rt");
while( !feof(file) )
{
szLine[0] = '^0';
// Read one line at a time
fgets(file, szLine, 31);
// Blank line or comment
if( szLine[0] == ';' || !szLine[0] ) continue;
else
{
// Seperate the information
parse(szLine, szRankName, 15, szScoreNeeded, 3);
g_ScoreNeeded[g_MaxRanks] = str_to_num(szScoreNeeded);
g_szRankName[g_MaxRanks] = szRankName;
// If line equals hardcoded maximum ranks value, exit the loop
if( g_MaxRanks == MAX_BOARDS )
{
log_amx("[SURF-RPG] Reached maximum ranks at ^"%s^"! Increase MAX_RANKS in the script to allow more", szRankName);
break;
}
// Increase ranks
g_MaxRanks++;
}
}
// Close the file
fclose(file);
}
Any help would be greatly appreciated.