SA-MP Forums Archive
[Tutorial] How To Use Multi Language - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How To Use Multi Language (/showthread.php?tid=513191)



How To Use Multi Language - AiRaLoKa - 15.05.2014

How To Use Multi Language

Set the player's language
Function:
pawn Код:
PlayerLanguage(playerid, languageid);
  1. First of all you ned to download Multi Language
  2. Then paste it on your pawno's include folder (.../pawn/iclude)
  3. Then you need to add this line to the top of your gamemode or filterscript.

    pawn Код:
    #include <a_samp> // without this, all of your script will never work...
    #include <multilang> // without this, you will never finished this tutorial...
  4. Put these lines under the #include <multilang>

    pawn Код:
    #define EN 0
    #define ID 1 // you can add more language if you can translate it....

    #define DIALOG_LANGUAGE 1000 // define the language selection dialog
  5. Add these lines under OnPlayerConnect callback

    pawn Код:
    ShowPlayerDialog(playerid, DIALOG_LANGUAGE, DIALOG_STYLE_MSGBOX, "Language", "Please choose your language \n\nMohon pilih bahasa anda", "English", "Indonesian"); // it's only the example... you can change the message by yourself
  6. under OnDialogResponse, put these line
    1. option 1
      pawn Код:
      switch(dialogid)
      {
              case DIALOG_LANGUAGE:
              {
              if(response) // if player choose the "English" button
              {
                          PlayerLanguage(playerid, EN); // Set the player's language into EN (language id 0)
              }
              if(!response) // if player choose the "Indonesian" button
              {
                  PlayerLanguage(playerid, ID); // Set the player's language into ID (language id 1)
              }
          }
      }
    2. option 2
      pawn Код:
      if(dialogid == DIALOG_LANGUAGE)
      {
          if(response) // if player choose the "English" button
          {
                      PlayerLanguage(playerid, EN); // Set the player's language into EN (language id 0)
          }
          if(!response) // if player choose the "Indonesian" button
          {
              PlayerLanguage(playerid, ID); // Set the player's language into ID (language id 1)
          }
      }
  7. Finished!
Send a client message to a specific

Function:
pawn Код:
SendClientMessageLang(playerid, language id, color, message);
Example:
pawn Код:
SendClientMessageLang(playerid, EN, 0xFFFFFFFF, "This is the english message"); // Send the message into player if player's language is setted EN. It will not send if player's language is ID
SendClientMessageLang(playerid, ID, 0xFFFFFFFF, "This is the indonesian message"); // Send the message into player if player's language is setted ID. It will not send if player's language is EN
Send client message to all

Function:
pawn Код:
SendClientMessageToAllLang(color, language id, message);
Example:
pawn Код:
SendClientMessageToAllLang(0xFFFFFFFF, EN, "This is the English message"); // Send the message to all player with EN language
SendClientMessageToAllLang(0xFFFFFFFF, ID, "This is the Indonesian message"); // Send the message to all player with ID language
Show a dialog to a specific player

Function:
pawn Код:
ShowPlayerDialogLang(playerid, language id, dialog id, dialog style, caption, message, button 1, button 2);
Example:
  1. First define the dialog'd id
    pawn Код:
    #define YOUR_DIALOG 100
  2. Then show the dialog into the player
    pawn Код:
    ShowPlayerDialogLang(playerid, EN, YOUR_DIALOG, DIALOG_STYLE_MSGBOX, "Dialog", "English dialog", "Button1", "Button2"); // Show the English dialog into player with language id EN
    ShowPlayerDialogLang(playerid, ID, YOUR_DIALOG, DIALOG_STYLE_MSGBOX, "Dialog", "Indonesian dialog", "Button1", "Button2"); // Show the Indonesian dialog into player with language id ID
Show a gametext to a specific player

Function:
pawn Код:
GameTextForPlayerLang(playerid, language id, message, duration, style);
Example:
pawn Код:
GameTextForPlayerLang(playerid, EN, "Message in English", 10000, 2); // Show a game text to palyer with EN language for 10 second. It will not showed if player's language is not EN
GameTextForPlayerLang(playerid, ID, "Message in Indonesian", 10000, 2); // Show a game text to palyer with ID language for 10 second. It will not showed if player's language is not ID
Show a gametext to all player

Function:
pawn Код:
GameTextForAllLang(language id, message, duration, style);
Example:
pawn Код:
GameTextForAllLang(EN, "English message", 10000, 2); // Show a gametext to all player with EN language for 10 second. It will not showed if player's language is not EN
GameTextForAllLang(ID, "Indonesian Message", 10000, 2); // Show a gametext to all player with ID language for 10 second. It will not showed if player's language is not ID
If i made a mistake, please correct me...


Re: How To Use Multi Language - JonyNguyen - 15.05.2014

Good job


Re: How To Use Multi Language - AiRaLoKa - 15.05.2014

Quote:
Originally Posted by JonyNguyen
Посмотреть сообщение
Good job
thanks...


Re: How To Use Multi Language - BlackEvils - 19.05.2014

and if i want for example leangua english | italian if i selelect english i want too see for exmaple all announce in english and if i type italian all in italian how i can do this ?


Re: How To Use Multi Language - NaClchemistryK - 19.05.2014

Quote:
Originally Posted by BlackEvils
Посмотреть сообщение
and if i want for example leangua english | italian if i selelect english i want too see for exmaple all announce in english and if i type italian all in italian how i can do this ?
Somehow connect your server to ****** translator, and let it crappily translate your texts.
Or you can make a triallion lines script under OnPlayerText which translates everything word by word.
Or translate both announcements by yourself.

OnTopic:
You really need to explain more what you are doing in your codes. Otherwise it isn't a tutorial. A tut shows you a tutorial of something, and a tutorial explains. Well, The only positive thing I see here is that there are barely, or not even any tuts that talks about this...


Re: How To Use Multi Language - kloning1 - 20.05.2014

cie, good job sir :3


Re: How To Use Multi Language - AiRaLoKa - 20.05.2014

Quote:
Originally Posted by BlackEvils
Посмотреть сообщение
and if i want for example leangua english | italian if i selelect english i want too see for exmaple all announce in english and if i type italian all in italian how i can do this ?
i dont know what did you mean ?? ?? ??

Quote:
Originally Posted by NaClchemistryK
Посмотреть сообщение
You really need to explain more what you are doing in your codes. Otherwise it isn't a tutorial. A tut shows you a tutorial of something, and a tutorial explains. Well, The only positive thing I see here is that there are barely, or not even any tuts that talks about this...
ok i'll fix it later....
i really-really have no free time, i have to take care of my server...

Quote:
Originally Posted by kloning1
Посмотреть сообщение
cie, good job sir :3
thanks...


Re: How To Use Multi Language - iAnonymous - 20.05.2014

It is not translating the text rather it is simply using a function to send a message in other language ( We have to translate the text our self ) .

OT :
Add some more explanation to your tutorial so that newbies might get something about what you are talking about .


Re: How To Use Multi Language - AiRaLoKa - 20.05.2014

Quote:
Originally Posted by iAnonymous
Посмотреть сообщение
It is not translating the text rather it is simply using a function to send a message in other language ( We have to translate the text our self ) .
thats why i dont give it name AL-Translator :v becouse it just language function