Raised This Month: $ Target: $400
 0% 

[Multilingua] Own multi param function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
orglee
Member
Join Date: Dec 2005
Old 06-05-2009 , 12:57   [Multilingua] Own multi param function
Reply With Quote #1

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
orglee is offline
crazyeffect
Veteran Member
Join Date: Jul 2008
Location: Belgium
Old 06-05-2009 , 13:02   Re: [Multilingua] Own multi param function
Reply With Quote #2

"%L", sLang
is impossible.

It needs to be '"%L", id, "SET_LANG_SERVER", sLang' then.
__________________
crazyeffect is offline
Send a message via MSN to crazyeffect
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-05-2009 , 13:05   Re: [Multilingua] Own multi param function
Reply With Quote #3

You can pass directly %L in PlayerNotify(), vformat supports ML.
__________________
Arkshine is offline
orglee
Member
Join Date: Dec 2005
Old 06-05-2009 , 13:19   Re: [Multilingua] Own multi param function
Reply With Quote #4

Well it looks like I'm ultradumb. . .

Could you give me some example. I just cant imagine/understand both solutions.
orglee is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-05-2009 , 13:49   Re: [Multilingua] Own multi param function
Reply With Quote #5

When you use : PlayerNotify(id, "I suck or %s", "not" );

You can use PlayerNotify(id, "I suck or %L", id, "I_SUCK" );
__________________
Arkshine is offline
orglee
Member
Join Date: Dec 2005
Old 06-05-2009 , 13:57   Re: [Multilingua] Own multi param function
Reply With Quote #6

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.
orglee is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-05-2009 , 14:05   Re: [Multilingua] Own multi param function
Reply With Quote #7

PlayerNotify(id, "%L", id, "SET_LANG_SERVER", MyParam );
__________________
Arkshine is offline
orglee
Member
Join Date: Dec 2005
Old 06-05-2009 , 14:27   Re: [Multilingua] Own multi param function
Reply With Quote #8

Quote:
Originally Posted by arkshine View Post
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.
orglee is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-05-2009 , 14:50   Re: [Multilingua] Own multi param function
Reply With Quote #9

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.
__________________
Arkshine is offline
orglee
Member
Join Date: Dec 2005
Old 06-05-2009 , 15:08   Re: [Multilingua] Own multi param function
Reply With Quote #10

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?
orglee is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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