Multi Language System (Very short and easy) -
Abruu - 08.10.2011
Multi Language System
-> short and easy <-
Tutorial in Spanish:
http://forum.sa-mp.com/showthread.ph...40#post1448040
Introduction.
- Hi, well, this is my first tutorial and i'm going to explain how to make a command with "Multi Language" with a easy method. Well, let's start:
Step 1:
Select the language by default
- We need to set the language by default for when we join the server.
- For do that we need to add the follow code in the first part of our script.
pawn Код:
new Language[MAX_PLAYERS] = 0; //Initialize with the Default Language - English
Step 2:
Select language to wiev
- First of all we need to decide what is the predominant language, (You need to decide the language all time that you enter to server).
- For that, add this code under the right public.
pawn Код:
public OnPlayerConnect(playerid)
{
//In this case let's say that the predominant language is English
SendClientMessage(playerid, 0xC0C0C0FF, "The predominant language of this server is: English");
SendClientMessage(playerid, 0xC0C0C0FF, "To change language use: (/english - /spanish"); //I put only the language "English" and "Spanish", but you can add more...
return 1;
}
- Remember that you can change the color of the mensage in where is the "0xC0C0C0FF", that color by default is Grey.
Step 3:
Language Choice
- Now, we need to make the command that set your language to "English" or to "Spanish".
This code goes straight under
OnPlayerCommandText(playerid, cmdtext[]) public.
pawn Код:
//-------------------------------- Set to "English" -------------------------------------//
if((strcmp(cmdtext,"/english",true) == 0) {
Language[playerid] = 0; // Pay attention that the "English" language is in 0
SendClientMessage(playerid,0xC0C0C0FF,"You choose the english language.");
return 1;
}
//-------------------------------- Set to "Spanish" ------------------------------------//
if((strcmp(cmdtext,"/spanish",true) == 0) {
Language[playerid] = 1; // Pay attention that the "Spanish" language is in 1
SendClientMessage(playerid,0xC0C0C0FF,"Elegistes el idioma espaсol.");
return 1;
}
Step 4:
How to send language messages
- When a player for example, types /help, we need to see what language he has, so we can send him the right message in the right language.
pawn Код:
if((strcmp(cmdtext,"/help",true) == 0) // English
||(strcmp(cmdtext,"/ayuda",true) == 0)) // Spanish
{
switch (Language[playerid])
{
case 0: //Now you see why i say after pay attention to the number 0.
{
SendClientMessage(playerid,0xFFD400AA,"HELP:");
SendClientMessage(playerid,0xFFD400AA,"Type /lock to close your vehicle.");
SendClientMessage(playerid,0xFFD400AA,"Type /unlock to open your vehicle.");
}
case 1: //Now you see why i say after pay attention to the number 1.
{
SendClientMessage(playerid,0xFFD400AA,"AYUDA:");
SendClientMessage(playerid,0xFFD400AA,"Escribe /lock para bloquear tu vehiculo.");
SendClientMessage(playerid,0xFFD400AA,"Escribe /unlock para desbloquear tu vehiculo.");
}
}
return 1;
}
-> Well, that is all, very easy and short method

Remember that is my first tutorial so please say me if i'am doing well the tutorial or no and i dont know, only enjoin it :P
P.S: My real language is spanish so if i have somethings bad writed is because i do what i can

and I don't test this because i'am bussy, but I'm sure it works
Re: Multi Language System (Very short and easy) -
NicoBellic - 08.10.2011
nice tut, but i think that it is a rough metod to implement a multilanguage system...
Respuesta: Re: Multi Language System (Very short and easy) -
Abruu - 08.10.2011
Quote:
Originally Posted by NicoBellic
nice tut, but i think that it is a rough metod to implement a multilanguage system...
|
Yes, idk, is my first tutorial and i dont know what i can do
Thanks for comment
Re: Multi Language System (Very short and easy) -
Ћilvėnas - 08.10.2011
good
Re: Multi Language System (Very short and easy) -
FireCat - 08.10.2011
Try making a function like
pawn Код:
stock SendLangMessage(playerid,color[],lang1[],lang2[])
{
switch(Language[playerid])
{
case 0:{SendClientMessage(playerid,color,lang1);}
case 1:{SendClientMessage(playerid,color,lang2);}
}
return 1;
}
Re: Multi Language System (Very short and easy) - array13 - 08.10.2011
this will be usefull for server of portuguese/english, spanish/french, arabic/russian....
Re: Multi Language System (Very short and easy) -
Ironboy - 09.10.2011
I have seen many Multilanguage tutorials like this but only some text are converting into other languages :/
Re: Multi Language System (Very short and easy) -
AndreT - 09.10.2011
The most convenient way would be doing multilingual systems the way YSI does (as far as I know, haven't checked though). You should have several language files in XML format. When a message is sent, then based on the player's language preference, it should read the right XML file and send that message.
AW: Multi Language System (Very short and easy) -
Johann95 - 09.10.2011
Very Good
Thank You
Re: Multi Language System (Very short and easy) -
Chris# - 16.10.2011
Quote:
Originally Posted by FireCat
Try making a function like
pawn Код:
stock SendLangMessage(playerid,color[],lang1[],lang2[]) { switch(Language[playerid]) { case 0:{SendClientMessage(playerid,color,lang1);} case 1:{SendClientMessage(playerid,color,lang2);} } return 1; }
|
or
pawn Код:
SendLanguageMessage( szP, color, es[ ], eng[ ] )
{
if( Language[ szP ] = 0 ) SendClientMessage( szP, color, es ) ;
else if( Language[ szP ] = 1 ) SendClientMessage( szP, color, eng ) ;
else SendClientMessage( szP, color, "Unknown language" ) ;
return 1;
}
Use
pawn Код:
CMD:lmessage( playerid, params[ ])
{
SendLanguageMessage( playerid, -1, "Spanish" , "English" )
return true;
}