08.10.2011, 00:56
(
Последний раз редактировалось Abruu; 08.10.2011 в 01:55.
)
Multi Language System
-> short and easy <-
-> 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;
}
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;
}
- 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;
}
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