Server.cfg Reader c++

Started by habi, Apr 19, 2023, 03:04 PM

Previous topic - Next topic

habi

Hi this is one of the programs i made long ago and has been used in two of my recent projects-filterscripts and rcon. It works perfectly.

Using this, you can read values from server.cfg. Using indexes, you can read the second, third , fourth and so on.

The two files (ReadCFG.cpp and ReadCFG.h) are attached.

Examples

Usage: main.cpp
#include "ReadCFG.h"

//Look for the term 'configuration' in server.cfg

char* szValue;
cfg mycfg;
mycfg.read("server.cfg", "configuration");

//Looping through all values (first, second, third, fourth, etc. )
for (int i = 0; i < mycfg.argc; i++)
{

   
    szValue = mycfg.ptr[i];
    printf(szValue);
    printf("\n");
    //Do something
   
}

mycfg.freememory();

Expected Output
Quotealpha
beta
gamma
delta

Nihongo^

hi habi, may i know what kind of file is it ? and the benefits ?

habi

It is just nothing.  When making plugins for server, you can tell user to type some value (names, file locations,  etc) in server.cfg and this one helps to get that value.