Badyx

[Base] Sistema multiidioma.

Aug 11th, 2018
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.42 KB | None | 0 0
  1. /*
  2.  
  3.         <======================================================================>
  4.         Base para sistema de idiomas By BadyX
  5.        
  6.         Explicación:
  7.        
  8.         Una vez definido el idioma que en este caso sería:
  9.        
  10.         1 - Ingles.
  11.         2 - Español.
  12.        
  13.         Usaríamos la función IncluirTextoTraducido de la siguiente forma:
  14.        
  15.         IncluirTextoTraducido(Jugador, Opcion);
  16.        
  17.         IncluirTextoTraducido   <====>  Sería el nombre de la función
  18.         Jugador                 <====>  La ID del jugador
  19.         Opcion                  <====>  Aquí vendría lo simple.
  20.        
  21.         Para no complicar demasiado vamos a seguir el siguiente patrón.
  22.        
  23.         Supongamos que queremos usar el siguiente texto:
  24.        
  25.         Soy un mensaje de prueba
  26.        
  27.         La forma correcta de llamarlo sería:
  28.        
  29.         IncluirTextoTraducido(playerid, 0); // El 0 sería la ID de la opción.
  30.        
  31.         Ahora si por ejemplo pusieramos:
  32.        
  33.         IncluirTextoTraducido(playerid, 1);
  34.        
  35.         Nos enviaría a la funcion de IncluirTextoTraducido pero con la opción 1 y daría el texto:
  36.        
  37.         Soy un mensaje de prueba x2
  38.        
  39.         Si añadieramos un 2 en la opción daría el siguiente mensaje.
  40.        
  41.         Soy un mensaje de prueba x3
  42.         <======================================================================>
  43.        
  44. */
  45.  
  46. #include <a_samp>
  47. #include <zcmd>
  48.  
  49. #define DIALOG_LENGUAGE 3000
  50.  
  51. enum pInfo
  52. {
  53.     pIdioma
  54. };
  55. new PlayerInfo[MAX_PLAYERS][pInfo]; //Con esto se guardaría el idioma seleccionado. Lógicamente tendrás que guardar/cargar la variable en la cuenta del usuario.
  56.  
  57. CMD:comando(playerid, params[])
  58. {
  59.     ShowPlayerDialog(playerid, DIALOG_LENGUAGE, DIALOG_STYLE_MSGBOX, "{0092FF}Welcome","\n{FFFFFF}\tPlease, choose a language you would like to display.\n\n\tPor favor, elija el idioma que desea mostrar.","{FFFFFF}English","{FFFFFF}Español");
  60.     return 1;
  61. }
  62.  
  63. CMD:prueba(playerid, params[])
  64. {
  65.     IncluirTextoTraducido(playerid, 0);
  66.     return 1;
  67. }
  68.  
  69. CMD:prueba1(playerid, params[])
  70. {
  71.     IncluirTextoTraducido(playerid, 1);
  72.     return 1;
  73. }
  74.  
  75. CMD:prueba2(playerid, params[])
  76. {
  77.     IncluirTextoTraducido(playerid, 2);
  78.     return 1;
  79. }
  80.  
  81. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  82. {
  83.     switch(dialogid)
  84.     {
  85.         case DIALOG_LENGUAGE:
  86.         {
  87.             if(!response)   return SendClientMessage(playerid, 1, "{33CCFF}[Info]{FFFFFF} Cerraste el menú -- Closed the menu.");
  88.             switch(listitem)
  89.             {
  90.                 case 0:
  91.                 {
  92.                     SendClientMessage(playerid, 1, "You selected how the main language is English.");
  93.                     PlayerInfo[playerid][pIdioma] = 1;
  94.                
  95.                 }
  96.                 case 1:
  97.                 {
  98.                     SendClientMessage(playerid, 1, "Seleccionaste cómo idioma principal el español.");
  99.                     PlayerInfo[playerid][pIdioma] = 1;
  100.                 }
  101.             }
  102.         }
  103.     }
  104.     return 1;
  105. }
  106.  
  107. forward  IncluirTextoTraducido(Jugador, Opcion);
  108. public IncluirTextoTraducido(Jugador, Opcion)
  109. {
  110.     switch(Opcion)
  111.     {
  112.         case 0:
  113.         {
  114.             switch(PlayerInfo[Jugador][pIdioma])
  115.             {
  116.                 case 1: SendClientMessage(Jugador, 1, "I am a test message.");
  117.                 case 2: SendClientMessage(Jugador, 1, "Soy un mensaje de prueba.");
  118.             }
  119.         }
  120.         case 1:
  121.         {
  122.             switch(PlayerInfo[Jugador][pIdioma])
  123.             {
  124.                 case 1: SendClientMessage(Jugador, 1, "I am a test message x2.");
  125.                 case 2: SendClientMessage(Jugador, 1, "Soy un mensaje de prueba x2.");
  126.             }
  127.         }
  128.         case 2:
  129.         {
  130.             switch(PlayerInfo[Jugador][pIdioma])
  131.             {
  132.                 case 1: SendClientMessage(Jugador, 1, "I am a test message x3.");
  133.                 case 2: SendClientMessage(Jugador, 1, "Soy un mensaje de prueba x3.");
  134.             }
  135.         }
  136.         default:
  137.         {
  138.             switch(PlayerInfo[Jugador][pIdioma])
  139.             {
  140.                 case 1: SendClientMessage(Jugador, 1, "Unknown option.");
  141.                 case 2: SendClientMessage(Jugador, 1, "Opción desconocida.");
  142.             }
  143.        
  144.         }
  145.         //Etc etc etc.
  146.     }
  147.     return 1;
  148. }
  149.  
  150. //============================================================================//
  151. //                                                                            //
  152. //                 SI TE SIRVIÓ RESPETA EL TRABAJO DEL CREADOR                //
  153. //                                                                            //
  154. //                      Sistema creado por Badyx                              //
  155. //                                                                            //
  156. //============================================================================//
Advertisement
Add Comment
Please, Sign In to add comment