Thread: [Solved] Need Code For CFG FILE
View Single Post
Begineer Programmer
Member
Join Date: Nov 2021
Old 07-24-2022 , 21:30   Re: Need Code For CFG FILE
Reply With Quote #34

Quote:
Originally Posted by lexzor View Post
i hope you will understand better
PHP Code:
getCvarValue(const szMap[])
{
    new 
szFile[128], szConfigsDir[128], szMapName[32], iValue;    
    
get_configsdir(szConfigsDircharsmax(szConfigsDir));
    
formatex(szFilecharsmax(szFile), "%s/%s_amxx.cfg"szConfigsDirszMap);

    if(
file_exists(szFile))
    {
        new 
iFile fopen(szFile"r");
        new 
szCvar[32], szValue[32], szCfgData[64];
        
        while(
fgets(iFileszCfgDatacharsmax(szCfgData)))
        {
            
parse(szDataszCvarcharsmax(szCvar), szValuecharsmax(szValue));

            if(
equali(szCvar"mp_maxrounds"))
            {
                
iValue str_to_num(szValue);
                break;
            }
        }
    }

    return 
iValue == ? -iValue;
}

client_command(id)
{
    new 
szMapName[32];
    
get_mapname(szMapNamecharsmax(szMapName));

    new 
iValue getCvarValue(szMapName);

    if(
iValue == -1)
    {
        
client_print_color(idprint_team_default"^4[CVAR]^1 No settings for this map");
    }
    else 
    {
        
client_print_color(idprint_team_default"^4[CVAR]^1 On this map will pe played^3 %i rounds^1."iValue);
    }

Thx mate !!! <3
Begineer Programmer is offline