From cb77ef5b7d731d36a5d9ebabf1200f300550d387 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 3 Jul 2007 20:16:40 +0000 Subject: [PATCH] fixed amb455 --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401040 --- core/smn_lang.cpp | 8 ++++++++ plugins/include/halflife.inc | 4 ++-- plugins/include/lang.inc | 11 +++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/core/smn_lang.cpp b/core/smn_lang.cpp index d4d6101d5..54248abe1 100644 --- a/core/smn_lang.cpp +++ b/core/smn_lang.cpp @@ -41,8 +41,16 @@ static cell_t sm_LoadTranslations(IPluginContext *pCtx, const cell_t *params) return 1; } +static cell_t sm_SetGlobalTransTarget(IPluginContext *pContext, const cell_t *params) +{ + g_SourceMod.SetGlobalTarget(params[1]); + + return 1; +} + REGISTER_NATIVES(langNativeS) { {"LoadTranslations", sm_LoadTranslations}, + {"SetGlobalTransTarget", sm_SetGlobalTransTarget}, {NULL, NULL}, }; diff --git a/plugins/include/halflife.inc b/plugins/include/halflife.inc index aea2abf26..99b2378a8 100644 --- a/plugins/include/halflife.inc +++ b/plugins/include/halflife.inc @@ -231,12 +231,12 @@ stock PrintToChatAll(const String:format[], any:...) new maxClients = GetMaxClients(); decl String:buffer[192]; - VFormat(buffer, sizeof(buffer), format, 2); - for (new i = 1; i <= maxClients; i++) { if (IsClientInGame(i)) { + SetGlobalTransTarget(i); + VFormat(buffer, sizeof(buffer), format, 2); PrintToChat(i, "%s", buffer); } } diff --git a/plugins/include/lang.inc b/plugins/include/lang.inc index f1d5b5df3..09f82e5be 100644 --- a/plugins/include/lang.inc +++ b/plugins/include/lang.inc @@ -28,3 +28,14 @@ * @noreturn */ native LoadTranslations(const String:file[]); + +/** + * Sets the global language target. This is useful for creating functions + * that will be compatible with the %t format specifier. Note that invalid + * indexes can be specified but the error will occur during translation, + * not during this function call. + * + * @param client Client index or LANG_SERVER. + * @noreturn + */ +native SetGlobalTransTarget(client);