From e8d5bf9521dedb24588c61d7aea3821dd351e0c3 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 14 Jul 2007 00:47:30 +0000 Subject: [PATCH] added request amb579 - ShowActivityEx() --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401110 --- core/smn_player.cpp | 31 ++++++++++++++++++++++--------- plugins/include/console.inc | 13 +++++++++++++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/core/smn_player.cpp b/core/smn_player.cpp index 9d728291..91996f27 100644 --- a/core/smn_player.cpp +++ b/core/smn_player.cpp @@ -864,7 +864,7 @@ static cell_t GetClientOfUserId(IPluginContext *pContext, const cell_t *params) return g_Players.GetClientOfUserId(params[1]); } -static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params) +static cell_t _ShowActivity(IPluginContext *pContext, const cell_t *params, const char *tag, cell_t fmt_param) { char message[255]; char buffer[255]; @@ -894,15 +894,15 @@ static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params) if (replyto == SM_REPLY_CONSOLE) { g_SourceMod.SetGlobalTarget(client); - g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); - UTIL_Format(message, sizeof(message), "[SM] %s\n", buffer); + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); + UTIL_Format(message, sizeof(message), "%s%s\n", tag, buffer); engine->ClientPrintf(pPlayer->GetEdict(), message); display_in_chat = true; } } else { g_SourceMod.SetGlobalTarget(LANG_SERVER); - g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); - UTIL_Format(message, sizeof(message), "[SM] %s\n", buffer); + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); + UTIL_Format(message, sizeof(message), "%s%s\n", tag, buffer); META_CONPRINT(message); } @@ -934,8 +934,8 @@ static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params) { newsign = name; } - g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); - UTIL_Format(message, sizeof(message), "[SM] %s: %s", newsign, buffer); + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); + UTIL_Format(message, sizeof(message), "%s%s: %s", tag, newsign, buffer); g_HL2.TextMsg(i, HUD_PRINTTALK, message); } } else { @@ -950,8 +950,8 @@ static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params) { newsign = name; } - g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); - UTIL_Format(message, sizeof(message), "[SM] %s: %s", newsign, buffer); + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); + UTIL_Format(message, sizeof(message), "%s%s: %s", tag, newsign, buffer); g_HL2.TextMsg(i, HUD_PRINTTALK, message); } } @@ -960,6 +960,19 @@ static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params) return 1; } +static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params) +{ + return _ShowActivity(pContext, params, "[SM] ", 2); +} + +static cell_t ShowActivityEx(IPluginContext *pContext, const cell_t *params) +{ + char *str; + pContext->LocalToString(params[2], &str); + + return _ShowActivity(pContext, params, str, 3); +} + static cell_t KickClient(IPluginContext *pContext, const cell_t *params) { int client = params[1]; diff --git a/plugins/include/console.inc b/plugins/include/console.inc index 090be28f..39a71041 100644 --- a/plugins/include/console.inc +++ b/plugins/include/console.inc @@ -208,6 +208,19 @@ native ReplySource:SetCmdReplySource(ReplySource:source); */ native ShowActivity(client, const String:format[], any:...); +/** + * Same as ShowActivity(), except the tag parameter is used instead of + * "[SM] " (note that you must supply any spacing). + * + * @param client Client index doing the action, or 0 for server. + * @param tag Tag to display with. + * @param format Formatting rules. + * @param ... Variable number of format parameters. + * @noreturn + * @error + */ +native ShowActivityEx(client, const String:tag[], const String:format[], any:...); + /** * Called when a server-only command is invoked. *