Thread: [Solved] Need Code For CFG FILE
View Single Post
lexzor
Veteran Member
Join Date: Nov 2020
Old 07-24-2022 , 21:28   Re: Need Code For CFG FILE
Reply With Quote #33

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;
            }
        }

        
fclose(iFile);
    }

    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);
    }


Last edited by lexzor; 07-24-2022 at 21:33.
lexzor is offline