Oh, just found out I couldn't compile it because the array size of filename did not match with path's array size.
Thank you!
Now, I have a new question: How do I send this info to console?
Code:
SetFailState("CONFIG ERROR ID: #%d, %s. (line %d, column %d) [FILE: %s]", result, sError, iLine, iCol, sPath);
I know I can just PrintToConsole or Reply, but look at this:
Code:
// ------------
// SMCParser
// Code is *very* based of: 'l4d_info_editor.sp'
// Step 1: Parse filename from user input, in order to use it in LoadConfigSMC.
public Action ParseConfigSMC(int client, int args)
{
char filename[70];
GetCmdArg(1, filename, sizeof(filename));
LoadConfigSMC(filename);
return Plugin_Handled;
}
// Step 2: Attempt to load the filename obtained from ParseConfigSMC; if the file is not found,
// then try to load the default file you download from the plugin's site ("l4d_reservecontrol.cfg").
// Otherwise, the plugin fails, resulting in its abortion.
void LoadConfigSMC(char path[70])
{
//g_smReserveData.Clear();
char sPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sPath, sizeof(sPath), "data/%s.cfg", path);
if( FileExists(sPath) )
{
SMCParser parser = new SMCParser();
parser.OnKeyValue = SMC_OnKeyValue;
// Setup error logging
char sError[128];
int iLine, iCol;
SMCError result = parser.ParseFile(sPath, iLine, iCol);
if( result != SMCError_Okay )
{
BuildPath(Path_SM, sPath, sizeof(sPath), "data/l4d_reservecontrol.cfg");
if( parser.GetErrorString(result, sError, sizeof(sError)) )
{
SetFailState("CONFIG ERROR ID: #%d, %s. (line %d, column %d) [FILE: %s]", result, sError, iLine, iCol, sPath);
// I want the plugin to keep running, rather than being aborted. Maybe log the error or print it to console.
}
else
{
SetFailState("Unable to load config. Bad format? Check for missing { } etc.");
// Same here.
}
}
delete parser;
return;
}
SetFailState("Could not load CFG '%s'! Plugin aborted.", sPath); // Same here as well.
}
I cannot PrintToConsole because I need a client ID, which is not fetched by LoadConfigSMC.
I could send the entire code, but that's pretty much what I've changed. I commented CmdReserveReload (used when reloading the cfg file), since I wasn't able to get it working properly (due to g_smReserveData.Clear() having a lot of errors that could overload the server). I might investigate a way on saving the parsed filename on memory, that way maybe I can get it working again.