AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Getting argument from vars in file ( like csdm.cfg ) (https://forums.alliedmods.net/showthread.php?t=89199)

Empowers 04-03-2009 14:18

[SOLVED] Getting argument from vars in file ( like csdm.cfg )
 
I have such a line in my csdm.cfg

Code:

remove_objectives = abcd

how can I get the argument "abcd" in my plugin.. I wrote only beginning of such a stock:
PHP Code:

stock csdm_get_remove_objectives()
{    
    static 
ConfigsDir[128], Filename[150], ReadData[512]
    
get_configsdir(ConfigsDir127)
    
format(Filename139"%s/csdm.cfg"ConfigsDir)
    
    if(!
file_exists(Filename))
        return;
    
    static 
len,currline
    
    
while(read_file(FilenamecurrlineReadData511len))
    {
        
// check if the line is empty
        
if (!len)
            continue;
            
        
// here should check does
        // string "remove_objectives" 
        // exists on current line ( currline )
        // and get what's after =

    
}


Any suggestions?

Emp` 04-03-2009 15:09

Re: Getting argument from vars in file ( like csdm.cfg )
 
Code:

new szFirst[51], szMiddle[51], szLast[51];
parse( ReadData, szFirst, 50, szMiddle, 50, szLast, 50);
if( equal(szFirst, "remove_objectives") && equal(szMiddle, "=") ){
    //szLast contains what is after the = sign
}


Empowers 04-03-2009 15:47

Re: Getting argument from vars in file ( like csdm.cfg )
 
Wow!
Great code, doing this with only 3 line it's really nice
Thx Emp`
+k

SOLVED


All times are GMT -4. The time now is 02:25.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.