diff --git a/natives.cpp b/natives.cpp index 8e3a671..670657b 100644 --- a/natives.cpp +++ b/natives.cpp @@ -825,8 +825,27 @@ static cell_t Native_PrintToChat(IPluginContext *pContext, const cell_t *params) char buffer[1024]; size_t len; { + +#if SOURCE_ENGINE != SE_CSGO + // There's no way to set the current translation without a client index, so we'll save / restore the language on the relay. + int iHLTVClient = hltvserver->GetHLTVServer()->GetHLTVSlot() + 1; + IGamePlayer *pHLTVClient = playerhelpers->GetGamePlayer(iHLTVClient); + + unsigned int langid = translator->GetServerLanguage(); + translator->GetLanguageByName(pClient->BaseClient()->GetUserSetting("cl_language"), &langid); + pHLTVClient->SetLanguageId(langid); + + int restoreTarget = translator->SetGlobalTarget(hltvserver->GetHLTVServer()->GetHLTVSlot() + 1); +#endif + DetectExceptions eh(pContext); len = smutils->FormatString(buffer, sizeof(buffer), pContext, params, 2); + +#if SOURCE_ENGINE != SE_CSGO + pHLTVClient->SetLanguageId(translator->GetServerLanguage()); + translator->SetGlobalTarget(restoreTarget); +#endif + if (eh.HasException()) return 0; } @@ -879,8 +898,27 @@ static cell_t Native_PrintToConsole(IPluginContext *pContext, const cell_t *para char buffer[1024]; size_t len; { + +#if SOURCE_ENGINE != SE_CSGO + // There's no way to set the current translation without a client index, so we'll save / restore the language on the relay. + int iHLTVClient = hltvserver->GetHLTVServer()->GetHLTVSlot() + 1; + IGamePlayer *pHLTVClient = playerhelpers->GetGamePlayer(iHLTVClient); + + unsigned int langid = translator->GetServerLanguage(); + translator->GetLanguageByName(pClient->BaseClient()->GetUserSetting("cl_language"), &langid); + pHLTVClient->SetLanguageId(langid); + + int restoreTarget = translator->SetGlobalTarget(hltvserver->GetHLTVServer()->GetHLTVSlot() + 1); +#endif + DetectExceptions eh(pContext); len = smutils->FormatString(buffer, sizeof(buffer), pContext, params, 2); + +#if SOURCE_ENGINE != SE_CSGO + pHLTVClient->SetLanguageId(translator->GetServerLanguage()); + translator->SetGlobalTarget(restoreTarget); +#endif + if (eh.HasException()) return 0; } diff --git a/smsdk_config.h b/smsdk_config.h index 71c5089..780997b 100644 --- a/smsdk_config.h +++ b/smsdk_config.h @@ -61,7 +61,7 @@ /** Enable interfaces you want to use here by uncommenting lines */ #define SMEXT_ENABLE_FORWARDSYS //#define SMEXT_ENABLE_HANDLESYS -//#define SMEXT_ENABLE_PLAYERHELPERS +#define SMEXT_ENABLE_PLAYERHELPERS //#define SMEXT_ENABLE_DBMANAGER #define SMEXT_ENABLE_GAMECONF //#define SMEXT_ENABLE_MEMUTILS @@ -75,7 +75,7 @@ //#define SMEXT_ENABLE_ADMINSYS //#define SMEXT_ENABLE_TEXTPARSERS //#define SMEXT_ENABLE_USERMSGS -//#define SMEXT_ENABLE_TRANSLATOR +#define SMEXT_ENABLE_TRANSLATOR //#define SMEXT_ENABLE_ROOTCONSOLEMENU #endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_