示例#1
0
static cell_t GetPluginInfo(IPluginContext *pContext, const cell_t *params)
{
	IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
	if (!pPlugin)
	{
		return 0;
	}

	const sm_plugininfo_t *info = pPlugin->GetPublicInfo();

	if (!info)
	{
		return 0;
	}

	const char *str = NULL;

	switch ((PluginInfo)params[2])
	{
	case PlInfo_Name:
		{
			str = info->name;
			break;
		}
	case PlInfo_Author:
		{
			str = info->author;
			break;
		}
	case PlInfo_Description:
		{
			str = info->description;
			break;
		}
	case PlInfo_Version:
		{
			str = info->version;
			break;
		}
	case PlInfo_URL:
		{
			str = info->url;
			break;
		}
	}

	if (!str || str[0] == '\0')
	{
		return 0;
	}

	pContext->StringToLocalUTF8(params[3], params[4], str, NULL);

	return 1;
}
示例#2
0
void ConVarManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command)
{
	int argcount = command->ArgC();
	if (argcount >= 3)
	{
		bool wantReset = false;
		
		/* Get plugin index that was passed */
		const char *arg = command->Arg(2);
		if (argcount >= 4 && strcmp(arg, "reset") == 0)
		{
			wantReset = true;
			arg = command->Arg(3);
		}
		
		/* Get plugin object */
		IPlugin *plugin = scripts->FindPluginByConsoleArg(arg);

		if (!plugin)
		{
			UTIL_ConsolePrint("[SM] Plugin \"%s\" was not found.", arg);
			return;
		}

		/* Get plugin name */
		const sm_plugininfo_t *plinfo = plugin->GetPublicInfo();
		const char *plname = IS_STR_FILLED(plinfo->name) ? plinfo->name : plugin->GetFilename();

		ConVarList *pConVarList;
		ConVarList::iterator iter;

		/* If no convar list... */
		if (!plugin->GetProperty("ConVarList", (void **)&pConVarList))
		{
			UTIL_ConsolePrint("[SM] No convars found for: %s", plname);
			return;
		}

		if (!wantReset)
		{
			UTIL_ConsolePrint("[SM] Listing %d convars for: %s", pConVarList->size(), plname);
			UTIL_ConsolePrint("  %-32.31s %s", "[Name]", "[Value]");
		}
		
		/* Iterate convar list and display/reset each one */
		for (iter = pConVarList->begin(); iter != pConVarList->end(); iter++)
		{
			/*const */ConVar *pConVar = const_cast<ConVar *>(*iter);
			if (!wantReset)
			{
				UTIL_ConsolePrint("  %-32.31s %s", pConVar->GetName(), pConVar->GetString()); 
			} else {
				pConVar->Revert();
			}
		}
		
		if (wantReset)
		{
			UTIL_ConsolePrint("[SM] Reset %d convars for: %s", pConVarList->size(), plname);
		}

		return;
	}

	/* Display usage of subcommand */
	UTIL_ConsolePrint("[SM] Usage: sm cvars [reset] <plugin #>");
}