From b4d006438c8fefb519b5ec6e6e76128984ad09a6 Mon Sep 17 00:00:00 2001 From: xPaw Date: Sun, 27 Jul 2014 11:42:34 +0300 Subject: [PATCH] Update core to use amx_language cvar instead of vault --- amxmodx/format.cpp | 10 +++++----- amxmodx/meta_api.cpp | 10 ++++------ configs/amxx.cfg | 11 +++++++++++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/amxmodx/format.cpp b/amxmodx/format.cpp index 1ec60e2a..023e568c 100644 --- a/amxmodx/format.cpp +++ b/amxmodx/format.cpp @@ -52,18 +52,18 @@ const char *translate(AMX *amx, cell amxaddr, const char *key) amx_cl_langs = CVAR_GET_POINTER("amx_client_languages"); if ( (int)amx_cl_langs->value == 0 ) { - pLangName = g_vault.get("server_language"); + pLangName = amxmodx_language->string; } else { pLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(g_langMngr.GetDefLang())->pEdict, "lang"); } } else if (addr[0] == LANG_SERVER) { - pLangName = g_vault.get("server_language"); + pLangName = amxmodx_language->string; } else if (addr[0] >= 1 && addr[0] <= gpGlobals->maxClients) { if (!amx_cl_langs) amx_cl_langs = CVAR_GET_POINTER("amx_client_languages"); if ( (int)amx_cl_langs->value == 0 ) { - pLangName = g_vault.get("server_language"); + pLangName = amxmodx_language->string; } else { pLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(addr[0])->pEdict, "lang"); } @@ -110,9 +110,9 @@ const char *translate(AMX *amx, cell amxaddr, const char *key) } if (addr[0] != LANG_SERVER) - def = g_langMngr.GetDef(g_vault.get("server_language"), key, status); + def = g_langMngr.GetDef(amxmodx_language->string, key, status); - if (!def && (strcmp(pLangName, "en") != 0 && strcmp(g_vault.get("server_language"), "en") != 0)) + if (!def && (strcmp(pLangName, "en") != 0 && strcmp(amxmodx_language->string, "en") != 0)) def = g_langMngr.GetDef("en", key, status); } diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index 67172920..43ea5030 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -142,9 +142,11 @@ cvar_t init_amxmodx_version = {"amxmodx_version", "", FCVAR_SERVER | FCVAR_SPONL cvar_t init_amxmodx_modules = {"amxmodx_modules", "", FCVAR_SPONLY}; cvar_t init_amxmodx_debug = {"amx_debug", "1", FCVAR_SPONLY}; cvar_t init_amxmodx_mldebug = {"amx_mldebug", "", FCVAR_SPONLY}; +cvar_t init_amxmodx_language = {"amx_language", "en", FCVAR_SERVER}; cvar_t init_amxmodx_cl_langs = {"amx_client_languages", "", FCVAR_SERVER}; cvar_t* amxmodx_version = NULL; cvar_t* amxmodx_modules = NULL; +cvar_t* amxmodx_language = NULL; cvar_t* hostname = NULL; cvar_t* mp_timelimit = NULL; @@ -464,12 +466,6 @@ int C_Spawn(edict_t *pent) char file[255]; g_vault.setSource(build_pathname_r(file, sizeof(file) - 1, "%s", get_localinfo("amxx_vault", "addons/amxmodx/configs/vault.ini"))); g_vault.loadVault(); - - if (strlen(g_vault.get("server_language")) < 1) - { - g_vault.put("server_language", "en"); - g_vault.saveVault(); - } // ###### Init time and freeze tasks g_game_timeleft = g_bmod_dod ? 1.0f : 0.0f; @@ -1446,9 +1442,11 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m CVAR_REGISTER(&init_amxmodx_modules); CVAR_REGISTER(&init_amxmodx_debug); CVAR_REGISTER(&init_amxmodx_mldebug); + CVAR_REGISTER(&init_amxmodx_language); CVAR_REGISTER(&init_amxmodx_cl_langs); amxmodx_version = CVAR_GET_POINTER(init_amxmodx_version.name); + amxmodx_language = CVAR_GET_POINTER(init_amxmodx_language.name); REG_SVR_COMMAND("amxx", amx_command); diff --git a/configs/amxx.cfg b/configs/amxx.cfg index b7dbe597..dd4f920c 100755 --- a/configs/amxx.cfg +++ b/configs/amxx.cfg @@ -134,12 +134,23 @@ amx_extendmap_max 90 // Default value: 15 amx_extendmap_step 15 +// Server language in ISO 639-1 format +// Please see data/lang/languages.txt file for a list of supported languages +// +// Default value: en +amx_language "en" + // If you set this to 0, clients cannot chose their language, instead they use // whatever language the server is configured to use. // // Default value: 1 amx_client_languages 1 +// If you set this to 0, clients will not see a message about amx_langmenu when they join the server +// +// Default value: 1 +amx_language_display_msg 1 + // Plugin Debug mode // 0 - No debugging (garbage line numbers) // 1 - Plugins with "debug" option in plugins.ini are put into debug mode