AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Multilingua] Own multi param function (https://forums.alliedmods.net/showthread.php?t=94012)

orglee 06-05-2009 12:57

[Multilingua] Own multi param function
 
Hello. I have function that handles displaying text messages to users.
Code:
public PlayerNotify(id, sLang[], any:...) {     new sText[70]     new sLangText[70]     format(sLangText, charsmax(sLangText), "%L", sLang)     vformat(sText, charsmax(sText), sLangText, 3)         client_print(id, print_chat, "%s %s", PLUGIN_TAG, sText) }
I want it to be able to send multilanguage informations with some custom data inside them. For instance;
Code:

[en]
SET_LANG_SERVER = The server language has been set to "%s"

It looks ( at least for me ) that everything is fine with that function implementation but It shows me an error.
Quote:

String formatted incorrectly - parameter 4 (total 4)
[AMXX] Displaying debug trace (plugin "climb.amxx")
[AMXX] Run time error 25: parameter error
with line number pointing on "format(sLangText, charsmax(sLangText), "%L", sLang)"

Thanks in advance
Regards

crazyeffect 06-05-2009 13:02

Re: [Multilingua] Own multi param function
 
"%L", sLang
is impossible.

It needs to be '"%L", id, "SET_LANG_SERVER", sLang' then.

Arkshine 06-05-2009 13:05

Re: [Multilingua] Own multi param function
 
You can pass directly %L in PlayerNotify(), vformat supports ML.

orglee 06-05-2009 13:19

Re: [Multilingua] Own multi param function
 
Well it looks like I'm ultradumb. . .

Could you give me some example. I just cant imagine/understand both solutions.

Arkshine 06-05-2009 13:49

Re: [Multilingua] Own multi param function
 
When you use : PlayerNotify(id, "I suck or %s", "not" );

You can use PlayerNotify(id, "I suck or %L", id, "I_SUCK" );

orglee 06-05-2009 13:57

Re: [Multilingua] Own multi param function
 
But it happens that I also have some variable inside language string.
Quote:

[en]
SET_LANG_SERVER = The server language has been set to "%s"
Could you please tell me you put id in third parameter?

crazyeffect@ Please explain me why you have used those arguments.

Arkshine 06-05-2009 14:05

Re: [Multilingua] Own multi param function
 
PlayerNotify(id, "%L", id, "SET_LANG_SERVER", MyParam );

orglee 06-05-2009 14:27

Re: [Multilingua] Own multi param function
 
Quote:

Originally Posted by arkshine (Post 842390)
PlayerNotify(id, "%L", id, "SET_LANG_SERVER", MyParam );

But I want to embed that inside function so it wont be necessary to use such unusual function prototype notation. I want PlayerNotify() to automatically load string of given language identifier ( second argument ) and put all other arguments given to PlayerNotify() inside that loaded string.

Arkshine 06-05-2009 14:50

Re: [Multilingua] Own multi param function
 
Sorry I don't understand what you want. It's the usual way to format a string, whatever using format[ex]() or using a function + vformat.

orglee 06-05-2009 15:08

Re: [Multilingua] Own multi param function
 
new sLang[3] = 'en'
SET_LANG_USER = Your language has been set to "%s"

PlayerNotify(id, "SET_LANG_USER", sLang)

And I really don't want to change that prototype no matter if I'm passing some arguments to language string or not. That means all "argument in lang string" implementation should be inside function.

How to do that?


All times are GMT -4. The time now is 13:48.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.