20.04.2013, 20:00
(
Последний раз редактировалось thefatshizms; 20.04.2013 в 21:29.
)
pawn Код:
stock INI_GetInt(INI:filehandle, Key[], &dest) {
if(!filehandle) return printf("Failed to open file!");
new pos, line[MAX_FILE_STRING], temp[MAX_FILE_STRING];
while( fread(filehandle, line) ) {
if( (pos = strfind(line, Key)) != -1 ) {//it's found the key
new idx = pos + strlen(Key)+1;
strmid(temp, line[pos], 0, idx);
if(!strcmp(temp[idx], " ", true)) {//if there is a space the strings won't match later on
strmid(temp, line, 0, idx-1);
}
if(!strcmp(temp, Key, true)) {//If there is something like Score and PlayersScore strfind won't work
if(line[idx] == '=') {//the value is a assignment
idx = pos + strlen(Key) + 2;//if the = sign is further across
return dest = (idx < sizeof(line)) ? strval(line[idx]) : 0;
}
}
}
}
return 1;
}
Код:
scores=5 score=5