diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 0d7620c0..aa7bafdd 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -4536,6 +4536,21 @@ static cell AMX_NATIVE_CALL admins_lookup(AMX *amx, cell *params) // unknown property return 0; }; +// LookupLangKey(Output[], OutputSize, const Key[], const &id) +static cell AMX_NATIVE_CALL LookupLangKey(AMX *amx, cell *params) +{ + int len; + char *key=get_amxstring(amx,params[3],0,len); + const char *def=translate(amx,params[4],key); + + if (def==NULL) + { + return 0; + } + + set_amxstring(amx,params[1],def,params[2]); + return 1; +}; AMX_NATIVE_INFO amxmodx_Natives[] = { diff --git a/plugins/include/lang.inc b/plugins/include/lang.inc index 4f8a4c61..ba086352 100755 --- a/plugins/include/lang.inc +++ b/plugins/include/lang.inc @@ -45,3 +45,12 @@ native TransKey:GetLangTransKey(const key[]); * Adds a translation. */ native AddTranslation(const lang[3], TransKey:key, const phrase[]); + +/** + * Looks up the translation of the key for the given type + * This does NOT format the output text. + * eg: If the key includes %s, the outputted text will also contain %s. + * NOTE: LANG_PLAYER is invalid in this, use a player index + * or LANG_SERVER + */ +native LookupLangKey(Output[], OutputSize, const Key[], const &id);