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

Hi, I've just found that function but it's not working.
Can someone fix it?
PHP код:
stock INI_Get(filename[], key[])
{
    new 
File:F,string[128];
    new 
sname[24],sval[24];
    
fopen(filename,io_read);
    if(!
F) return sname;
    while(
fread(F,string))
    {
        
sscanf(string,"p<=>s[24]s[24]",sname,sval);
        if(!
strcmp(sname,key))
        {
            
sval[strlen(sval)-2] = 0;
            
fclose(F);
            return 
sval;
        }
    }
    
fclose(F);
    
sname[0] = '\0';
    return 
sname;

PHP код:
stock INI_GetValue(filename[], key[])
{
    return 
strval(INI_Get(filenamekey));

For example I do:

PHP код:
if(fexist("text.txt"))
    {
        
printf("%d"INI_GetValue("text.txt""Skills"));
    }
    else
    {
        print(
"File does not exist");
    } 
It doesn't work. Can someone help me? I really need that function.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)