I have been using this mechanism:
define in global area:
Code:
ConVar announcer_version("annnouncer_version", "0.5B", FCVAR_SPONLY|FCVAR_NOTIFY, "Announcer Version");
also add in the global area:
Code:
/**
* Something like this is needed to register cvars/CON_COMMANDs.
*/
class BaseAccessor : public IConCommandBaseAccessor
{
public:
bool RegisterConCommandBase(ConCommandBase *pCommandBase) {
/* Always call META_REGCVAR instead of going through the engine. */
return (META_REGCVAR(pCommandBase));
}
} s_BaseAccessor;
In Load(), make sure this is included already:
Code:
GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION);
after the SH_ADD_HOOKs in Load(), add:
Code:
#if SOURCE_ENGINE >= SE_ORANGEBOX
g_pCVar = icvar;
ConVar_Register(0, &s_BaseAccessor);
#else
ConCommandBaseMgr::OneTimeInit(&s_BaseAccessor);
#endif
Finally your set value:
Code:
announcer_version.SetValue("0.5B");
I didn't use the "new" construction but it should work by adjusting the above.
__________________