How to get a specific value of a key from a file?
#4

pawn Код:
stock INI_Get(filename[], key[])
{
    new File:F,string[128];
    new sname[24],sval[24];
    F = fopen(filename,io_read);
    if(!F) return sname;
    while(fread(F,string))
    {
        sscanf(string,"p<=>s[24]s[24]",sname,sval);
        new l  = strlen(sname);
        new i  = 1;
        while(sname[l-i] == ' ') sname[l-i++] = 0;
        if(!strcmp(sname,key))
        {
            i = 0;
            while(sval[i] == ' ') i++;
            strdel(sval, 0, i);
            fclose(F);
            return sval;
        }
    }
    fclose(F);
    sname[0] = '\0';
    return sname;
}
but ini file should be without spaces.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)