18.02.2012, 15:06
pawn Код:
stock strCharSplit(const strings[], &index)
{
new result[20], i = 0;
if(index != 0 && strings[index] != '\0') index++;
while(strings[index] && strings[index] != ' ')
{
result[i++] = strings[index++];
}
return result;
}
pawn Код:
stock strtok(const strings[], &index)
{
new length = strlen(strings);
while ((index < length) && (strings[index] <= ' ')) index++;
new offset = index;
new result[20];
while ((index < length) && (strings[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = strings[index];
index++;
}
result[index - offset] = EOS;
return result;
}
срабатывает строка
Error: Line%d - 404 %s.race
Пример
pawn Код:
stock LoadRaceList()
{
if(fexist("Logs/racenames.cfg"))
{
new File:file = fopen("Logs/racenames.cfg", io_read);
new line[20];
while(fread(file, line, sizeof(line), false))
{
new iidx;
RaceNames[countrace] = strCharSplit(line, iidx);
new trackname[13+32];
format(trackname, sizeof(trackname), "Logs/%s.race",RaceNames[countrace]);
if(fexist(trackname))
{
//printf("Race%d - %s.race",countrace,RaceNames[countrace]);
}
else printf("Error: Line%d - 404 %s.race", countrace, RaceNames[countrace]);
countrace++;
}
fclose(file);
}
}