Пример #1
0
void CoreConfig::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
{
	int argcount = command.ArgC();
	if (argcount >= 4)
	{
		const char *option = command.Arg(2);
		const char *value = command.Arg(3);

		char error[255];

		ConfigResult res = SetConfigOption(option, value, ConfigSource_Console, error, sizeof(error));

		if (res == ConfigResult_Reject)
		{
			g_RootMenu.ConsolePrint("[SM] Could not set config option \"%s\" to \"%s\". (%s)", option, value, error);
		} else if (res == ConfigResult_Ignore) {
			g_RootMenu.ConsolePrint("[SM] No such config option \"%s\" exists.", option);
		} else {
			g_RootMenu.ConsolePrint("[SM] Config option \"%s\" successfully set to \"%s\".", option, value);
		}

		return;
	} else if (argcount >= 3) {
		const char *option = command.Arg(2);
		
		const char *value = GetCoreConfigValue(option);
		
		if (value == NULL)
		{
			g_RootMenu.ConsolePrint("[SM] No such config option \"%s\" exists.", option);
		} else {
			g_RootMenu.ConsolePrint("[SM] Config option \"%s\" is set to \"%s\".", option, value);
		}
		
		return;
	}

	g_RootMenu.ConsolePrint("[SM] Usage: sm config <option> [value]");
}
Пример #2
0
void SourceModBase::StartSourceMod(bool late)
{
	SH_ADD_HOOK(IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER(this, &SourceModBase::LevelShutdown), false);
	SH_ADD_HOOK(IServerGameDLL, GameFrame, gamedll, SH_MEMBER(&g_Timers, &TimerSystem::GameFrame), false);

	enginePatch = SH_GET_CALLCLASS(engine);
	gamedllPatch = SH_GET_CALLCLASS(gamedll);

	InitLogicBridge();

	/* Initialize CoreConfig to get the SourceMod base path properly - this parses core.cfg */
	g_CoreConfig.Initialize();

	/* Notify! */
	SMGlobalClass *pBase = SMGlobalClass::head;
	while (pBase)
	{
		pBase->OnSourceModStartup(false);
		pBase = pBase->m_pGlobalClassNext;
	}
	g_pGameConf = logicore.GetCoreGameConfig();

	/* Notify! */
	pBase = SMGlobalClass::head;
	while (pBase)
	{
		pBase->OnSourceModAllInitialized();
		pBase = pBase->m_pGlobalClassNext;
	}

	/* Notify! */
	pBase = SMGlobalClass::head;
	while (pBase)
	{
		pBase->OnSourceModAllInitialized_Post();
		pBase = pBase->m_pGlobalClassNext;
	}

	/* Add us now... */
	sharesys->AddInterface(NULL, this);

	/* We're loaded! */
	g_Loaded = true;

	/* Initialize VSP stuff */
	if (vsp_interface != NULL)
	{
		g_SourceMod_Core.OnVSPListening(vsp_interface);
	}

	if (late)
	{
		/* We missed doing anythin gin this if we late-loaded. Sneak it in now. */
		AllPluginsLoaded();
	}

	/* If we want to autoload, do that now */
	const char *disabled = GetCoreConfigValue("DisableAutoUpdate");
	if (disabled == NULL || strcasecmp(disabled, "yes") != 0)
	{
		extsys->LoadAutoExtension("updater.ext." PLATFORM_LIB_EXT);
	}

	const char *timeout = GetCoreConfigValue("SlowScriptTimeout");
	if (timeout == NULL)
	{
		timeout = "8";
	}
	if (atoi(timeout) != 0)
	{
		g_pSourcePawn2->InstallWatchdogTimer(atoi(timeout) * 1000);
	}
}