AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   multilang message (https://forums.alliedmods.net/showthread.php?t=319132)

Mankled 10-13-2019 14:43

multilang message
 
can someone help me to put ML in this code
PHP Code:

public client_authorized(id)
{
    if(
is_user_bot(id)) return PLUGIN_CONTINUE;

    new 
szUserName[33];
    
get_user_name(idszUserName32);

    new 
szAuthID[33];
    
get_user_ip(id szAuthID 32);
    
    new 
iPlayers[32], iNumi;
    
get_players(iPlayersiNum);

    for(
0<= iNumi++)
    {
        new 
iPlayers[i];

        if(!
is_user_connected(x) || is_user_bot(x)) continue;

        
client_cmd(x"spk %s"g_szSoundFile);

        new 
szMessage[164];
        
format(szMessage163"^x04%s (^x01%s^x04) Connected!!!"szUserName szAuthID);

        
message_beginMSG_ONEg_iMsgSayText, {0,0,0}, );
        
write_byte  );
        
write_stringszMessage );
        
message_end ();
    }

    return 
PLUGIN_CONTINUE;


i suck putting ml, i can only put it on client_print

line where i want ML
PHP Code:

format(szMessage163"^x04%s (^x01%s^x04) Connected!!!"szUserName szAuthID); 


LearninG 10-13-2019 15:22

Re: multilang message
 
take a look to this example :
https://forums.alliedmods.net/showpo...72&postcount=4

Mankled 10-13-2019 15:39

Re: multilang message
 
but can i use formatex instead format ?

iceeedr 10-13-2019 17:31

Re: multilang message
 
Sure.

By the way, you have an error on this line.

PHP Code:

for(0<= iNumi++) 

:arrow:

PHP Code:

for(0iNumi++) 


Mankled 10-13-2019 18:47

Re: multilang message
 
im having some difficulties with ML, i dont understand well, i saw this topic : https://forums.alliedmods.net/showth...ngual+tutorial on comments section YamiKaitou said:
Quote:

Originally Posted by YamiKaitou (Post 1844771)
Use LANG_SERVER when you want to output the message in the language of the server.
Use LANG_PLAYER when you want to output the message to all users at once (ie, "client_print(0, ...." ) in their language
Use Player Index when you want to output the message to a specific user in their language

ok, everything that he said, i understood.

but fysiks said it:
Quote:

Originally Posted by fysiks (Post 1844889)
And as a consequence, you cannot use LANG_PLAYER with format functions (format and formatex).

"you cannot use lang_player with format functions (format and formatex)

if i cannot use it, what should i use when i see it:
PHP Code:

format(szMessage163"^x04%s (^x01%s^x04) Connected!!!"szUserName szAuthID); 


OciXCrom 10-13-2019 20:57

Re: multilang message
 
You would use the player's index instead of LANG_PLAYER.
Also, you should use "formatex" and "charsmax" almost every time.

Mankled 10-13-2019 21:55

Re: multilang message
 
Quote:

Originally Posted by OciXCrom (Post 2669698)
You would use the player's index instead of LANG_PLAYER.
Also, you should use "formatex" and "charsmax" almost every time.

and what about he said here:

Quote:

Originally Posted by fysiks (Post 1844889)
And as a consequence, you cannot use LANG_PLAYER with format functions (format and formatex).


iceeedr 10-14-2019 01:13

Re: multilang message
 
PHP Code:

new TranslatedMessage[164]
    
formatex(TranslatedMessagecharsmax(TranslatedMessage), "%L"LANG_PLAYER"yourmessagename"szUserName szAuthID


ML File

Code:

[language name]
youmessagename = ^4%s (^1%s^4) Connected!!!

In plugin_init

PHP Code:

register_dictionary("myplugin.txt"


Mankled 10-14-2019 01:42

Re: multilang message
 
Quote:

Originally Posted by iceeedr (Post 2669704)
PHP Code:

new TranslatedMessage[164]
    
formatex(TranslatedMessagecharsmax(TranslatedMessage), "%L"LANG_PLAYER"yourmessagename"szUserName szAuthID


ML File

Code:

[language name]
youmessagename = ^4%s (^1%s^4) Connected!!!

In plugin_init

PHP Code:

register_dictionary("myplugin.txt"



Thank you

fysiks 10-14-2019 22:03

Re: multilang message
 
Quote:

Originally Posted by iceeedr (Post 2669704)
PHP Code:

new TranslatedMessage[164]
    
formatex(TranslatedMessagecharsmax(TranslatedMessage), "%L"LANG_PLAYER"yourmessagename"szUserName szAuthID


Perhaps you should read a little bit more closely, you did exactly what you can't do: You can't use LANG_PLAYER with format() or formatex(). You can only use it with client_print() (there might be some others but they have to print directly to the player).

So, in your case,
Quote:

Originally Posted by OciXCrom (Post 2669698)
You would use the player's index instead of LANG_PLAYER.



All times are GMT -4. The time now is 20:54.

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