Vice City: Multiplayer

VC:MP Discussion => Support => Tutorials => Topic started by: habi on Apr 19, 2023, 03:04 PM

Title: Server.cfg Reader c++
Post by: habi on Apr 19, 2023, 03:04 PM
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
(https://i.imgur.com/YambfOt.png)
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
Title: Re: Server.cfg Reader c++
Post by: Nihongo^ on Apr 19, 2023, 05:12 PM
hi habi, may i know what kind of file is it ? and the benefits ?
Title: Re: Server.cfg Reader c++
Post by: habi on Apr 19, 2023, 09:17 PM
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.