added request amb579 - ShowActivityEx()

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401110
This commit is contained in:
David Anderson 2007-07-14 00:47:30 +00:00
parent f2194aa2d9
commit e8d5bf9521
2 changed files with 35 additions and 9 deletions

View File

@ -864,7 +864,7 @@ static cell_t GetClientOfUserId(IPluginContext *pContext, const cell_t *params)
return g_Players.GetClientOfUserId(params[1]); 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 message[255];
char buffer[255]; char buffer[255];
@ -894,15 +894,15 @@ static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params)
if (replyto == SM_REPLY_CONSOLE) if (replyto == SM_REPLY_CONSOLE)
{ {
g_SourceMod.SetGlobalTarget(client); g_SourceMod.SetGlobalTarget(client);
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, fmt_param);
UTIL_Format(message, sizeof(message), "[SM] %s\n", buffer); UTIL_Format(message, sizeof(message), "%s%s\n", tag, buffer);
engine->ClientPrintf(pPlayer->GetEdict(), message); engine->ClientPrintf(pPlayer->GetEdict(), message);
display_in_chat = true; display_in_chat = true;
} }
} else { } else {
g_SourceMod.SetGlobalTarget(LANG_SERVER); g_SourceMod.SetGlobalTarget(LANG_SERVER);
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, fmt_param);
UTIL_Format(message, sizeof(message), "[SM] %s\n", buffer); UTIL_Format(message, sizeof(message), "%s%s\n", tag, buffer);
META_CONPRINT(message); META_CONPRINT(message);
} }
@ -934,8 +934,8 @@ static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params)
{ {
newsign = name; newsign = name;
} }
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, fmt_param);
UTIL_Format(message, sizeof(message), "[SM] %s: %s", newsign, buffer); UTIL_Format(message, sizeof(message), "%s%s: %s", tag, newsign, buffer);
g_HL2.TextMsg(i, HUD_PRINTTALK, message); g_HL2.TextMsg(i, HUD_PRINTTALK, message);
} }
} else { } else {
@ -950,8 +950,8 @@ static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params)
{ {
newsign = name; newsign = name;
} }
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, fmt_param);
UTIL_Format(message, sizeof(message), "[SM] %s: %s", newsign, buffer); UTIL_Format(message, sizeof(message), "%s%s: %s", tag, newsign, buffer);
g_HL2.TextMsg(i, HUD_PRINTTALK, message); g_HL2.TextMsg(i, HUD_PRINTTALK, message);
} }
} }
@ -960,6 +960,19 @@ static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params)
return 1; 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) static cell_t KickClient(IPluginContext *pContext, const cell_t *params)
{ {
int client = params[1]; int client = params[1];

View File

@ -208,6 +208,19 @@ native ReplySource:SetCmdReplySource(ReplySource:source);
*/ */
native ShowActivity(client, const String:format[], any:...); 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. * Called when a server-only command is invoked.
* *