コード例 #1
0
ファイル: extension.cpp プロジェクト: Kolpa/SourceMod.js
void CmdReloadPlugin(const CCommandContext &context, const CCommand &command){
	if(command.ArgC() != 2){
		META_CONPRINT("Usage: js_reload [plugin_dir]\n");
		return;
	}

	CmdUnloadPlugin(context, command);
	CmdLoadPlugin(context, command);
	
}
コード例 #2
0
ファイル: extension.cpp プロジェクト: Kolpa/SourceMod.js
void CmdUnloadPlugin(const CCommandContext &context, const CCommand &command){
	if(command.ArgC() != 2){
		META_CONPRINT("Usage: js_unload [plugin_dir]\n");
		return;
	}

	auto pl = SMJS_Plugin::GetPluginByDir(command.Arg(1));
	if(pl == NULL){
		META_CONPRINTF("Plugin \"%s\" is not loaded!\n", command.Arg(1));
		return;
	}

	delete pl;
	META_CONPRINTF("Plugin \"%s\" unloaded successfully!\n", command.Arg(1));
}
コード例 #3
0
ファイル: logic_bridge.cpp プロジェクト: WildCard65/sourcemod
void UTIL_ConsolePrintVa(const char *fmt, va_list ap)
{
	char buffer[512];
	size_t len = ke::SafeVsprintf(buffer, sizeof(buffer), fmt, ap);

	if (len >= sizeof(buffer) - 1)
	{
		buffer[510] = '\n';
		buffer[511] = '\0';
	} else {
		buffer[len++] = '\n';
		buffer[len] = '\0';
	}
	META_CONPRINT(buffer);
}
コード例 #4
0
ファイル: smn_console.cpp プロジェクト: pmrowla/sourcemod-1.5
static cell_t sm_PrintToServer(IPluginContext *pCtx, const cell_t *params)
{
	char buffer[1024];
	char *fmt;
	int arg = 2;

	pCtx->LocalToString(params[1], &fmt);
	size_t res = atcprintf(buffer, sizeof(buffer)-2, fmt, pCtx, params, &arg);

	buffer[res++] = '\n';
	buffer[res] = '\0';

	META_CONPRINT(buffer);

	return 1;
}
コード例 #5
0
static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params)
{
	int index = params[1];
	if ((index < 0) || (index > g_Players.GetMaxClients()))
	{
		return pCtx->ThrowNativeError("Client index %d is invalid", index);
	}

	CPlayer *pPlayer = NULL;
	if (index != 0)
	{
		pPlayer = g_Players.GetPlayerByIndex(index);
		if (!pPlayer->IsInGame())
		{
			return pCtx->ThrowNativeError("Client %d is not in game", index);
		}
		
		/* Silent fail on bots, engine will crash */
		if (pPlayer->IsFakeClient())
		{
			return 0;
		}
	}

	char buffer[1024];
	char *fmt;
	int arg = 3;

	pCtx->LocalToString(params[2], &fmt);
	size_t res = atcprintf(buffer, sizeof(buffer)-2, fmt, pCtx, params, &arg);

	buffer[res++] = '\n';
	buffer[res] = '\0';

	if (index != 0)
	{
#if SOURCE_ENGINE == SE_DOTA
		engine->ClientPrintf(pPlayer->GetIndex(), buffer);
#else
		engine->ClientPrintf(pPlayer->GetEdict(), buffer);
#endif
	} else {
		META_CONPRINT(buffer);
	}

	return 1;
}
コード例 #6
0
ファイル: extension.cpp プロジェクト: Kolpa/SourceMod.js
void CmdLoadPlugin(const CCommandContext &context, const CCommand &command){
	if(command.ArgC() != 2){
		META_CONPRINT("Usage: js_load [plugin_dir]\n");
		return;
	}

	auto pl = SMJS_Plugin::GetPluginByDir(command.Arg(1));
	if(pl != NULL){
		META_CONPRINTF("Plugin \"%s\" is already loaded!\n", command.Arg(1));
		return;
	}

	pl = LoadPlugin(command.Arg(1));
	if(pl == NULL){
		META_CONPRINTF("Plugin \"%s\" failed to load!\n", command.Arg(1));
	}else{
		META_CONPRINTF("Plugin \"%s\" loaded successfully!\n", command.Arg(1));
	}
}
コード例 #7
0
void RootConsoleMenu::ConsolePrint(const char *fmt, ...)
{
	char buffer[512];

	va_list ap;
	va_start(ap, fmt);
	size_t len = vsnprintf(buffer, sizeof(buffer), fmt, ap);
	va_end(ap);

	if (len >= sizeof(buffer) - 1)
	{
		buffer[510] = '\n';
		buffer[511] = '\0';
	} else {
		buffer[len++] = '\n';
		buffer[len] = '\0';
	}
	
	META_CONPRINT(buffer);
}
コード例 #8
0
ファイル: logic_bridge.cpp プロジェクト: WildCard65/sourcemod
void CoreProviderImpl::ConPrint(const char *message)
{
	META_CONPRINT(message);
}
コード例 #9
0
ファイル: smn_player.cpp プロジェクト: pmrowla/sourcemod-1.5
static cell_t _ShowActivity2(IPluginContext *pContext,
							 const cell_t *params,
							 const char *tag,
							 cell_t fmt_param)
{
	char message[255];
	char buffer[255];
	int value = sm_show_activity.GetInt();
	unsigned int replyto = g_ChatTriggers.GetReplyTo();
	int client = params[1];

	const char *name = "Console";
	const char *sign = "ADMIN";
	if (client != 0)
	{
		CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
		if (!pPlayer || !pPlayer->IsConnected())
		{
			return pContext->ThrowNativeError("Client index %d is invalid", client);
		}
		name = pPlayer->GetName();
		AdminId id = pPlayer->GetAdminId();
		if (id == INVALID_ADMIN_ID
			|| !g_Admins.GetAdminFlag(id, Admin_Generic, Access_Effective))
		{
			sign = "PLAYER";
		}

		g_SourceMod.SetGlobalTarget(client);
		g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, fmt_param);

		if (pContext->GetLastNativeError() != SP_ERROR_NONE)
		{
			return 0;
		}

		/* We don't display directly to the console because the chat text 
		 * simply gets added to the console, so we don't want it to print 
		 * twice.
		 */
		if (replyto == SM_REPLY_CONSOLE)
		{
#if 0
			UTIL_Format(message, sizeof(message), "%s%s\n", tag, buffer);
			engine->ClientPrintf(pPlayer->GetEdict(), message);
#endif
			UTIL_Format(message, sizeof(message), "%s%s", tag, buffer);
			g_HL2.TextMsg(client, HUD_PRINTTALK, message);
		}
		else
		{
			UTIL_Format(message, sizeof(message), "%s%s", tag, buffer);
			g_HL2.TextMsg(client, HUD_PRINTTALK, message);
		}
	}
	else
	{
		g_SourceMod.SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);
		g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, fmt_param);

		if (pContext->GetLastNativeError() != SP_ERROR_NONE)
		{
			return 0;
		}

		UTIL_Format(message, sizeof(message), "%s%s\n", tag, buffer);
		META_CONPRINT(message);
	}

	if (!value)
	{
		return 1;
	}

	int maxClients = g_Players.GetMaxClients();
	for (int i=1; i<=maxClients; i++)
	{
		CPlayer *pPlayer = g_Players.GetPlayerByIndex(i);
		if (!pPlayer->IsInGame() 
			|| pPlayer->IsFakeClient()
			|| i == client)
		{
			continue;
		}
		AdminId id = pPlayer->GetAdminId();
		g_SourceMod.SetGlobalTarget(i);
		if (id == INVALID_ADMIN_ID
			|| !g_Admins.GetAdminFlag(id, Admin_Generic, Access_Effective))
		{
			/* Treat this as a normal user */
			if ((value & 1) || (value & 2))
			{
				const char *newsign = sign;
				if ((value & 2))
				{
					newsign = name;
				}
				g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, fmt_param);

				if (pContext->GetLastNativeError() != SP_ERROR_NONE)
				{
					return 0;
				}

				UTIL_Format(message, sizeof(message), "%s%s: %s", tag, newsign, buffer);
				g_HL2.TextMsg(i, HUD_PRINTTALK, message);
			}
		}
		else
		{
			/* Treat this as an admin user */
			bool is_root = g_Admins.GetAdminFlag(id, Admin_Root, Access_Effective);
			if ((value & 4) 
				|| (value & 8)
				|| ((value & 16) && is_root))
			{
				const char *newsign = sign;
				if ((value & 8) || ((value & 16) && is_root))
				{
					newsign = name;
				}
				g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, fmt_param);

				if (pContext->GetLastNativeError() != SP_ERROR_NONE)
				{
					return 0;
				}

				UTIL_Format(message, sizeof(message), "%s%s: %s", tag, newsign, buffer);
				g_HL2.TextMsg(i, HUD_PRINTTALK, message);
			}
		}
	}

	return 1;
}
コード例 #10
0
ファイル: logic_bridge.cpp プロジェクト: 50Wliu/sourcemod
static void conprint(const char *message)
{
	META_CONPRINT(message);
}